[Xfce4-commits] <xfce4-indicator-plugin:master> Merge branch 'andrzejr/tmp' into xfconf

Mark Trompell noreply at xfce.org
Fri Mar 23 15:40:11 CET 2012


Updating branch refs/heads/master
         to 971f5197c0508c697803bb640104ab6cea6d9d18 (commit)
       from 517416a99f407954c6e16e50086a7904b18b1941 (commit)

commit 971f5197c0508c697803bb640104ab6cea6d9d18
Merge: 517416a 969fe20
Author: Mark Trompell <mark at foresightlinux.org>
Date:   Fri Mar 23 08:14:57 2012 +0100

    Merge branch 'andrzejr/tmp' into xfconf

commit 969fe20f8525f8940c345b9c8eeed507f686a520
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Thu Mar 22 20:57:20 2012 +0900

    Replaced "nrows-min" with "icon-size-max"
    
    This is more convenient to use in practice (icon sizes stay ~constant
    when panel size changes) and works better with panel 4.8.

commit 43120ffe21201a436401db8f093cbe614787e263
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Wed Mar 21 18:34:05 2012 +0900

    Removed unused on_label_changed
    
    We pass whole GtkLabel to the button so there is no need to listen
    to the label text changes.

commit 92aa37ef3025aeffe80679e83c662b187f00cb93
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Wed Mar 21 16:05:44 2012 +0900

    Removing some assert violations and compiler warnings.

commit 7cf3a0d89e28573cfec0f2e4fd3ba23584189b46
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Wed Mar 21 16:04:57 2012 +0900

    Added "nrows-min" property. Sets a minimum number of icon rows/columns.
    
    To be used in the gui/xconf setting later. Default value is set to 2.

commit 2b92a4b2a72ad1d2406cdf9375989723c1f63716
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Wed Mar 21 16:01:42 2012 +0900

    Added exo dependency

commit 4433eaf8b8482602e1ffbff6a55c783c5ce039be
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Wed Mar 21 14:56:06 2012 +0900

    Removed chatty debug messages

commit 47662af0e551e67be8d9f148aaf783826aa5d860
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Wed Mar 21 14:54:07 2012 +0900

    Changed version checking mechanism

commit ac510b4d7851c2b7fece06b17f048d15831c2770
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Wed Mar 21 01:49:04 2012 +0900

    Icons can now be scaled up to the row size (or panel size in 4.8).
    
    Because there is no cap on the maximum icon size, this patch changes
    the behavior of the plugin in panel 4.8. We probably need a configuration
    variable like "Max icon size" or "Min number of rows" to make the icons
    smaller again and perhaps allow multi-row layout in 4.8.

commit 733903a016ee6fea8f51c0f600de97aeb67fb8b2
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Wed Mar 21 00:50:40 2012 +0900

    Added a default icon and reworked pixbuf change notification.

 configure.in.in                 |    1 +
 panel-plugin/Makefile.am        |    4 +
 panel-plugin/indicator-box.c    |  163 +++++++++++++++++++++++++++++++++------
 panel-plugin/indicator-box.h    |    1 +
 panel-plugin/indicator-button.c |  117 +++++++++++++++++++++++-----
 panel-plugin/indicator-button.h |    4 +-
 panel-plugin/indicator.c        |   29 +++----
 7 files changed, 254 insertions(+), 65 deletions(-)

diff --git a/configure.in.in b/configure.in.in
index 8ec40e7..3280c7f 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -65,6 +65,7 @@ dnl ***********************************
 dnl *** Check for required packages ***
 dnl ***********************************
 XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.14.0])
+XDT_CHECK_PACKAGE([EXO], [exo-1], [0.6.0])
 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.3.99.2])
 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.99.2])
 XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.6.0])
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index 0c1ba0e..c07a45c 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -22,6 +22,8 @@ xfce4_indicator_plugin_SOURCES =				\
 	indicator.h									
 
 xfce4_indicator_plugin_CFLAGS =					\
+	$(GTK_CFLAGS) \
+	$(EXO_CFLAGS) \
 	$(LIBXFCE4UTIL_CFLAGS)						\
 	$(LIBXFCE4PANEL_CFLAGS)						\
 	$(XFCONF_CFLAGS)					\
@@ -33,6 +35,8 @@ xfce4_indicator_plugin_CFLAGS =					\
 
 
 xfce4_indicator_plugin_LDADD =					\
