diff options
author | lukefromdc <[email protected]> | 2018-06-08 17:53:48 -0400 |
---|---|---|
committer | lukefromdc <[email protected]> | 2018-06-11 14:23:44 -0400 |
commit | 8bd11f81e05d8498c530e3951fa0f1c2b67a74b8 (patch) | |
tree | 609de16ba221f5da96aadc5b9ee337fe760b2bc6 /cpufreq/src/cpufreq-applet.c | |
parent | a3c1c30f19430d08053bfc251bd26bb55a94a42a (diff) | |
download | mate-applets-8bd11f81e05d8498c530e3951fa0f1c2b67a74b8.tar.bz2 mate-applets-8bd11f81e05d8498c530e3951fa0f1c2b67a74b8.tar.xz |
Cpufreq: ensure frequency label always shows up if freq selected
Remove old code left over from GTK2 that never worked properly in GTK 3
Diffstat (limited to 'cpufreq/src/cpufreq-applet.c')
-rw-r--r-- | cpufreq/src/cpufreq-applet.c | 51 |
1 files changed, 7 insertions, 44 deletions
diff --git a/cpufreq/src/cpufreq-applet.c b/cpufreq/src/cpufreq-applet.c index d40ae0b4..e9be2701 100644 --- a/cpufreq/src/cpufreq-applet.c +++ b/cpufreq/src/cpufreq-applet.c @@ -103,9 +103,6 @@ static gboolean cpufreq_applet_key_press (GtkWidget *widget, GdkEventKey *event); static void cpufreq_applet_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static void cpufreq_applet_get_preferred_width (GtkWidget *widget, - gint *minimum_width, - gint *natural_width); static void cpufreq_applet_change_orient (MatePanelApplet *pa, MatePanelAppletOrient orient); static void cpufreq_applet_style_updated (GtkWidget *widget); @@ -224,7 +221,6 @@ cpufreq_applet_class_init (CPUFreqAppletClass *klass) widget_class->size_allocate = cpufreq_applet_size_allocate; widget_class->style_updated = cpufreq_applet_style_updated; - widget_class->get_preferred_width = cpufreq_applet_get_preferred_width; widget_class->button_press_event = cpufreq_applet_button_press; widget_class->key_press_event = cpufreq_applet_key_press; @@ -367,46 +363,6 @@ cpufreq_applet_get_max_unit_width (CPUFreqApplet *applet) } static void -cpufreq_applet_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width) -{ - CPUFreqApplet *applet; - gint labels_width = 0; - gint width; - gint scale; - - applet = CPUFREQ_APPLET (widget); - scale = gtk_widget_get_scale_factor (widget); - - if (applet->orient == MATE_PANEL_APPLET_ORIENT_LEFT || - applet->orient == MATE_PANEL_APPLET_ORIENT_RIGHT) - return; - - - if (applet->show_freq) { - labels_width += cpufreq_applet_get_max_label_width (applet) + 2; - } - - if (applet->show_perc) { - labels_width += cpufreq_applet_get_max_perc_width (applet); - } - - if (applet->show_unit) { - labels_width += cpufreq_applet_get_max_unit_width (applet); - } - - if (applet->show_icon) { - gint icon_width; - - gtk_widget_get_preferred_width (applet->icon, &icon_width, NULL); - width = (labels_width + icon_width + 2); - } else { - width = labels_width; - } - - *minimum_width = *natural_width = width / scale; -} - -static void cpufreq_applet_popup_position_menu (GtkMenu *menu, int *x, int *y, @@ -579,6 +535,10 @@ cpufreq_applet_style_updated (GtkWidget *widget) applet->max_perc_width = 0; cpufreq_applet_refresh (applet); + + /*Reset label sizes to zero that have been held to maximum reached width*/ + gtk_widget_set_size_request (GTK_WIDGET (applet->label), 0, 0); + gtk_widget_set_size_request (GTK_WIDGET (applet->unit_label), 0, 0); } static void @@ -809,6 +769,9 @@ cpufreq_applet_update (CPUFreqApplet *applet, CPUFreqMonitor *monitor) if (applet->show_unit) { gtk_label_set_text (GTK_LABEL (applet->unit_label), unit_label); + /*Hold the largest size set by MHZ or GHZ to prevent jumping */ + gtk_widget_get_preferred_size (GTK_WIDGET (applet->unit_label),&req, NULL); + gtk_widget_set_size_request (GTK_WIDGET (applet->unit_label),req.width, req.height); } if (applet->show_icon) { |