Updating branch refs/heads/master
         to 8e98219a76463e3634a75214d70c857c8ac5cb85 (commit)
       from 67898aabce1f010381460dc905bd9bcf11e5d04d (commit)

commit 8e98219a76463e3634a75214d70c857c8ac5cb85
Author: Harald Judt <[email protected]>
Date:   Tue Aug 20 19:25:42 2013 +0200

    Properly handle icon size in icon update function.

 panel-plugin/xfce4-cpufreq-configure.c |    4 ----
 panel-plugin/xfce4-cpufreq-plugin.c    |   34 +++++++++++++++++++++-----------
 2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/panel-plugin/xfce4-cpufreq-configure.c 
b/panel-plugin/xfce4-cpufreq-configure.c
index bfff760..6b9924c 100644
--- a/panel-plugin/xfce4-cpufreq-configure.c
+++ b/panel-plugin/xfce4-cpufreq-configure.c
@@ -54,10 +54,6 @@ check_button_changed (GtkWidget *button, 
CpuFreqPluginConfigure *configure)
        else if (button == configure->keep_compact) {
                cpuFreq->options->keep_compact =
                        gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(button));
-               if (cpuFreq->options->keep_compact)
-                       cpuFreq->icon_size -= 4;
-               else
-                       cpuFreq->icon_size += 4;
                cpufreq_update_icon (cpuFreq);
        }
 
diff --git a/panel-plugin/xfce4-cpufreq-plugin.c 
b/panel-plugin/xfce4-cpufreq-plugin.c
index 61cc106..5a3836c 100644
--- a/panel-plugin/xfce4-cpufreq-plugin.c
+++ b/panel-plugin/xfce4-cpufreq-plugin.c
@@ -360,24 +360,34 @@ cpufreq_mode_changed (XfcePanelPlugin *plugin, 
XfcePanelPluginMode mode, CpuFreq
 void
 cpufreq_update_icon (CpuFreqPlugin *cpufreq)
 {
-       if (cpufreq->icon)
-       {
+       if (cpufreq->icon) {
                gtk_widget_destroy (cpufreq->icon);
                cpufreq->icon = NULL;
        }
 
-       if(cpufreq->options->show_icon)
-       {
-               GdkPixbuf *buf = gtk_icon_theme_load_icon 
(gtk_icon_theme_get_default (),
-                                                                    
"xfce4-cpufreq-plugin", cpufreq->icon_size, 0, NULL);
-               if (buf)
-               {
+       if (cpufreq->options->show_icon) {
+               GdkPixbuf *buf;
+               guint nrows;
+               gint panel_size;
+
+               panel_size = xfce_panel_plugin_get_size (cpufreq->plugin);
+               nrows = xfce_panel_plugin_get_nrows (cpuFreq->plugin);
+
+               cpufreq->icon_size = panel_size / nrows;
+               if (cpufreq->options->keep_compact ||
+                       (!cpufreq->options->show_label_freq &&
+                        !cpufreq->options->show_label_governor))
+                       cpufreq->icon_size -= 4;
+
+               buf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                                                               
"xfce4-cpufreq-plugin",
+                                                                               
cpufreq->icon_size, 0, NULL);
+               if (buf) {
                        cpufreq->icon = gtk_image_new_from_pixbuf (buf);
                        g_object_unref (G_OBJECT (buf));
-               }
-               else
-               {
-                       cpufreq->icon = gtk_image_new_from_icon_name 
("xfce4-cpufreq-plugin", GTK_ICON_SIZE_BUTTON);
+               } else {
+                       cpufreq->icon = gtk_image_new_from_icon_name
+                               ("xfce4-cpufreq-plugin", GTK_ICON_SIZE_BUTTON);
                }
                gtk_box_pack_start (GTK_BOX (cpufreq->box), cpufreq->icon, 
FALSE, FALSE, 0);
                gtk_widget_show (cpufreq->icon);
_______________________________________________
Xfce4-commits mailing list
[email protected]
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to