@@ -64,10 +64,6 @@ struct _CPUFreqApplet {
6464 GtkWidget * container ;
6565 cairo_surface_t * surfaces [5 ];
6666
67- gint max_label_width ;
68- gint max_perc_width ;
69- gint max_unit_width ;
70-
7167 gboolean need_refresh ;
7268
7369 CPUFreqPrefs * prefs ;
@@ -305,63 +301,6 @@ get_max_text_width (GtkWidget *widget,
305301 return logical_rect .width ;
306302}
307303
308- static gint
309- cpufreq_applet_get_max_label_width (CPUFreqApplet * applet )
310- {
311- GList * available_freqs ;
312- gint width = 0 ;
313-
314- if (applet -> max_label_width > 0 )
315- return applet -> max_label_width ;
316-
317- if (!CPUFREQ_IS_MONITOR (applet -> monitor ))
318- return 0 ;
319-
320- available_freqs = cpufreq_monitor_get_available_frequencies (applet -> monitor );
321- while (available_freqs ) {
322- gint label_width ;
323- const gchar * text ;
324- gchar * freq_text ;
325- gint freq ;
326-
327- text = (const gchar * ) available_freqs -> data ;
328- freq = atoi (text );
329-
330- freq_text = cpufreq_utils_get_frequency_label (freq );
331- label_width = get_max_text_width (applet -> label , freq_text );
332- width = MAX (width , label_width );
333-
334- g_free (freq_text );
335-
336- available_freqs = g_list_next (available_freqs );
337- }
338-
339- applet -> max_label_width = width ;
340-
341- return width ;
342- }
343-
344- static gint
345- cpufreq_applet_get_max_perc_width (CPUFreqApplet * applet )
346- {
347- if (applet -> max_perc_width > 0 )
348- return applet -> max_perc_width ;
349-
350- applet -> max_perc_width = get_max_text_width (applet -> label , "100%" );
351- return applet -> max_perc_width ;
352- }
353-
354- static gint
355- cpufreq_applet_get_max_unit_width (CPUFreqApplet * applet )
356- {
357- if (applet -> max_unit_width > 0 )
358- return applet -> max_unit_width ;
359-
360- applet -> max_unit_width = MAX (get_max_text_width (applet -> unit_label , "GHz" ),
361- get_max_text_width (applet -> unit_label , "MHz" ));
362- return applet -> max_unit_width ;
363- }
364-
365304static void
366305cpufreq_applet_popup_position_menu (GtkMenu * menu ,
367306 int * x ,
@@ -530,10 +469,6 @@ cpufreq_applet_style_updated (GtkWidget *widget)
530469
531470 applet = CPUFREQ_APPLET (widget );
532471
533- applet -> max_label_width = 0 ;
534- applet -> max_unit_width = 0 ;
535- applet -> max_perc_width = 0 ;
536-
537472 cpufreq_applet_refresh (applet );
538473
539474 /*Reset label sizes to zero that have been held to maximum reached width*/
@@ -811,34 +746,6 @@ cpufreq_applet_update (CPUFreqApplet *applet, CPUFreqMonitor *monitor)
811746 }
812747}
813748
814- static gint
815- cpufreq_applet_get_widget_size (CPUFreqApplet * applet ,
816- GtkWidget * widget )
817- {
818- GtkRequisition req ;
819- gint size ;
820-
821- if (!gtk_widget_get_visible (widget ))
822- return 0 ;
823-
824- gtk_widget_get_preferred_size (widget , & req , NULL );
825-
826- switch (applet -> orient ) {
827- case MATE_PANEL_APPLET_ORIENT_LEFT :
828- case MATE_PANEL_APPLET_ORIENT_RIGHT :
829- size = req .width ;
830- break ;
831- case MATE_PANEL_APPLET_ORIENT_UP :
832- case MATE_PANEL_APPLET_ORIENT_DOWN :
833- size = req .height ;
834- break ;
835- default :
836- g_assert_not_reached ();
837- }
838-
839- return size ;
840- }
841-
842749static void
843750cpufreq_applet_refresh (CPUFreqApplet * applet )
844751{
@@ -848,32 +755,23 @@ cpufreq_applet_refresh (CPUFreqApplet *applet)
848755 gint size_step = 12 ;
849756 gboolean horizontal ;
850757 gboolean do_unref = FALSE;
851- GtkRequisition req ;
852758
853759 panel_size = applet -> size - 1 ; /* 1 pixel margin */
854760
855761 horizontal = (applet -> orient == MATE_PANEL_APPLET_ORIENT_UP ||
856762 applet -> orient == MATE_PANEL_APPLET_ORIENT_DOWN );
857763
858- /* Zero out and reset the size of the label in case the theme is getting smaller */
859- gtk_widget_set_size_request (GTK_WIDGET (applet -> label ), 0 , 0 );
860- gtk_widget_get_preferred_size (GTK_WIDGET (applet -> label ),& req , NULL );
861- gtk_widget_set_size_request (GTK_WIDGET (applet -> label ),req .width , req .height );
764+
862765 /* We want a fixed label size, the biggest */
863- if (horizontal )
864- label_size = cpufreq_applet_get_widget_size (applet , applet -> label );
865- else
866- label_size = cpufreq_applet_get_max_label_width (applet );
867- total_size += label_size ;
868-
869- if (horizontal )
870- unit_label_size = cpufreq_applet_get_widget_size (applet , applet -> unit_label );
871- else
872- unit_label_size = cpufreq_applet_get_max_unit_width (applet );
873- total_size += unit_label_size ;
874-
875- pixmap_size = cpufreq_applet_get_widget_size (applet , applet -> icon );
876- total_size += pixmap_size ;
766+
767+ gtk_widget_get_preferred_width (GTK_WIDGET (applet -> label ), & label_size , NULL );
768+ total_size += label_size ;
769+
770+ gtk_widget_get_preferred_width (GTK_WIDGET (applet -> unit_label ), & unit_label_size , NULL );
771+ total_size += unit_label_size ;
772+
773+ gtk_widget_get_preferred_width (GTK_WIDGET (applet -> icon ), & pixmap_size , NULL );
774+ total_size += pixmap_size ;
877775
878776 if (applet -> box ) {
879777 do_unref = TRUE;
0 commit comments