+	$(GTK_LIBS) \
+	$(EXO_LIBS) \
 	$(LIBXFCE4UTIL_LIBS)						\
 	$(LIBXFCE4PANEL_LIBS)						\
 	$(XFCONF_LIBS)						\
diff --git a/panel-plugin/indicator-box.c b/panel-plugin/indicator-box.c
index e8ccb8a..95376dd 100644
--- a/panel-plugin/indicator-box.c
+++ b/panel-plugin/indicator-box.c
@@ -17,27 +17,43 @@
 
 #include <glib.h>
 #include <gtk/gtk.h>
+#include <exo/exo.h>
 #include <libxfce4panel/libxfce4panel.h>
 #include <libindicator/indicator-object.h>
 
 #include "indicator-box.h"
 #include "indicator-button.h"
 
-static void                 xfce_indicator_box_finalize       (GObject        *object);
-static void                 xfce_indicator_box_add            (GtkContainer   *container,
-                                                               GtkWidget      *child);
-static void                 xfce_indicator_box_remove         (GtkContainer   *container,
-                                                               GtkWidget      *child);
-static void                 xfce_indicator_box_forall         (GtkContainer   *container,
-                                                               gboolean        include_internals,
-                                                               GtkCallback     callback,
-                                                               gpointer        callback_data);
-static GType                xfce_indicator_box_child_type     (GtkContainer   *container);
-static void                 xfce_indicator_box_size_request   (GtkWidget      *widget,
-                                                               GtkRequisition *requisition);
-static void                 xfce_indicator_box_size_allocate  (GtkWidget     *widget,
-                                                               GtkAllocation *allocation);
-
+static void                 xfce_indicator_box_finalize       (GObject          *object);
+static void                 xfce_indicator_box_get_property   (GObject          *object,
+                                                               guint             prop_id,
+                                                               GValue           *value,
+                                                               GParamSpec       *pspec);
+static void                 xfce_indicator_box_set_property   (GObject          *object,
+                                                               guint             prop_id,
+                                                               const GValue     *value,
+                                                               GParamSpec       *pspec);
+static void                 xfce_indicator_box_add            (GtkContainer     *container,
+                                                               GtkWidget        *child);
+static void                 xfce_indicator_box_remove         (GtkContainer     *container,
+                                                               GtkWidget        *child);
+static void                 xfce_indicator_box_forall         (GtkContainer     *container,
+                                                               gboolean          include_internals,
+                                                               GtkCallback       callback,
+                                                               gpointer          callback_data);
+static GType                xfce_indicator_box_child_type     (GtkContainer     *container);
+static void                 xfce_indicator_box_size_request   (GtkWidget        *widget,
+                                                               GtkRequisition   *requisition);
+static void                 xfce_indicator_box_size_allocate  (GtkWidget        *widget,
+                                                               GtkAllocation    *allocation);
+static gint                 xfce_indicator_box_get_row_size   (XfceIndicatorBox *box);
+
+
+enum
+{
+  PROP_0,
+  PROP_ICON_SIZE_MAX
+};
 
 G_DEFINE_TYPE (XfceIndicatorBox, xfce_indicator_box, GTK_TYPE_CONTAINER)
 
@@ -50,6 +66,8 @@ xfce_indicator_box_class_init (XfceIndicatorBoxClass *klass)
 
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = xfce_indicator_box_finalize;
+  gobject_class->get_property = xfce_indicator_box_get_property;
+  gobject_class->set_property = xfce_indicator_box_set_property;
 
   gtkwidget_class = GTK_WIDGET_CLASS (klass);
   gtkwidget_class->size_request = xfce_indicator_box_size_request;
@@ -60,6 +78,15 @@ xfce_indicator_box_class_init (XfceIndicatorBoxClass *klass)
   gtkcontainer_class->remove = xfce_indicator_box_remove;
   gtkcontainer_class->forall = xfce_indicator_box_forall;
   gtkcontainer_class->child_type = xfce_indicator_box_child_type;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ICON_SIZE_MAX,
+                                   g_param_spec_uint ("icon-size-max",
+                                                      NULL, NULL,
+                                                      1,
+                                                      128,
+                                                      24,
+                                                      EXO_PARAM_READWRITE));
 }
 
 
@@ -75,6 +102,7 @@ xfce_indicator_box_init (XfceIndicatorBox *box)
   box->children = NULL;
 
   box->nrows = 1;
