[Xfce4-commits] <xfce4-cpufreq-plugin:master> Update layout only if necessary.
Harald Judt
noreply at xfce.org
Sun Aug 18 11:32:21 CEST 2013
Updating branch refs/heads/master
to e01d15daa5e1eefab75810ea53111f70242485d0 (commit)
from 73ca04dd894bbbda394fbae2f1fee2bca70047f6 (commit)
commit e01d15daa5e1eefab75810ea53111f70242485d0
Author: Harald Judt <h.judt at gmx.at>
Date: Mon Aug 12 15:40:34 2013 +0200
Update layout only if necessary.
It is a bit costly and unnecessary to do this every update.
panel-plugin/xfce4-cpufreq-configure.c | 1 +
panel-plugin/xfce4-cpufreq-plugin.c | 8 +++++++-
panel-plugin/xfce4-cpufreq-plugin.h | 1 +
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/panel-plugin/xfce4-cpufreq-configure.c b/panel-plugin/xfce4-cpufreq-configure.c
index f51ec57..6176127 100644
--- a/panel-plugin/xfce4-cpufreq-configure.c
+++ b/panel-plugin/xfce4-cpufreq-configure.c
@@ -59,6 +59,7 @@ check_button_changed (GtkWidget *button, CpuFreqPluginConfigure *configure)
else
cpuFreq->icon_size += 4;
cpufreq_update_icon (cpuFreq);
+ cpuFreq->layout_changed = TRUE;
}
cpufreq_prepare_label (cpuFreq);
diff --git a/panel-plugin/xfce4-cpufreq-plugin.c b/panel-plugin/xfce4-cpufreq-plugin.c
index 3607719..ddc9eff 100644
--- a/panel-plugin/xfce4-cpufreq-plugin.c
+++ b/panel-plugin/xfce4-cpufreq-plugin.c
@@ -175,6 +175,8 @@ cpufreq_widgets_layout (void)
TRUE, TRUE, 0, GTK_PACK_START);
}
gtk_box_reorder_child (GTK_BOX (cpuFreq->box), cpuFreq->label, pos);
+
+ cpuFreq->layout_changed = FALSE;
}
gboolean
@@ -184,7 +186,8 @@ cpufreq_update_plugin (void)
g_return_val_if_fail (cpuFreq->options->show_cpu < cpuFreq->cpus->len, FALSE);
- cpufreq_widgets_layout ();
+ if (cpuFreq->layout_changed)
+ cpufreq_widgets_layout ();
cpu = g_ptr_array_index (cpuFreq->cpus, cpuFreq->options->show_cpu);
if (cpufreq_update_label (cpu) == FALSE)
@@ -209,6 +212,7 @@ static void
cpufreq_mode_changed (XfcePanelPlugin *plugin, XfcePanelPluginMode mode, CpuFreqPlugin *cpufreq)
{
cpuFreq->panel_mode = mode;
+ cpuFreq->layout_changed = TRUE;
cpufreq_update_plugin ();
}
@@ -384,6 +388,7 @@ cpufreq_set_size (XfcePanelPlugin *plugin, gint size, CpuFreqPlugin *cpufreq)
{
cpuFreq->icon_size = size / xfce_panel_plugin_get_nrows (cpuFreq->plugin);
+ cpuFreq->layout_changed = TRUE;
cpufreq_update_icon (cpufreq);
cpufreq_update_plugin ();
@@ -401,6 +406,7 @@ cpufreq_construct (XfcePanelPlugin *plugin)
cpuFreq->cpus = g_ptr_array_new ();
cpufreq_read_config ();
+ cpuFreq->layout_changed = TRUE;
#ifdef __linux__
if (cpufreq_linux_init () == FALSE)
diff --git a/panel-plugin/xfce4-cpufreq-plugin.h b/panel-plugin/xfce4-cpufreq-plugin.h
index 0f2d313..89fc977 100644
--- a/panel-plugin/xfce4-cpufreq-plugin.h
+++ b/panel-plugin/xfce4-cpufreq-plugin.h
@@ -67,6 +67,7 @@ typedef struct
/* Widgets */
GtkWidget *button, *box, *icon, *label;
+ gboolean layout_changed;
gint icon_size;
More information about the Xfce4-commits
mailing list