[Xfce4-commits] [panel-plugins/xfce4-cpufreq-plugin] 01/03: Fix panel resizing caused by freq format function (bug #10385).

noreply at xfce.org noreply at xfce.org
Mon Dec 22 18:51:18 CET 2014


This is an automated email from the git hooks/post-receive script.

hjudt pushed a commit to branch master
in repository panel-plugins/xfce4-cpufreq-plugin.

commit 5677fa969032ae8e6eae26ea69d4c36a39db385e
Author: Harald Judt <h.judt at gmx.at>
Date:   Fri Dec 19 20:00:34 2014 +0100

    Fix panel resizing caused by freq format function (bug #10385).
---
 panel-plugin/xfce4-cpufreq-plugin.c |   24 ++++++++++++++++++++++++
 panel-plugin/xfce4-cpufreq-plugin.h |    1 +
 2 files changed, 25 insertions(+)

diff --git a/panel-plugin/xfce4-cpufreq-plugin.c b/panel-plugin/xfce4-cpufreq-plugin.c
index 322ddd0..7c3e59f 100644
--- a/panel-plugin/xfce4-cpufreq-plugin.c
+++ b/panel-plugin/xfce4-cpufreq-plugin.c
@@ -116,6 +116,7 @@ cpufreq_label_set_font (void)
 gboolean
 cpufreq_update_label (CpuInfo *cpu)
 {
+	GtkRequisition label_size;
 	gchar *label, *freq;
 	gint both;
 
@@ -147,6 +148,22 @@ cpufreq_update_label (CpuInfo *cpu)
 		else
 			gtk_label_set_angle (GTK_LABEL(cpuFreq->label), 0);
 		gtk_widget_show (cpuFreq->label);
+
+		/* Set label width to max width if smaller to avoid panel
+		   resizing/jumping (see bug #10385). */
+		gtk_widget_size_request (cpuFreq->label, &label_size);
+		if (cpuFreq->panel_mode == XFCE_PANEL_PLUGIN_MODE_VERTICAL)
+			if (label_size.height < cpuFreq->label_max_width)
+				gtk_widget_set_size_request (GTK_WIDGET (cpuFreq->label),
+											 -1, cpuFreq->label_max_width);
+			else
+				cpuFreq->label_max_width = label_size.height;
+		else
+			if (label_size.width < cpuFreq->label_max_width)
+				gtk_widget_set_size_request (GTK_WIDGET (cpuFreq->label),
+											 cpuFreq->label_max_width, -1);
+			else
+				cpuFreq->label_max_width = label_size.width;
 	}
 	else
 	{
@@ -169,6 +186,10 @@ cpufreq_widgets_layout (void)
 						   !cpuFreq->options->show_label_governor);
 	gint pos = 1, lw = 0, lh = 0, iw = 0, ih = 0;
 
+	/* reset label max width on layout changes */
+	cpuFreq->label_max_width = -1;
+	gtk_widget_set_size_request (GTK_WIDGET (cpuFreq->label), -1, -1);
+
 	small = (hide_label ? TRUE : cpuFreq->options->keep_compact);
 
 	switch (cpuFreq->panel_mode) {
@@ -201,6 +222,7 @@ cpufreq_widgets_layout (void)
 		iw = icon_size.width;
 		ih = icon_size.height;
 	}
+
 	if (cpuFreq->panel_mode == XFCE_PANEL_PLUGIN_MODE_HORIZONTAL &&
 		orientation == GTK_ORIENTATION_VERTICAL &&
 		lh + ih + BORDER * 2 >= cpuFreq->panel_size) {
@@ -551,6 +573,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 +619,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;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list