diff options
author | lukefromdc <[email protected]> | 2016-03-07 01:51:31 -0500 |
---|---|---|
committer | lukefromdc <[email protected]> | 2016-03-07 01:51:31 -0500 |
commit | 300ef94527f603311fed18d7d632740ecf56163c (patch) | |
tree | 49e09b74420689c1c32b1724d6929b40c72a8e96 /cpufreq/src/cpufreq-applet.c | |
parent | 7d17435dedc9936a20c52df34ba449b6dbd440e0 (diff) | |
download | mate-applets-300ef94527f603311fed18d7d632740ecf56163c.tar.bz2 mate-applets-300ef94527f603311fed18d7d632740ecf56163c.tar.xz |
cpufreq GTK3: hardcode fewer labels
In gtk3, replacing "label" with "applet->label" makes the gtk_widget_get_preferred_width functions work for the frequency and unit labels without issue. Trim them a bit in gtk3.19 builds as they render 2px wider there for some reason. The exception is the percentage label. That one apparently always starts with "0%" entered-and it does NOT update it's width when larger character strings come up. Thus, a fixed figure of 20px still has to be added to that one. On the other hand, that will ensure the applet never jumps from percentage changes. Height of the whole applet is still limited somewhere to 24 px, still looking for that issue as it hurts the match to taller panels.
Diffstat (limited to 'cpufreq/src/cpufreq-applet.c')
-rw-r--r-- | cpufreq/src/cpufreq-applet.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/cpufreq/src/cpufreq-applet.c b/cpufreq/src/cpufreq-applet.c index 3596dadd..10ed6aad 100644 --- a/cpufreq/src/cpufreq-applet.c +++ b/cpufreq/src/cpufreq-applet.c @@ -16,7 +16,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * - * Authors : Carlos Garc�a Campos <[email protected]> + * Authors : Carlos García Campos <[email protected]> */ #ifdef HAVE_CONFIG_H @@ -333,9 +333,15 @@ cpufreq_applet_get_max_label_width (CPUFreqApplet *applet) freq_text = cpufreq_utils_get_frequency_label (freq); label = gtk_label_new (freq_text); #if GTK_CHECK_VERSION (3, 0, 0) - gtk_widget_get_preferred_width (label, &label_width, NULL); - width = MAX (width, label_width); + gtk_widget_get_preferred_width (applet->label, &label_width, NULL); + +#if GTK_CHECK_VERSION (3, 19, 0) + width = MAX (width, label_width)-2; #else + width = MAX (width, label_width); +#endif +#endif +#if !GTK_CHECK_VERSION (3, 0, 0) gtk_widget_size_request (label, &req); width = MAX (width, req.width); #endif @@ -366,8 +372,8 @@ cpufreq_applet_get_max_perc_width (CPUFreqApplet *applet) label = gtk_label_new ("100%"); #if GTK_CHECK_VERSION (3, 0, 0) - gtk_widget_get_preferred_width (label, &width, NULL); - applet->max_perc_width = width; + gtk_widget_get_preferred_width (applet->label, &width,&width); + applet->max_perc_width = width +20; /*for some reason width always comes up 2 characters*/ #else gtk_widget_size_request (label, &req); applet->max_perc_width = req.width; @@ -391,7 +397,7 @@ cpufreq_applet_get_max_unit_width (CPUFreqApplet *applet) label = gtk_label_new ("GHz"); #if GTK_CHECK_VERSION (3, 0, 0) - gtk_widget_get_preferred_width (label, &w1, NULL); + gtk_widget_get_preferred_width (applet->label, &w1, NULL); #else gtk_widget_size_request (label, &req); w1 = req.width; @@ -399,16 +405,18 @@ cpufreq_applet_get_max_unit_width (CPUFreqApplet *applet) gtk_label_set_text (GTK_LABEL (label), "MHz"); #if GTK_CHECK_VERSION (3, 0, 0) - gtk_widget_get_preferred_width (label, &w2, NULL); + gtk_widget_get_preferred_width (applet->label, &w2, NULL); #else gtk_widget_size_request (label, &req); w2 = req.width; #endif gtk_widget_destroy (label); - +#if GTK_CHECK_VERSION (3, 0, 0) + applet->max_unit_width = MAX (w1, w2)-1; +#else applet->max_unit_width = MAX (w1, w2); - +#endif return applet->max_unit_width; } @@ -433,19 +441,7 @@ cpufreq_applet_size_request (GtkWidget *widget, GtkRequisition *requisition) applet->orient == MATE_PANEL_APPLET_ORIENT_RIGHT) return; -#if GTK_CHECK_VERSION (3, 0, 0) - /*Specify numerical values so labels in gtk3 don't get zero width */ - if (applet->show_freq) { - labels_width += 50; - } - - if (applet->show_perc) { - labels_width += 50; - } - if (applet->show_unit) { - labels_width += 20; -#else if (applet->show_freq) { labels_width += cpufreq_applet_get_max_label_width (applet) + 2; } @@ -456,7 +452,6 @@ cpufreq_applet_size_request (GtkWidget *widget, GtkRequisition *requisition) if (applet->show_unit) { labels_width += cpufreq_applet_get_max_unit_width (applet); -#endif } if (applet->show_icon) { |