Skip to content

Commit 8bd11f8

Browse files
committed
Cpufreq: ensure frequency label always shows up if freq selected
Remove old code left over from GTK2 that never worked properly in GTK 3
1 parent a3c1c30 commit 8bd11f8

File tree

1 file changed

+7
-44
lines changed

1 file changed

+7
-44
lines changed

cpufreq/src/cpufreq-applet.c

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ static gboolean cpufreq_applet_key_press (GtkWidget *widget,
103103
GdkEventKey *event);
104104
static void cpufreq_applet_size_allocate (GtkWidget *widget,
105105
GtkAllocation *allocation);
106-
static void cpufreq_applet_get_preferred_width (GtkWidget *widget,
107-
gint *minimum_width,
108-
gint *natural_width);
109106
static void cpufreq_applet_change_orient (MatePanelApplet *pa,
110107
MatePanelAppletOrient orient);
111108
static void cpufreq_applet_style_updated (GtkWidget *widget);
@@ -224,7 +221,6 @@ cpufreq_applet_class_init (CPUFreqAppletClass *klass)
224221

225222
widget_class->size_allocate = cpufreq_applet_size_allocate;
226223
widget_class->style_updated = cpufreq_applet_style_updated;
227-
widget_class->get_preferred_width = cpufreq_applet_get_preferred_width;
228224
widget_class->button_press_event = cpufreq_applet_button_press;
229225
widget_class->key_press_event = cpufreq_applet_key_press;
230226

@@ -366,46 +362,6 @@ cpufreq_applet_get_max_unit_width (CPUFreqApplet *applet)
366362
return applet->max_unit_width;
367363
}
368364

369-
static void
370-
cpufreq_applet_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width)
371-
{
372-
CPUFreqApplet *applet;
373-
gint labels_width = 0;
374-
gint width;
375-
gint scale;
376-
377-
applet = CPUFREQ_APPLET (widget);
378-
scale = gtk_widget_get_scale_factor (widget);
379-
380-
if (applet->orient == MATE_PANEL_APPLET_ORIENT_LEFT ||
381-
applet->orient == MATE_PANEL_APPLET_ORIENT_RIGHT)
382-
return;
383-
384-
385-
if (applet->show_freq) {
386-
labels_width += cpufreq_applet_get_max_label_width (applet) + 2;
387-
}
388-
389-
if (applet->show_perc) {
390-
labels_width += cpufreq_applet_get_max_perc_width (applet);
391-
}
392-
393-
if (applet->show_unit) {
394-
labels_width += cpufreq_applet_get_max_unit_width (applet);
395-
}
396-
397-
if (applet->show_icon) {
398-
gint icon_width;
399-
400-
gtk_widget_get_preferred_width (applet->icon, &icon_width, NULL);
401-
width = (labels_width + icon_width + 2);
402-
} else {
403-
width = labels_width;
404-
}
405-
406-
*minimum_width = *natural_width = width / scale;
407-
}
408-
409365
static void
410366
cpufreq_applet_popup_position_menu (GtkMenu *menu,
411367
int *x,
@@ -579,6 +535,10 @@ cpufreq_applet_style_updated (GtkWidget *widget)
579535
applet->max_perc_width = 0;
580536

581537
cpufreq_applet_refresh (applet);
538+
539+
/*Reset label sizes to zero that have been held to maximum reached width*/
540+
gtk_widget_set_size_request (GTK_WIDGET (applet->label), 0, 0);
541+
gtk_widget_set_size_request (GTK_WIDGET (applet->unit_label), 0, 0);
582542
}
583543

584544
static void
@@ -809,6 +769,9 @@ cpufreq_applet_update (CPUFreqApplet *applet, CPUFreqMonitor *monitor)
809769

810770
if (applet->show_unit) {
811771
gtk_label_set_text (GTK_LABEL (applet->unit_label), unit_label);
772+
/*Hold the largest size set by MHZ or GHZ to prevent jumping */
773+
gtk_widget_get_preferred_size (GTK_WIDGET (applet->unit_label),&req, NULL);
774+
gtk_widget_set_size_request (GTK_WIDGET (applet->unit_label),req.width, req.height);
812775
}
813776

814777
if (applet->show_icon) {

0 commit comments

Comments
 (0)