From 64183866c2f4417074d45d1b66d53f1ac64b4216 Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Fri, 19 Dec 2014 20:00:34 +0100 Subject: Fix panel resizing caused by freq format function (bug #10385). --- panel-plugin/xfce4-cpufreq-configure.c | 2 ++ panel-plugin/xfce4-cpufreq-plugin.c | 17 +++++++++++++++++ panel-plugin/xfce4-cpufreq-plugin.h | 1 + 3 files changed, 20 insertions(+) diff --git a/panel-plugin/xfce4-cpufreq-configure.c b/panel-plugin/xfce4-cpufreq-configure.c index 125bec0..d209a41 100644 --- a/panel-plugin/xfce4-cpufreq-configure.c +++ b/panel-plugin/xfce4-cpufreq-configure.c @@ -66,6 +66,7 @@ check_button_changed (GtkWidget *button, CpuFreqPluginConfigure *configure) gtk_widget_set_sensitive (configure->display_icon, TRUE); cpufreq_update_icon (cpuFreq); + cpuFreq->label_max_width = -1; cpuFreq->layout_changed = TRUE; cpufreq_update_plugin (); } @@ -85,6 +86,7 @@ button_fontname_update(GtkWidget *button, } if (update_plugin) { cpufreq_label_set_font (); + cpuFreq->label_max_width = -1; cpuFreq->layout_changed = TRUE; cpufreq_update_plugin (); } diff --git a/panel-plugin/xfce4-cpufreq-plugin.c b/panel-plugin/xfce4-cpufreq-plugin.c index 322ddd0..f3c9fed 100644 --- a/panel-plugin/xfce4-cpufreq-plugin.c +++ b/panel-plugin/xfce4-cpufreq-plugin.c @@ -201,6 +201,21 @@ cpufreq_widgets_layout (void) iw = icon_size.width; ih = icon_size.height; } + + /* Set label width to max width if smaller to avoid panel + resizing/jumping (see bug #10385). */ + if (label_size.width < cpuFreq->label_max_width) + gtk_widget_set_size_request (GTK_WIDGET (cpuFreq->label), + cpuFreq->label_max_width, -1); + else { + /* remember label max width */ + if (label_size.width > cpuFreq->label_max_width) + cpuFreq->label_max_width = label_size.width; + + gtk_widget_set_size_request (GTK_WIDGET (cpuFreq->label), + -1, -1); + } + if (cpuFreq->panel_mode == XFCE_PANEL_PLUGIN_MODE_HORIZONTAL && orientation == GTK_ORIENTATION_VERTICAL && lh + ih + BORDER * 2 >= cpuFreq->panel_size) { @@ -551,6 +566,7 @@ cpufreq_set_size (XfcePanelPlugin *plugin, gint size, CpuFreqPlugin *cpufreq) { cpuFreq->panel_size = size; cpuFreq->panel_rows = xfce_panel_plugin_get_nrows (plugin); + cpuFreq->label_max_width = -1; cpuFreq->layout_changed = TRUE; cpufreq_update_icon (cpufreq); cpufreq_update_plugin (); @@ -596,6 +612,7 @@ cpufreq_construct (XfcePanelPlugin *plugin) cpuFreq->panel_mode = xfce_panel_plugin_get_mode (cpuFreq->plugin); cpuFreq->panel_rows = xfce_panel_plugin_get_nrows (cpuFreq->plugin); cpuFreq->panel_size = xfce_panel_plugin_get_size (cpuFreq->plugin); + cpuFreq->label_max_width = -1; cpuFreq->cpus = g_ptr_array_new (); cpufreq_read_config (); diff --git a/panel-plugin/xfce4-cpufreq-plugin.h b/panel-plugin/xfce4-cpufreq-plugin.h index 96fa05a..d69a37a 100644 --- a/panel-plugin/xfce4-cpufreq-plugin.h +++ b/panel-plugin/xfce4-cpufreq-plugin.h @@ -84,6 +84,7 @@ typedef struct /* Widgets */ GtkWidget *button, *box, *icon, *label; gboolean layout_changed; + gint label_max_width; CpuFreqPluginOptions *options; gint timeoutHandle; -- 2.2.0