+  box->icon_size_max = 24;
   box->panel_size = 16;
   box->panel_orientation = GTK_ORIENTATION_HORIZONTAL;
   box->orientation = GTK_ORIENTATION_HORIZONTAL;
@@ -98,6 +126,67 @@ xfce_indicator_box_finalize (GObject *object)
 
 
 
+static void
+xfce_indicator_box_get_property (GObject    *object,
+                                 guint       prop_id,
+                                 GValue     *value,
+                                 GParamSpec *pspec)
+{
+  XfceIndicatorBox *box = XFCE_INDICATOR_BOX (object);
+  GPtrArray        *array;
+
+  switch (prop_id)
+    {
+    case PROP_ICON_SIZE_MAX:
+      g_value_set_uint (value, box->icon_size_max);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+
+static void
+xfce_indicator_box_set_property (GObject      *object,
+                                 guint         prop_id,
+                                 const GValue *value,
+                                 GParamSpec   *pspec)
+{
+  XfceIndicatorBox     *box = XFCE_INDICATOR_BOX (object);
+  gint                  val;
+  gint                  size;
+  XfceIndicatorButton  *child;
+  GSList               *li;
+
+  switch (prop_id)
+    {
+    case PROP_ICON_SIZE_MAX:
+      val = g_value_get_uint (value);
+      if (box->icon_size_max != val)
+        {
+          box->icon_size_max = val;
+          size = xfce_indicator_box_get_row_size (box);
+          for (li = box->children; li != NULL; li = li->next)
+            {
+              child = XFCE_INDICATOR_BUTTON (li->data);
+              g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (child));
+              xfce_indicator_button_set_size (child, box->panel_size, size);
+            }
+          gtk_widget_queue_resize (GTK_WIDGET (box));
+        }
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+
 void
 xfce_indicator_box_set_orientation (XfceIndicatorBox *box,
                                     GtkOrientation    panel_orientation,
@@ -143,6 +232,7 @@ xfce_indicator_box_set_size (XfceIndicatorBox *box,
   gboolean              needs_update = FALSE;
   XfceIndicatorButton  *child;
   GSList               *li;
+  gint                  size;
 
   g_return_if_fail (XFCE_IS_INDICATOR_BOX (box));
 
@@ -160,11 +250,12 @@ xfce_indicator_box_set_size (XfceIndicatorBox *box,
 
   if (needs_update)
     {
+      size = xfce_indicator_box_get_row_size (box);
       for (li = box->children; li != NULL; li = li->next)
         {
           child = XFCE_INDICATOR_BUTTON (li->data);
           g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (child));
-          xfce_indicator_button_set_size (child, panel_size, panel_size / nrows);
+          xfce_indicator_button_set_size (child, panel_size, size);
         }
       gtk_widget_queue_resize (GTK_WIDGET (box));
     }
@@ -187,6 +278,7 @@ xfce_indicator_box_add (GtkContainer *container,
 {
   XfceIndicatorBox    *box = XFCE_INDICATOR_BOX (container);
   XfceIndicatorButton *button = XFCE_INDICATOR_BUTTON (child);
+  gint                 size;
 
   g_return_if_fail (XFCE_IS_INDICATOR_BOX (box));
   g_return_if_fail (GTK_IS_WIDGET (child));
@@ -196,7 +288,8 @@ xfce_indicator_box_add (GtkContainer *container,
 
   gtk_widget_set_parent (child, GTK_WIDGET (box));
   xfce_indicator_button_set_orientation (button, box->panel_orientation, box->orientation);
-  xfce_indicator_button_set_size (button, box->panel_size, box->panel_size / box->nrows);
+  size = xfce_indicator_box_get_row_size (box);
+  xfce_indicator_button_set_size (button, box->panel_size, size);
 
   gtk_widget_queue_resize (GTK_WIDGET (container));
 }
@@ -265,6 +358,7 @@ xfce_indicator_box_size_request (GtkWidget      *widget,
   gint              panel_size;
   gint              length;
   gint              row;
+  gint              nrows;
   gint              x;
   gboolean          has_label;
 
@@ -272,6 +366,9 @@ xfce_indicator_box_size_request (GtkWidget      *widget,
   row = 0;
   length = 0;
   x = 0;
+  //nrows = MAX (box->nrows,
+  //             box->panel_size / xfce_indicator_box_get_row_size (box));
+  nrows = box->panel_size / xfce_indicator_box_get_row_size (box);
 
   for (li = box->children; li != NULL; li = li->next)
     {
@@ -282,7 +379,7 @@ xfce_indicator_box_size_request (GtkWidget      *widget,
       has_label = (xfce_indicator_button_get_label (XFCE_INDICATOR_BUTTON (child)) != NULL);
 
       /* wrap rows if column is overflowing or a label is encountered */
-      if (row > 0 && (has_label || row >= box->nrows))
+      if (row > 0 && (has_label || row >= nrows))
         {
           x += length;
           row = 0;
@@ -292,7 +389,7 @@ xfce_indicator_box_size_request (GtkWidget      *widget,
       length =
         MAX (length, (box->panel_orientation == GTK_ORIENTATION_HORIZONTAL) ? child_req.width :child_req.height);
 
-      if (has_label || row >= box->nrows)
+      if (has_label || row >= nrows)
         {
           x += length;
           row = 0;
@@ -316,7 +413,7 @@ xfce_indicator_box_size_request (GtkWidget      *widget,
       requisition->width = panel_size;
       requisition->height = x;
     }
-  g_debug ("indicator-box size request: w=%d h=%d", requisition->width, requisition->height);
+  /* g_debug ("indicator-box size request: w=%d h=%d", requisition->width, requisition->height); */
 }
 
 
@@ -335,6 +432,7 @@ xfce_indicator_box_size_allocate (GtkWidget     *widget,
   GSList           *li;
   gint              length, width;
   gint              row;
+  gint              nrows;
   gboolean          has_label;
 
   row = 0;
@@ -344,8 +442,10 @@ xfce_indicator_box_size_allocate (GtkWidget     *widget,
   x0 = allocation->x;
   y0 = allocation->y;
 
+  //nrows = MAX (box->nrows, box->panel_size / box->icon_size_max);
+  nrows = box->panel_size / xfce_indicator_box_get_row_size (box);
   panel_size = box->panel_size;
-  size = panel_size / box->nrows;
+  size = panel_size / nrows;
 
   for (li = box->children; li != NULL; li = li->next)
     {
@@ -357,7 +457,7 @@ xfce_indicator_box_size_allocate (GtkWidget     *widget,
       has_label = (xfce_indicator_button_get_label (XFCE_INDICATOR_BUTTON (child)) != NULL);
 
       /* wrap rows if column is overflowing or a label is encountered */
-      if (row > 0 && (has_label || row >= box->nrows))
+      if (row > 0 && (has_label || row >= nrows))
         {
           x += length;
           y = 0;
@@ -384,12 +484,12 @@ xfce_indicator_box_size_allocate (GtkWidget     *widget,
           child_alloc.height = length;
         }
 
-      g_debug ("indicator-box size allocate: x=%d y=%d w=%d h=%d",
-               child_alloc.x, child_alloc.y, child_alloc.width, child_alloc.height);
+      /* g_debug ("indicator-box size allocate: x=%d y=%d w=%d h=%d", */
+      /*          child_alloc.x, child_alloc.y, child_alloc.width, child_alloc.height); */
 
       gtk_widget_size_allocate (child, &child_alloc);
 
-      if (has_label || row >= box->nrows)
+      if (has_label || row >= nrows)
         {
           x += length;
           y = 0;
@@ -406,3 +506,16 @@ xfce_indicator_box_size_allocate (GtkWidget     *widget,
 
 
 
+static gint
+xfce_indicator_box_get_row_size (XfceIndicatorBox *box)
+{
+  gint                 border_thickness;
+  GtkStyle            *style;
+
+  g_return_val_if_fail (XFCE_IS_INDICATOR_BOX (box), 24);
+
+  style = gtk_widget_get_style (GTK_WIDGET (box));
+  border_thickness = 2 * MAX (style->xthickness, style->ythickness) + 2;
+
+  return MIN (box->panel_size / box->nrows, box->icon_size_max + border_thickness);
+}
diff --git a/panel-plugin/indicator-box.h b/panel-plugin/indicator-box.h
index fafaa37..b28c9d2 100644
--- a/panel-plugin/indicator-box.h
+++ b/panel-plugin/indicator-box.h
@@ -40,6 +40,7 @@ struct _XfceIndicatorBox
 
   gint                  panel_size;
   gint                  nrows;
+  gint                  icon_size_max;
 
   GtkOrientation        panel_orientation;
   GtkOrientation        orientation;
diff --git a/panel-plugin/indicator-button.c b/panel-plugin/indicator-button.c
index e9a416e..9763da5 100644
--- a/panel-plugin/indicator-button.c
+++ b/panel-plugin/indicator-button.c
@@ -54,11 +54,13 @@ xfce_indicator_button_init (XfceIndicatorButton *button)
   button->menu = NULL;
 
   button->label = NULL;
+  button->orig_icon = NULL;
   button->icon = NULL;
+  button->orig_icon_handler = 0;
 
   button->size = 0;
   button->panel_size = 0;
-  button->orig_icon_size = 0;
+  button->icon_size = 24;
   button->panel_orientation = GTK_ORIENTATION_HORIZONTAL;
   button->orientation = GTK_ORIENTATION_HORIZONTAL;
 
@@ -85,6 +87,11 @@ xfce_indicator_button_finalize (GObject *object)
       g_object_unref (G_OBJECT (button->label));
       button->label = NULL;
     }
+  if (button->orig_icon != NULL)
+    {
+      g_object_unref (G_OBJECT (button->orig_icon));
+      button->orig_icon = NULL;
+    }
   if (button->icon != NULL)
     {
       g_object_unref (G_OBJECT (button->icon));
@@ -115,18 +122,11 @@ static void
 xfce_indicator_button_update_layout (XfceIndicatorButton *button)
 {
   GtkRequisition          label_size;
-  gint                    border_thickness;
-  GtkStyle               *style;
-  gint                    icon_size;
 
   g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button));
 
   if (button->icon != NULL && button->size != 0)
     {
-      style = gtk_widget_get_style (GTK_WIDGET (button));
-      border_thickness = 2 * MAX (style->xthickness, style->ythickness) + 2;
-      icon_size = MIN (button->size - border_thickness, button->orig_icon_size);
-
       if (button->label != NULL &&
           button->panel_orientation == GTK_ORIENTATION_VERTICAL &&
           button->orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -136,14 +136,62 @@ xfce_indicator_button_update_layout (XfceIndicatorButton *button)
           /* put icon above the label if number of rows > 1 (they look better)
              or if they don't fit when arranged horizontally */
           if (button->panel_size != button->size ||
-              label_size.width > button->panel_size - icon_size - border_thickness)
+              label_size.width > button->panel_size - button->size)
             gtk_orientable_set_orientation (GTK_ORIENTABLE (button->box), GTK_ORIENTATION_VERTICAL);
           else
             gtk_orientable_set_orientation (GTK_ORIENTABLE (button->box), GTK_ORIENTATION_HORIZONTAL);
         }
 
-      xfce_panel_image_set_size (XFCE_PANEL_IMAGE (button->icon), icon_size);
+      xfce_panel_image_set_size (XFCE_PANEL_IMAGE (button->icon), button->icon_size);
+    }
+}
+
+
+
+static void
+xfce_indicator_button_update_icon (XfceIndicatorButton *button)
+{
+  GdkPixbuf    *pixbuf_s, *pixbuf_d;
+  gdouble       aspect;
+  gint          size;
+
+  g_return_if_fail (GTK_IS_IMAGE (button->orig_icon));
+  g_return_if_fail (XFCE_IS_PANEL_IMAGE (button->icon));
+
+  size = button->icon_size;
+
+  /* Copied from xfce_panel_image.c, try to snap to icon sizes, which minimize smoothing */
+#if 0
+  if (size > 16 && size < 22)
+    size = 16;
+  else if (size > 22 && size < 24)
+    size = 22;
+  else if (size > 24 && size < 32)
+    size = 24;
+#endif
+
+  pixbuf_s = gtk_image_get_pixbuf (GTK_IMAGE (button->orig_icon));
+
+  if (pixbuf_s != NULL)
+    {
+      aspect = (gdouble) gdk_pixbuf_get_width (pixbuf_s) /
+        (gdouble) gdk_pixbuf_get_height (pixbuf_s);
+      if (aspect > 1.0)
+        pixbuf_d = gdk_pixbuf_scale_simple
+          (pixbuf_s, size, (gint) (size / aspect),
+           GDK_INTERP_BILINEAR);
+      else
+        pixbuf_d = gdk_pixbuf_scale_simple
+          (pixbuf_s, (gint) (size * aspect), size,
+           GDK_INTERP_BILINEAR);
+      xfce_panel_image_set_from_pixbuf (XFCE_PANEL_IMAGE (button->icon), pixbuf_d);
+    }
+  else
+    {
+      xfce_panel_image_set_from_source (XFCE_PANEL_IMAGE (button->icon), "image-missing");
     }
+
+  xfce_panel_image_set_size (XFCE_PANEL_IMAGE (button->icon), button->icon_size);
 }
 
 
@@ -180,11 +228,9 @@ on_pixbuf_changed (GtkImage *image, GParamSpec *pspec, XfceIndicatorButton *butt
 
   g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button));
   g_return_if_fail (GTK_IS_IMAGE (image));
+  g_return_if_fail (XFCE_IS_PANEL_IMAGE (button->icon));
 
-  pixbuf = gtk_image_get_pixbuf (image);
-  button->orig_icon_size = gdk_pixbuf_get_width (pixbuf);
-
-  xfce_panel_image_set_from_pixbuf (button->icon, pixbuf);
+  xfce_indicator_button_update_icon (button);
 }
 
 
@@ -198,24 +244,38 @@ xfce_indicator_button_set_image (XfceIndicatorButton *button,
   g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button));
   g_return_if_fail (GTK_IS_IMAGE (image));
 
-  if (button->icon != GTK_WIDGET (image))
+  g_debug ("indicator-button set image, image=%x\n", (uint) image);
+
+  if (button->orig_icon != GTK_WIDGET (image))
     {
+      if (button->orig_icon != NULL)
+        {
+          g_signal_handler_disconnect
+            (G_OBJECT (button->orig_icon), button->orig_icon_handler);
+          g_object_unref (G_OBJECT (button->orig_icon));
+        }
+
       if (button->icon != NULL)
         {
           gtk_container_remove (GTK_CONTAINER (button->box), button->icon);
           g_object_unref (G_OBJECT (button->icon));
         }
 
-      pixbuf = gtk_image_get_pixbuf (image);
-      g_signal_connect(G_OBJECT(image), "notify::pixbuf", G_CALLBACK(on_pixbuf_changed), button);
-      button->orig_icon_size = gdk_pixbuf_get_width (pixbuf);
+      button->orig_icon = GTK_WIDGET (image);
+      g_object_ref (G_OBJECT (button->orig_icon));
+
+      button->orig_icon_handler = g_signal_connect
+        (G_OBJECT (image), "notify::pixbuf", G_CALLBACK (on_pixbuf_changed), button);
 
-      button->icon = xfce_panel_image_new_from_pixbuf (pixbuf);
+
+      button->icon = xfce_panel_image_new ();
+      xfce_indicator_button_update_icon (button);
 
       gtk_box_pack_start (GTK_BOX (button->box), button->icon, TRUE, FALSE, 1);
       gtk_widget_show (button->icon);
+
+      xfce_indicator_button_update_layout (button);
     }
-  xfce_indicator_button_update_layout (button);
 }
 
 
@@ -254,7 +314,7 @@ xfce_indicator_button_get_image (XfceIndicatorButton *button)
 {
   g_return_val_if_fail (XFCE_IS_INDICATOR_BUTTON (button), NULL);
 
-  return button->icon;
+  return button->orig_icon;
 }
 
 
@@ -329,6 +389,9 @@ xfce_indicator_button_set_size (XfceIndicatorButton *button,
                                 gint                 size)
 {
   gboolean    needs_update = FALSE;
+  gint        border_thickness;
+  GtkStyle   *style;
+  gdouble     aspect;
 
   g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button));
 
@@ -345,7 +408,17 @@ xfce_indicator_button_set_size (XfceIndicatorButton *button,
     }
 
   if (needs_update)
-    xfce_indicator_button_update_layout (button);
+    {
+      style = gtk_widget_get_style (GTK_WIDGET (button));
+      border_thickness = 2 * MAX (style->xthickness, style->ythickness) + 2;
+      button->icon_size = button->size - border_thickness;
+
+      if (button->orig_icon != NULL)
+        {
+          xfce_indicator_button_update_icon (button);
+          xfce_indicator_button_update_layout (button);
+        }
+    }
 }
 
 
diff --git a/panel-plugin/indicator-button.h b/panel-plugin/indicator-button.h
index 22a2e31..80e93fb 100644
--- a/panel-plugin/indicator-button.h
+++ b/panel-plugin/indicator-button.h
@@ -43,10 +43,12 @@ struct _XfceIndicatorButton
   GtkWidget            *box;
   GtkWidget            *label;
   GtkWidget            *icon;
+  GtkWidget            *orig_icon;
+  gulong                orig_icon_handler;
 
   gint                  panel_size;
   gint                  size;
-  gint                  orig_icon_size;
+  gint                  icon_size;
 
   GtkOrientation        panel_orientation;
   GtkOrientation        orientation;
diff --git a/panel-plugin/indicator.c b/panel-plugin/indicator.c
index fff5319..81f4149 100644
--- a/panel-plugin/indicator.c
+++ b/panel-plugin/indicator.c
@@ -34,6 +34,12 @@
 
 #define DEFAULT_EXCLUDED_MODULES NULL
 
+#ifdef LIBXFCE4PANEL_CHECK_VERSION
+#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0)
+#define HAS_PANEL_49
+#endif
+#endif
+
 /* prototypes */
 static void
 indicator_construct (XfcePanelPlugin *plugin);
@@ -44,7 +50,7 @@ load_module (const gchar * name, IndicatorPlugin * indicator);
 static gboolean
 indicator_size_changed (XfcePanelPlugin *plugin, gint size, IndicatorPlugin *indicator);
 
-#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0)
+#ifdef HAS_PANEL_49
 static void
 indicator_mode_changed (XfcePanelPlugin *plugin, XfcePanelPluginMode mode, IndicatorPlugin *indicator);
 #else
@@ -200,7 +206,7 @@ indicator_free (XfcePanelPlugin *plugin,
 
 
 
-#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0)
+#ifdef HAS_PANEL_49
 static void
 indicator_mode_changed (XfcePanelPlugin     *plugin,
                         XfcePanelPluginMode  mode,
@@ -237,7 +243,7 @@ indicator_size_changed (XfcePanelPlugin *plugin,
                      gint             size,
                      IndicatorPlugin    *indicator)
 {
-#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0)
+#ifdef HAS_PANEL_49
   xfce_indicator_box_set_size (XFCE_INDICATOR_BOX (indicator->buttonbox),
                                size, xfce_panel_plugin_get_nrows (plugin));
 #else
@@ -278,15 +284,6 @@ menu_deactivate (GtkMenu *menu,
 }
 
 static void
-on_label_changed (GtkLabel *label, GParamSpec *pspec, XfceIndicatorButton *button)
-{
-  g_return_if_fail (GTK_IS_LABEL (label));
-  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button));
-
-  xfce_indicator_button_set_label (button, label);
-}
-
-static void
 indicator_construct (XfcePanelPlugin *plugin)
 {
   IndicatorPlugin *indicator;
@@ -304,7 +301,7 @@ indicator_construct (XfcePanelPlugin *plugin)
   g_signal_connect (G_OBJECT (plugin), "size-changed",
                     G_CALLBACK (indicator_size_changed), indicator);
 
-#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0)
+#ifdef HAS_PANEL_49
   g_signal_connect (G_OBJECT (plugin), "mode-changed",
                     G_CALLBACK (indicator_mode_changed), indicator);
 #else
@@ -341,10 +338,8 @@ entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_d
   if (entry->image != NULL)
     xfce_indicator_button_set_image(XFCE_INDICATOR_BUTTON(button), entry->image);
 
-  if (entry->label != NULL) {
+  if (entry->label != NULL)
     xfce_indicator_button_set_label(XFCE_INDICATOR_BUTTON(button), entry->label);
-    g_signal_connect(G_OBJECT(entry->label), "notify::label", G_CALLBACK(on_label_changed), button);
-  }
 
   if (entry->menu != NULL)
   {
@@ -357,7 +352,7 @@ entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_d
   g_signal_connect(button, "scroll-event", G_CALLBACK(entry_scrolled),
                    user_data);
 
-  gtk_container_add(XFCE_INDICATOR_BOX (((IndicatorPlugin *)user_data)->buttonbox), button);
+  gtk_container_add(GTK_CONTAINER (((IndicatorPlugin *)user_data)->buttonbox), button);
   gtk_widget_show(button);
 }
 


More information about the Xfce4-commits mailing list