[Xfce4-commits] <xfce4-indicator-plugin:master> Reworked button layout mechanism.

Andrzej noreply at xfce.org
Fri Aug 30 02:36:01 CEST 2013


Updating branch refs/heads/master
         to 56a2a08d2c30713e8fcbc83d46a01f4d2aa6884b (commit)
       from 5455baee861dbf23c57c220381d0791feca7fe5c (commit)

commit 56a2a08d2c30713e8fcbc83d46a01f4d2aa6884b
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Fri Aug 30 01:34:40 2013 +0100

    Reworked button layout mechanism.

 panel-plugin/Makefile.am            |    2 +
 panel-plugin/indicator-box.c        |   86 +++--
 panel-plugin/indicator-button-box.c |  586 +++++++++++++++++++++++++++++++++++
 panel-plugin/indicator-button-box.h |   55 ++++
 panel-plugin/indicator-button.c     |  396 ++---------------------
 panel-plugin/indicator-button.h     |    8 +-
 6 files changed, 742 insertions(+), 391 deletions(-)

diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index 919a6dd..f2d4f23 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -21,6 +21,8 @@ libindicator_plugin_la_SOURCES = \
 	$(libindicator_built_sources) \
 	indicator-config.c									\
 	indicator-config.h									\
+	indicator-button-box.c									\
+	indicator-button-box.h									\
 	indicator-button.c									\
 	indicator-button.h									\
 	indicator-box.c									\
diff --git a/panel-plugin/indicator-box.c b/panel-plugin/indicator-box.c
index 92e53ad..bba6dd9 100644
--- a/panel-plugin/indicator-box.c
+++ b/panel-plugin/indicator-box.c
@@ -33,6 +33,8 @@
 #include "indicator-box.h"
 #include "indicator-button.h"
 
+#define ICON_SIZE 22
+
 static void                 xfce_indicator_box_finalize             (GObject          *object);
 static void                 xfce_indicator_box_list_changed         (XfceIndicatorBox *box,
                                                                      IndicatorConfig  *config);
@@ -324,25 +326,44 @@ xfce_indicator_box_get_preferred_length (GtkWidget *widget,
   XfceIndicatorButton *button;
   GtkRequisition       child_req;
   GList               *known_indicators, *li, *li_int, *li_tmp;
-  gint                 panel_size;
+  gint                 panel_size, size;
   gint                 length;
   gint                 row;
   gint                 nrows;
   gint                 x;
-  gboolean             has_label, rectangular_icon;
+  gboolean             is_small;
   GtkOrientation       panel_orientation;
-
+  GtkStyleContext     *ctx;
+  GtkBorder            padding, border;
+  gint                 border_thickness;
+
+  /* check border thickness of the first button */
+  li = gtk_container_get_children (GTK_CONTAINER (box));
+  if (li == NULL)
+    return;
+
+  button = XFCE_INDICATOR_BUTTON (li->data);
+  ctx = gtk_widget_get_style_context (GTK_WIDGET (button));
+  gtk_style_context_get_padding (ctx, gtk_widget_get_state_flags (GTK_WIDGET (button)), &padding);
+  gtk_style_context_get_border (ctx, gtk_widget_get_state_flags (GTK_WIDGET (button)), &border);
+  border_thickness = MAX (padding.left+padding.right+border.left+border.right,
+                          padding.top+padding.bottom+border.top+border.bottom);
+
+  size = ICON_SIZE + border_thickness;
   panel_size = indicator_config_get_panel_size (box->config);
+  nrows = MAX (1, panel_size / size);
+
   panel_orientation = indicator_config_get_panel_orientation (box->config);
+
   row = 0;
   length = 0;
   x = 0;
-  nrows = panel_size / xfce_indicator_box_get_row_size (box);
 
   if (g_hash_table_lookup (box->children, "<placeholder>") != NULL)
     known_indicators = g_list_append (NULL, "<placeholder>");
   else
     known_indicators = indicator_config_get_known_indicators (box->config);
+
   for (li = known_indicators; li != NULL; li = li->next)
     {
       li_int = g_hash_table_lookup (box->children, li->data);
@@ -351,11 +372,11 @@ xfce_indicator_box_get_preferred_length (GtkWidget *widget,
           button = XFCE_INDICATOR_BUTTON (li_tmp->data);
 
           gtk_widget_get_preferred_size (GTK_WIDGET (button), NULL, &child_req);
-          has_label = (xfce_indicator_button_get_label (button) != NULL);
-          rectangular_icon = xfce_indicator_button_is_icon_rectangular (button);
+
+          is_small = xfce_indicator_button_is_small (button);
 
           /* wrap rows if column is overflowing or a label is encountered */
-          if (row > 0 && (has_label || row >= nrows || rectangular_icon))
+          if (row > 0 && (row >= nrows || !is_small))
             {
               x += length;
               row = 0;
@@ -365,7 +386,7 @@ xfce_indicator_box_get_preferred_length (GtkWidget *widget,
           length =
             MAX (length, (panel_orientation == GTK_ORIENTATION_HORIZONTAL) ? child_req.width :child_req.height);
 
-          if (has_label || row >= nrows || rectangular_icon)
+          if (row >= nrows || !is_small)
             {
               x += length;
               row = 0;
@@ -448,15 +469,18 @@ xfce_indicator_box_size_allocate (GtkWidget     *widget,
   XfceIndicatorButton *button;
   GtkAllocation        child_alloc;
   GtkRequisition       child_req;
-  gint                 panel_size, size;
+  gint                 panel_size, size, full_size, spacing;
   gint                 x, y;
   gint                 x0, y0;
   GList               *known_indicators, *li, *li_int, *li_tmp;
   gint                 length, width;
   gint                 row;
   gint                 nrows;
-  gboolean             has_label, rectangular_icon;
+  gboolean             is_small;
   GtkOrientation       panel_orientation;
+  GtkStyleContext     *ctx;
+  GtkBorder            padding, border;
+  gint                 border_thickness;
 
   row = 0;
   length = 0;
@@ -467,15 +491,31 @@ xfce_indicator_box_size_allocate (GtkWidget     *widget,
 
   gtk_widget_set_allocation (widget, allocation);
 
+  /* check border thickness of the first button */
+  li = gtk_container_get_children (GTK_CONTAINER (box));
+  if (li == NULL)
+    return;
+
+  button = XFCE_INDICATOR_BUTTON (li->data);
+  ctx = gtk_widget_get_style_context (GTK_WIDGET (button));
+  gtk_style_context_get_padding (ctx, gtk_widget_get_state_flags (GTK_WIDGET (button)), &padding);
+  gtk_style_context_get_border (ctx, gtk_widget_get_state_flags (GTK_WIDGET (button)), &border);
+  border_thickness = MAX (padding.left+padding.right+border.left+border.right,
+                          padding.top+padding.bottom+border.top+border.bottom);
+
+  size = ICON_SIZE + border_thickness;
   panel_size = indicator_config_get_panel_size (box->config);
+  nrows = MAX (1, panel_size / size);
+  //full_size = ((nrows-1)*panel_size + nrows*size) / nrows; // regular pitch, margins
+  full_size = panel_size; // irregular pitch, no margins
+
   panel_orientation = indicator_config_get_panel_orientation (box->config);
-  nrows = panel_size / xfce_indicator_box_get_row_size (box);
-  size = panel_size / nrows;
 
   if (g_hash_table_lookup (box->children, "<placeholder>") != NULL)
     known_indicators = g_list_append (NULL, "<placeholder>");
   else
     known_indicators = indicator_config_get_known_indicators (box->config);
+
   for (li = known_indicators; li != NULL; li = li->next)
     {
       li_int = g_hash_table_lookup (box->children, li->data);
@@ -485,19 +525,27 @@ xfce_indicator_box_size_allocate (GtkWidget     *widget,
 
           gtk_widget_get_preferred_size (GTK_WIDGET (button), NULL, &child_req);
 
-          has_label = (xfce_indicator_button_get_label (button) != NULL);
-          rectangular_icon = xfce_indicator_button_is_icon_rectangular (button);
+          is_small = xfce_indicator_button_is_small (button);
 
           /* wrap rows if column is overflowing or a label is encountered */
-          if (row > 0 && (has_label || row >= nrows || rectangular_icon))
+          if (row > 0 && (row >= nrows || !is_small))
             {
               x += length;
-              y = 0;
               row = 0;
               length = 0;
             }
 
-          width = (has_label || rectangular_icon) ? panel_size : size;
+          // regular pitch
+          // y = ((2*row+1) * panel_size + nrows - nrows * size) / 2 / nrows;
+          // no margins
+          if (!is_small)
+            y = 0;
+          else if (nrows == 1)
+            y = (panel_size - size + 1) / 2;
+          else
+            y = (2*row*(panel_size-size) + nrows - 1) / (2*nrows-2);
+
+          width = (is_small) ? size : full_size;
           length = MAX (length,
                         (panel_orientation == GTK_ORIENTATION_HORIZONTAL) ? child_req.width :child_req.height);
 
@@ -521,17 +569,15 @@ xfce_indicator_box_size_allocate (GtkWidget     *widget,
 
           gtk_widget_size_allocate (GTK_WIDGET (button), &child_alloc);
 
-          if (has_label || row >= nrows || rectangular_icon)
+          if (row >= nrows || !is_small)
             {
               x += length;
-              y = 0;
               row = 0;
               length = 0;
             }
           else
             {
               row += 1;
-              y += size;
             }
         }
     }
diff --git a/panel-plugin/indicator-button-box.c b/panel-plugin/indicator-button-box.c
new file mode 100644
index 0000000..2812e2c
--- /dev/null
+++ b/panel-plugin/indicator-button-box.c
@@ -0,0 +1,586 @@
+/*  Copyright (c) 2013 Andrzej <ndrwrdck at gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+
+/*
+ *  This file implements a container class holding an icon and a label
+ *  for use in XfceIndicatorButton.
+ *
+ */
+
+
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <libxfce4panel/libxfce4panel.h>
+
+#include "indicator-button-box.h"
+
+#define ICON_SIZE 22
+#define SPACING 2
+
+static void   indicator_button_box_finalize                        (GObject                *object);
+static void   indicator_button_box_get_preferred_width             (GtkWidget              *widget,
+                                                                    gint                   *minimum_width,
+                                                                    gint                   *natural_width);
+static void   indicator_button_box_get_preferred_width_for_height  (GtkWidget              *widget,
+                                                                    gint                    height,
+                                                                    gint                   *minimum_width,
+                                                                    gint                   *natural_width);
+static void   indicator_button_box_get_preferred_height            (GtkWidget              *widget,
+                                                                    gint                   *minimum_height,
+                                                                    gint                   *natural_height);
+static void   indicator_button_box_get_preferred_height_for_width  (GtkWidget              *widget,
+                                                                    gint                    width,
+                                                                    gint                   *minimum_height,
+                                                                    gint                   *natural_height);
+static void   indicator_button_box_size_allocate                   (GtkWidget             *widget,
+                                                                    GtkAllocation         *allocation);
+static void   indicator_button_box_add                             (GtkContainer          *container,
+                                                                    GtkWidget             *child);
+static void   indicator_button_box_remove                          (GtkContainer          *container,
+                                                                    GtkWidget             *child);
+static GType  indicator_button_box_child_type                      (GtkContainer          *container);
+static void   indicator_button_box_forall                          (GtkContainer          *container,
+                                                                    gboolean              include_internals,
+                                                                    GtkCallback           callback,
+                                                                    gpointer              callback_data);
+
+
+struct _IndicatorButtonBox
+{
+  GtkContainer        __parent__;
+
+  IndicatorConfig      *config;
+
+  GtkWidget            *label;
+  GtkWidget            *icon;
+
+  gboolean              cached;
+  gboolean              is_small;
+  gint                  pixbuf_w;
+  gint                  pixbuf_h;
+  GtkOrientation        orientation;
+
+  gulong                configuration_changed_id;
+};
+
+struct _IndicatorButtonBoxClass
+{
+  GtkContainerClass   __parent__;
+};
+
+
+
+
+G_DEFINE_TYPE (IndicatorButtonBox, indicator_button_box, GTK_TYPE_CONTAINER)
+
+static void
+indicator_button_box_class_init (IndicatorButtonBoxClass *klass)
+{
+  GObjectClass      *gobject_class;
+  GtkWidgetClass    *widget_class;
+  GtkContainerClass *container_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = indicator_button_box_finalize;
+
+  widget_class = GTK_WIDGET_CLASS (klass);
+  widget_class->get_preferred_width             = indicator_button_box_get_preferred_width;
+  widget_class->get_preferred_width_for_height  = indicator_button_box_get_preferred_width_for_height;
+  widget_class->get_preferred_height            = indicator_button_box_get_preferred_height;
+  widget_class->get_preferred_height_for_width  = indicator_button_box_get_preferred_height_for_width;
+  widget_class->size_allocate                   = indicator_button_box_size_allocate;
+
+  container_class = GTK_CONTAINER_CLASS (klass);
+  container_class->add               = indicator_button_box_add;
+  container_class->remove            = indicator_button_box_remove;
+  container_class->child_type        = indicator_button_box_child_type;
+  container_class->forall            = indicator_button_box_forall;
+}
+
+
+
+static void
+indicator_button_box_init (IndicatorButtonBox *box)
+{
+  gtk_widget_set_has_window (GTK_WIDGET (box), FALSE);
+  gtk_widget_set_can_focus(GTK_WIDGET(box), FALSE);
+  gtk_widget_set_can_default (GTK_WIDGET (box), FALSE);
+  gtk_container_set_border_width(GTK_CONTAINER(box), 0);
+  gtk_widget_set_name (GTK_WIDGET (box), "indicator-button-box");
+
+  box->config = NULL;
+
+  box->label = NULL;
+  box->icon = NULL;
+
+  box->cached = FALSE;
+  box->is_small = TRUE;
+  box->pixbuf_w = -1;
+  box->pixbuf_h = -1;
+  box->orientation = GTK_ORIENTATION_HORIZONTAL;
+
+  box->configuration_changed_id = 0;
+}
+
+
+
+static void
+indicator_button_box_finalize (GObject *object)
+{
+  IndicatorButtonBox *box = XFCE_INDICATOR_BUTTON_BOX (object);
+
+  indicator_button_box_disconnect_signals (box);
+
+  if (box->label != NULL)
+    g_object_unref (G_OBJECT (box->label));
+  if (box->icon != NULL)
+    g_object_unref (G_OBJECT (box->icon));
+
+  G_OBJECT_CLASS (indicator_button_box_parent_class)->finalize (object);
+}
+
+
+
+static GType
+indicator_button_box_child_type (GtkContainer          *container)
+{
+  return GTK_TYPE_WIDGET;
+}
+
+
+
+
+
+static void
+indicator_button_box_forall (GtkContainer *container,
+                             gboolean      include_internals,
+                             GtkCallback   callback,
+                             gpointer      callback_data)
+{
+  IndicatorButtonBox *box = XFCE_INDICATOR_BUTTON_BOX (container);
+
+  if (box->icon != NULL)
+    (*callback) (box->icon, callback_data);
+  if (box->label != NULL)
+    (*callback) (box->label, callback_data);
+}
+
+
+
+
+static void
+indicator_button_box_add (GtkContainer *container,
+                          GtkWidget    *child)
+{
+  IndicatorButtonBox  *box = XFCE_INDICATOR_BUTTON_BOX (container);
+
+  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON_BOX (box));
+  g_return_if_fail (gtk_widget_get_parent (GTK_WIDGET (child)) == NULL);
+
+  gtk_widget_set_parent (child, GTK_WIDGET (box));
+  gtk_widget_queue_resize (GTK_WIDGET (container));
+}
+
+
+
+static void
+indicator_button_box_remove (GtkContainer *container,
+                             GtkWidget    *child)
+{
+  IndicatorButtonBox  *box = XFCE_INDICATOR_BUTTON_BOX (container);
+
+  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON_BOX (box));
+
+  gtk_widget_unparent (child);
+  gtk_widget_queue_resize (GTK_WIDGET (container));
+}
+
+
+
+static void
+indicator_button_box_label_changed (GtkLabel            *label,
+                                    GParamSpec          *pspec,
+                                    IndicatorButtonBox  *box)
+{
+  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON_BOX (box));
+  g_return_if_fail (GTK_IS_LABEL (label));
+
+  gtk_widget_queue_resize (GTK_WIDGET (box));
+}
+
+
+
+void
+indicator_button_box_set_label (IndicatorButtonBox  *box,
+                                GtkLabel            *label)
+{
+  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON_BOX (box));
+  g_return_if_fail (GTK_IS_LABEL (label));
+
+  if (box->label != NULL)
+    {
+      gtk_container_remove (GTK_CONTAINER (box), box->label);
+      g_object_unref (G_OBJECT (box->label));
+    }
+  box->label = GTK_WIDGET (label);
+  g_object_ref (G_OBJECT (box->label));
+  g_signal_connect(G_OBJECT(box->label), "notify::label",
+                   G_CALLBACK(indicator_button_box_label_changed), box);
+
+  gtk_label_set_ellipsize (GTK_LABEL (box->label), PANGO_ELLIPSIZE_END);
+  box->is_small = FALSE;
+
+  gtk_container_add (GTK_CONTAINER (box), box->label);
+  gtk_widget_show (box->label);
+}
+
+
+
+
+static void
+indicator_button_box_icon_changed (GtkImage            *icon,
+                                   GParamSpec          *pspec,
+                                   IndicatorButtonBox  *box)
+{
+  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON_BOX (box));
+  g_return_if_fail (GTK_IS_IMAGE (icon));
+
+  box->cached = FALSE;
+
+  gtk_widget_queue_resize (GTK_WIDGET (box));
+}
+
+
+
+void
+indicator_button_box_set_image (IndicatorButtonBox  *box,
+                                GtkImage            *image)
+{
+  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON_BOX (box));
+  g_return_if_fail (GTK_IS_IMAGE (image));
+
+  g_debug ("indicator-button-box set image, image=%x\n", (uint) image);
+
+  if (box->icon != NULL)
+    {
+      gtk_container_remove (GTK_CONTAINER (box), box->label);
+      g_object_unref (G_OBJECT (box->icon));
+    }
+  box->icon = GTK_WIDGET (image);
+  g_object_ref (G_OBJECT (box->icon));
+  g_signal_connect(G_OBJECT(box->icon), "notify::pixbuf",
+                   G_CALLBACK(indicator_button_box_icon_changed), box);
+
+  box->cached = FALSE;
+
+  gtk_container_add (GTK_CONTAINER (box), box->icon);
+  gtk_widget_show (box->icon);
+}
+
+
+
+static void
+indicator_button_box_configuration_changed (IndicatorButtonBox  *box,
+                                            IndicatorConfig     *config)
+{
+  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON_BOX (box));
+  g_return_if_fail (XFCE_IS_INDICATOR_CONFIG (config));
+
+  box->cached = FALSE;
+
+  gtk_widget_queue_resize (GTK_WIDGET (box));
+}
+
+
+
+GtkWidget *
+indicator_button_box_new (IndicatorConfig      *config)
+{
+  IndicatorButtonBox *box = g_object_new (XFCE_TYPE_INDICATOR_BUTTON_BOX, NULL);
+  g_return_val_if_fail (XFCE_IS_INDICATOR_CONFIG (config), NULL);
+
+  box->config = config;
+
+  box->configuration_changed_id =
+    g_signal_connect_swapped (G_OBJECT (box->config), "configuration-changed",
+                              G_CALLBACK (indicator_button_box_configuration_changed), box);
+
+  return GTK_WIDGET (box);
+}
+
+
+
+void
+indicator_button_box_disconnect_signals (IndicatorButtonBox *box)
+{
+  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON_BOX (box));
+
+  if (box->configuration_changed_id != 0)
+    {
+      g_signal_handler_disconnect (box->config, box->configuration_changed_id);
+      box->configuration_changed_id = 0;
+    }
+}
+
+
+
+gboolean
+indicator_button_box_is_small (IndicatorButtonBox *box)
+{
+  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON_BOX (box));
+
+  if (box->cached)
+    return box->is_small;
+
+  // check sizes
+  box->pixbuf_w = -1;
+  box->pixbuf_h = -1;
+
+  if (box->label != NULL)
+    {
+      box->is_small = FALSE;
+      box->orientation = indicator_config_get_panel_orientation (box->config);
+      if (box->orientation == GTK_ORIENTATION_VERTICAL &&
+          indicator_config_get_orientation (box->config) == GTK_ORIENTATION_HORIZONTAL &&
+          indicator_config_get_align_left (box->config))
+        box->orientation = GTK_ORIENTATION_HORIZONTAL;
+      gtk_label_set_angle (GTK_LABEL (box->label),
+                           (indicator_config_get_orientation (box->config) == GTK_ORIENTATION_VERTICAL)
+                           ? -90 : 0);
+    }
+  else if (box->icon != NULL &&
+           gtk_image_get_storage_type (GTK_IMAGE (box->icon)) == GTK_IMAGE_PIXBUF)
+    {
+      GdkPixbuf *pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (box->icon));
+
+      box->pixbuf_w = gdk_pixbuf_get_width (pixbuf);
+      box->pixbuf_h = gdk_pixbuf_get_height (pixbuf);
+
+      box->is_small = (box->pixbuf_w == box->pixbuf_h);
+    }
+  else
+    {
+      box->is_small = TRUE;
+    }
+
+  box->cached = TRUE;
+
+  return box->is_small;
+}
+
+
+
+
+static void
+indicator_button_box_get_preferred_width (GtkWidget *widget,
+                                          gint      *minimum_width,
+                                          gint      *natural_width)
+{
+  IndicatorButtonBox  *box = XFCE_INDICATOR_BUTTON_BOX (widget);
+  IndicatorConfig     *config = box->config;
+  gint                 min_size, nat_size;
+
+  if (indicator_button_box_is_small (box)) // check & cache
+    {
+      min_size = nat_size = ICON_SIZE;
+    }
+  else if (box->label != NULL)
+    {
+      gtk_widget_get_preferred_width (box->label, &min_size, &nat_size);
+
+      if (box->icon != NULL && box->orientation == GTK_ORIENTATION_HORIZONTAL)
+        {
+          min_size = min_size + ICON_SIZE + SPACING;
+          nat_size = nat_size + ICON_SIZE + SPACING;
+        }
+      else
+        {
+          min_size = MAX (min_size, ICON_SIZE);
+          nat_size = MAX (nat_size, ICON_SIZE);
+        }
+    }
+  else // rectangular icon
+    {
+      min_size = nat_size = MAX (box->pixbuf_w, ICON_SIZE);
+    }
+
+  if (minimum_width != NULL)
+    *minimum_width = min_size;
+
+  if (natural_width != NULL)
+    *natural_width = nat_size;
+}
+
+
+
+static void
+indicator_button_box_get_preferred_width_for_height (GtkWidget *widget,
+                                                     gint       height,
+                                                     gint      *minimum_width,
+                                                     gint      *natural_width)
+{
+  indicator_button_box_get_preferred_width (widget, minimum_width, natural_width);
+}
+
+
+
+
+static void
+indicator_button_box_get_preferred_height (GtkWidget *widget,
+                                           gint      *minimum_height,
+                                           gint      *natural_height)
+{
+  IndicatorButtonBox  *box = XFCE_INDICATOR_BUTTON_BOX (widget);
+  IndicatorConfig     *config = box->config;
+  gint                 min_size, nat_size;
+
+  if (indicator_button_box_is_small (box)) // check & cache
+    {
+      min_size = nat_size = ICON_SIZE;
+    }
+  else if (box->label != NULL)
+    {
+      gtk_widget_get_preferred_height (box->label, &min_size, &nat_size);
+
+      if (box->icon != NULL && box->orientation == GTK_ORIENTATION_VERTICAL)
+        {
+          min_size = min_size + ICON_SIZE + SPACING;
+          nat_size = nat_size + ICON_SIZE + SPACING;
+        }
+      else
+        {
+          min_size = MAX (min_size, ICON_SIZE);
+          nat_size = MAX (nat_size, ICON_SIZE);
+        }
+    }
+  else // rectangular icon
+    {
+      min_size = nat_size = MAX (box->pixbuf_h, ICON_SIZE);
+    }
+
+  if (minimum_height != NULL)
+    *minimum_height = min_size;
+
+  if (natural_height != NULL)
+    *natural_height = nat_size;
+}
+
+
+
+static void
+indicator_button_box_get_preferred_height_for_width (GtkWidget *widget,
+                                                     gint       width,
+                                                     gint      *minimum_height,
+                                                     gint      *natural_height)
+{
+  indicator_button_box_get_preferred_height (widget, minimum_height, natural_height);
+}
+
+
+
+
+static void
+indicator_button_box_size_allocate (GtkWidget     *widget,
+                                    GtkAllocation *allocation)
+{
+  IndicatorButtonBox  *box = XFCE_INDICATOR_BUTTON_BOX (widget);
+  IndicatorConfig     *config = box->config;
+  gint                 label_width, label_height;
+  gint                 x, y, width, height;
+  GtkAllocation        child_allocation;
+
+  gtk_widget_set_allocation (widget, allocation);
+
+  x = allocation->x;
+  y = allocation->y;
+  width  = allocation->width;
+  height = allocation->height;
+
+  if (indicator_button_box_is_small (box)) // check & cache
+    {
+      child_allocation.x = x + (width - ICON_SIZE + 1) / 2;
+      child_allocation.y = y + (height - ICON_SIZE + 1) / 2;
+      child_allocation.width = ICON_SIZE;
+      child_allocation.height = ICON_SIZE;
+      gtk_widget_size_allocate (box->icon, &child_allocation);
+    }
+  else if (box->icon != NULL)
+    {
+      /* allocate icon */
+      child_allocation.width = MAX (ICON_SIZE, box->pixbuf_w);
+      child_allocation.height = MAX (ICON_SIZE, box->pixbuf_h);
+      if (box->orientation == GTK_ORIENTATION_HORIZONTAL)
+        {
+          if (box->label != NULL)
+            child_allocation.x = x;
+          else
+            child_allocation.x = x + (width - child_allocation.width + 1) / 2;
+          child_allocation.y = y + (height - child_allocation.height + 1) / 2;
+        }
+      else
+        {
+          if (box->label != NULL)
+            child_allocation.y = y;
+          else
+            child_allocation.y = y + (height - child_allocation.height + 1) / 2;
+          child_allocation.x = x + (width - child_allocation.width + 1) / 2;
+        }
+      gtk_widget_size_allocate (box->icon, &child_allocation);
+    }
+  if (box->label != NULL)
+    {
+      /* allocate label */
+      gtk_widget_get_preferred_width  (box->label, NULL, &label_width);
+      gtk_widget_get_preferred_height (box->label, NULL, &label_height);
+
+      if (box->orientation == GTK_ORIENTATION_HORIZONTAL)
+        {
+          if (box->icon != NULL)
+            {
+              child_allocation.x = x + ICON_SIZE + SPACING;
+              child_allocation.width  = MAX (1, MIN (width - ICON_SIZE - SPACING, label_width));
+            }
+          else
+            {
+              child_allocation.x = x;
+              child_allocation.width  = MAX (ICON_SIZE, MIN (width, label_width));
+            }
+          child_allocation.height = MAX (ICON_SIZE, MIN (height, label_height));
+          child_allocation.y = y + (height - child_allocation.height + 1) / 2;
+        }
+      else
+        {
+          if (box->icon != NULL)
+            {
+              child_allocation.y = y + ICON_SIZE + SPACING;
+              child_allocation.height = MAX (1, MIN (height - ICON_SIZE - SPACING, label_height));
+            }
+          else
+            {
+              child_allocation.height = MAX (ICON_SIZE, MIN (height, label_height));
+              child_allocation.y = y + (height - child_allocation.height + 1) / 2;
+            }
+          child_allocation.width  = MAX (ICON_SIZE, MIN (width, label_width));
+          child_allocation.x = x + (width - child_allocation.width + 1) / 2;
+        }
+      gtk_widget_size_allocate (box->label, &child_allocation);
+    }
+}
+
diff --git a/panel-plugin/indicator-button-box.h b/panel-plugin/indicator-button-box.h
new file mode 100644
index 0000000..2bf9598
--- /dev/null
+++ b/panel-plugin/indicator-button-box.h
@@ -0,0 +1,55 @@
+/*  Copyright (c) 2013 Andrzej <ndrwrdck at gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __INDICATOR_BUTTON_BOX_H__
+#define __INDICATOR_BUTTON_BOX_H__
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "indicator-config.h"
+
+G_BEGIN_DECLS
+
+GType indicator_button_box_get_type (void);
+
+#define XFCE_TYPE_INDICATOR_BUTTON_BOX             (indicator_button_box_get_type())
+#define XFCE_INDICATOR_BUTTON_BOX(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), XFCE_TYPE_INDICATOR_BUTTON_BOX, IndicatorButtonBox))
+#define XFCE_INDICATOR_BUTTON_BOX_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), XFCE_TYPE_INDICATOR_BUTTON_BOX, IndicatorButtonBoxClass))
+#define XFCE_IS_INDICATOR_BUTTON_BOX(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), XFCE_TYPE_INDICATOR_BUTTON_BOX))
+#define XFCE_IS_INDICATOR_BUTTON_BOX_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), XFCE_TYPE_INDICATOR_BUTTON_BOX))
+#define XFCE_INDICATOR_BUTTON_BOX_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), XFCE_TYPE_INDICATOR_BUTTON_BOX, IndicatorButtonBoxClass))
+
+typedef struct          _IndicatorButtonBox              IndicatorButtonBox;
+typedef struct          _IndicatorButtonBoxClass         IndicatorButtonBoxClass;
+
+
+void                    indicator_button_box_set_label   (IndicatorButtonBox        *box,
+                                                          GtkLabel                  *label);
+
+void                    indicator_button_box_set_image   (IndicatorButtonBox        *box,
+                                                          GtkImage                  *image);
+
+gboolean                indicator_button_box_is_small    (IndicatorButtonBox        *box);
+
+GtkWidget              *indicator_button_box_new         (IndicatorConfig           *config);
+
+void                    indicator_button_box_disconnect_signals (IndicatorButtonBox *box);
+
+G_END_DECLS
+
+#endif /* !__INDICATOR_BUTTON_BOX_H__ */
diff --git a/panel-plugin/indicator-button.c b/panel-plugin/indicator-button.c
index 67b5b6a..7c4bffd 100644
--- a/panel-plugin/indicator-button.c
+++ b/panel-plugin/indicator-button.c
@@ -31,19 +31,18 @@
 #include <libindicator/indicator-object.h>
 
 #include "indicator-button.h"
+#include "indicator-button-box.h"
 
 
 #include <libindicator/indicator-object.h>
+
+#define ICON_SIZE 22
+#define SPACING 2
+
 //#ifndef INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED
 //#define INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED "scroll-entry"
 //#endif
 
-//#if GTK_CHECK_VERSION (3, 0, 0) && !GTK_CHECK_VERSION (3, 10, 0)
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define GTK_BUTTON_SIZING_FIX
-#endif
-
-
 static void                 xfce_indicator_button_finalize        (GObject                *object);
 static gint                 xfce_indicator_button_get_icon_size   (XfceIndicatorButton    *button);
 static gboolean             xfce_indicator_button_button_press    (GtkWidget              *widget,
@@ -52,14 +51,12 @@ static gboolean             xfce_indicator_button_scroll          (GtkWidget
                                                                    GdkEventScroll         *event);
 static void                 xfce_indicator_button_menu_deactivate (XfceIndicatorButton    *button,
                                                                    GtkMenu                *menu);
-#ifdef GTK_BUTTON_SIZING_FIX
 static void            xfce_indicator_button_get_preferred_width  (GtkWidget              *widget,
                                                                    gint                   *minimum_width,
                                                                    gint                   *natural_width);
 static void            xfce_indicator_button_get_preferred_height (GtkWidget              *widget,
                                                                    gint                   *minimum_height,
                                                                    gint                   *natural_height);
-#endif
 
 
 struct _XfceIndicatorButton
@@ -75,13 +72,6 @@ struct _XfceIndicatorButton
 
   GtkWidget            *align_box;
   GtkWidget            *box;
-  GtkWidget            *label;
-  GtkWidget            *icon;
-  GtkWidget            *orig_icon;
-  gboolean              rectangular_icon;
-
-  gulong                orig_icon_changed_id;
-  gulong                configuration_changed_id;
 };
 
 struct _XfceIndicatorButtonClass
@@ -106,10 +96,8 @@ xfce_indicator_button_class_init (XfceIndicatorButtonClass *klass)
   widget_class = GTK_WIDGET_CLASS (klass);
   widget_class->button_press_event = xfce_indicator_button_button_press;
   widget_class->scroll_event = xfce_indicator_button_scroll;
-#ifdef GTK_BUTTON_SIZING_FIX
   widget_class->get_preferred_width = xfce_indicator_button_get_preferred_width;
   widget_class->get_preferred_height = xfce_indicator_button_get_preferred_height;
-#endif
 }
 
 
@@ -131,21 +119,9 @@ xfce_indicator_button_init (XfceIndicatorButton *button)
   button->config = NULL;
   button->menu = NULL;
 
-  button->label = NULL;
-  button->orig_icon = NULL;
-  button->icon = NULL;
-  button->orig_icon_changed_id = 0;
-  button->configuration_changed_id = 0;
-  button->rectangular_icon = FALSE;
-
-  button->align_box = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+  button->align_box = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
   gtk_container_add (GTK_CONTAINER (button), button->align_box);
   gtk_widget_show (button->align_box);
-
-  //button->box = xfce_hvbox_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 1);
-  button->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
-  gtk_container_add (GTK_CONTAINER (button->align_box), button->box);
-  gtk_widget_show (button->box);
 }
 
 
@@ -157,12 +133,6 @@ xfce_indicator_button_finalize (GObject *object)
 
   xfce_indicator_button_disconnect_signals (button);
 
-  if (button->label != NULL)
-    g_object_unref (G_OBJECT (button->label));
-  if (button->orig_icon != NULL)
-    g_object_unref (G_OBJECT (button->orig_icon));
-  if (button->icon != NULL)
-    g_object_unref (G_OBJECT (button->icon));
   if (button->menu != NULL)
     g_object_unref (G_OBJECT (button->menu));
   /* IndicatorObjectEntry is not GObject */
@@ -176,200 +146,6 @@ xfce_indicator_button_finalize (GObject *object)
 
 
 
-static void
-xfce_indicator_button_update_layout (XfceIndicatorButton *button)
-{
-  GtkRequisition          label_size;
-  gfloat                  align_x;
-  gint                    border_thickness;
-  GtkStyleContext        *ctx;
-  GtkBorder               padding, border;
-
-  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button));
-
-  if (button->label != NULL)
-    gtk_label_set_ellipsize (GTK_LABEL (button->label), PANGO_ELLIPSIZE_NONE);
-
-  /* deskbar mode? */
-  if (button->label != NULL &&
-      indicator_config_get_panel_orientation (button->config) == GTK_ORIENTATION_VERTICAL &&
-      indicator_config_get_orientation (button->config) == GTK_ORIENTATION_HORIZONTAL)
-    {
-      ctx = gtk_widget_get_style_context (GTK_WIDGET (button));
-      gtk_style_context_get_padding (ctx,
-                                     gtk_widget_get_state_flags (GTK_WIDGET (button)),
-                                     &padding);
-      gtk_style_context_get_border (ctx,
-                                    gtk_widget_get_state_flags (GTK_WIDGET (button)),
-                                    &border);
-      border_thickness = MAX (padding.left+padding.right+border.left+border.right,
-                              padding.top+padding.bottom+border.top+border.bottom);
-
-      gtk_widget_get_preferred_size (button->label, NULL, &label_size);
-
-      /* check if icon and label fit side by side */
-      if (!indicator_config_get_align_left (button->config)
-          || (button->icon != NULL
-              && label_size.width >
-              indicator_config_get_panel_size (button->config) - 2 - border_thickness
-              - xfce_indicator_button_get_icon_size (button)))
-        {
-          align_x = 0.5;
-          gtk_orientable_set_orientation (GTK_ORIENTABLE (button->box), GTK_ORIENTATION_VERTICAL);
-        }
-      else
-        {
-          align_x = 0.0;
-          gtk_orientable_set_orientation (GTK_ORIENTABLE (button->box), GTK_ORIENTATION_HORIZONTAL);
-        }
-
-      /* check if label alone fits in the panel */
-      if (label_size.width > indicator_config_get_panel_size (button->config) - border_thickness)
-        {
-          gtk_alignment_set (GTK_ALIGNMENT (button->align_box), align_x, 0.5, 1.0, 0.0);
-          gtk_label_set_ellipsize (GTK_LABEL (button->label), PANGO_ELLIPSIZE_END);
-        }
-      else
-        {
-          gtk_alignment_set (GTK_ALIGNMENT (button->align_box), align_x, 0.5, 0.0, 0.0);
-        }
-    }
-  else
-    {
-      gtk_alignment_set (GTK_ALIGNMENT (button->align_box), 0.5, 0.5, 0.0, 0.0);
-      gtk_orientable_set_orientation (GTK_ORIENTABLE (button->box),
-                                      indicator_config_get_orientation (button->config));
-    }
-
-
-  if (button->label != NULL)
-    gtk_label_set_angle (GTK_LABEL (button->label),
-                         (indicator_config_get_orientation (button->config) == GTK_ORIENTATION_VERTICAL)
-                         ? -90 : 0);
-}
-
-
-
-
-static void
-xfce_indicator_button_update_icon (XfceIndicatorButton *button)
-{
-  GdkPixbuf        *pixbuf_s, *pixbuf_d;
-  gdouble           aspect;
-  gint              w, h, w2, h2, size;
-  gint              border_thickness;
-  GtkStyleContext  *ctx;
-  GtkBorder         padding, border;
-  GtkImageType      storage;
-
-  g_return_if_fail (GTK_IS_IMAGE (button->orig_icon));
-  g_return_if_fail (GTK_IS_IMAGE (button->icon));
-
-  size = xfce_indicator_button_get_icon_size (button);
-
-  if (size > 22 && size <= 26)
-    size = 22;
-
-#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
-
-  storage = gtk_image_get_storage_type (GTK_IMAGE (button->orig_icon));
-
-  if (storage == GTK_IMAGE_PIXBUF || storage == GTK_IMAGE_EMPTY)
-    {
-      pixbuf_s = gtk_image_get_pixbuf (GTK_IMAGE (button->orig_icon));
-    }
-  else if (storage == GTK_IMAGE_GICON)
-    {
-      GIcon *icon = NULL;
-      GtkIconSize size;
-      gtk_image_get_gicon (GTK_IMAGE (button->orig_icon), &icon, &size);
-      //printf ("G_ICON %s ... %d\n", g_icon_to_string (icon), size);
-      gtk_image_set_from_gicon (GTK_IMAGE (button->icon),
-                                icon, size);
-      return;
-    }
-  else if (storage == GTK_IMAGE_ICON_NAME)
-    {
-      const gchar *icon_name = NULL;
-      GtkIconSize size;
-      gtk_image_get_icon_name (GTK_IMAGE (button->orig_icon), &icon_name, &size);
-      //printf ("ICON_NAME %s ... %d\n", icon_name, size);
-      gtk_image_set_from_icon_name (GTK_IMAGE (button->icon),
-                                    icon_name, size);
-      return;
-    }
-  else
-    {
-      printf ("Unrecognized storage type");
-      return;
-    }
-
-  if (pixbuf_s != NULL)
-    {
-      w = gdk_pixbuf_get_width (pixbuf_s);
-      h = gdk_pixbuf_get_height (pixbuf_s);
-      aspect = (gdouble) w / (gdouble) h;
-      ctx = gtk_widget_get_style_context (GTK_WIDGET (button));
-      gtk_style_context_get_padding (ctx,
-                                     gtk_widget_get_state_flags (GTK_WIDGET (button)),
-                                     &padding);
-      gtk_style_context_get_border (ctx,
-                                    gtk_widget_get_state_flags (GTK_WIDGET (button)),
-                                    &border);
-      border_thickness = MAX (padding.left+padding.right+border.left+border.right,
-                              padding.top+padding.bottom+border.top+border.bottom);
-
-      button->rectangular_icon = (w != h);
-
-      if (indicator_config_get_panel_orientation (button->config) == GTK_ORIENTATION_VERTICAL &&
-          size * aspect > indicator_config_get_panel_size (button->config) - border_thickness)
-        {
-          w2 = indicator_config_get_panel_size (button->config) - border_thickness;
-          h2 = (gint) (w2 / aspect);
-        }
-      else
-        {
-          h2 = size;
-          w2 = (gint) (h2 * aspect);
-        }
-
-      if (h2 == h)
-        {
-          gtk_image_set_from_pixbuf (GTK_IMAGE (button->icon), pixbuf_s);
-        }
-      else
-        {
-          pixbuf_d = gdk_pixbuf_scale_simple (pixbuf_s, w2, h2, GDK_INTERP_BILINEAR);
-          gtk_image_set_from_pixbuf (GTK_IMAGE (button->icon), pixbuf_d);
-          g_object_unref (G_OBJECT (pixbuf_d));
-        }
-    }
-  else
-    {
-      gtk_image_set_from_icon_name (GTK_IMAGE (button->icon),
-                                    "image-missing", GTK_ICON_SIZE_MENU);
-    }
-}
-
-
-
-static void
-xfce_indicator_button_label_changed (GtkLabel            *label,
-                                     GParamSpec          *pspec,
-                                     XfceIndicatorButton *button)
-{
-  xfce_indicator_button_update_layout (button);
-}
-
-
-
 void
 xfce_indicator_button_set_label (XfceIndicatorButton *button,
                                  GtkLabel            *label)
@@ -377,37 +153,12 @@ xfce_indicator_button_set_label (XfceIndicatorButton *button,
   g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button));
   g_return_if_fail (GTK_IS_LABEL (label));
 
-  if (button->label != GTK_WIDGET (label))
-    {
-      if (button->label != NULL)
-        {
-          gtk_container_remove (GTK_CONTAINER (button->box), button->label);
-          g_object_unref (G_OBJECT (button->label));
-        }
-
-      button->label = GTK_WIDGET (label);
-      g_object_ref (G_OBJECT (button->label));
-      gtk_box_pack_end (GTK_BOX (button->box), button->label, TRUE, FALSE, 1);
-      g_signal_connect(G_OBJECT(button->label), "notify::label", G_CALLBACK(xfce_indicator_button_label_changed), button);
-    }
-  xfce_indicator_button_update_layout (button);
+  indicator_button_box_set_label (XFCE_INDICATOR_BUTTON_BOX (button->box), label);
 }
 
 
 
 
-static void
-on_pixbuf_changed (GtkImage *image, GParamSpec *pspec, XfceIndicatorButton *button)
-{
-  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button));
-  g_return_if_fail (GTK_IS_IMAGE (image));
-  g_return_if_fail (GTK_IS_IMAGE (button->icon));
-
-  xfce_indicator_button_update_icon (button);
-}
-
-
-
 void
 xfce_indicator_button_set_image (XfceIndicatorButton *button,
                                  GtkImage            *image)
@@ -415,40 +166,7 @@ xfce_indicator_button_set_image (XfceIndicatorButton *button,
   g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button));
   g_return_if_fail (GTK_IS_IMAGE (image));
 
-  g_debug ("indicator-button set image, image=%x\n", (uint) image);
-
-  if (button->orig_icon != GTK_WIDGET (image))
-    {
-      if (button->orig_icon != NULL)
-        {
-          if (button->orig_icon_changed_id != 0)
-            {
-              g_signal_handler_disconnect (G_OBJECT (button->orig_icon), button->orig_icon_changed_id);
-              button->orig_icon_changed_id = 0;
-            }
-          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));
-        }
-
-      button->orig_icon = GTK_WIDGET (image);
-      g_object_ref (G_OBJECT (button->orig_icon));
-
-      button->orig_icon_changed_id = g_signal_connect
-        (G_OBJECT (image), "notify::pixbuf", G_CALLBACK (on_pixbuf_changed), button);
-
-      button->icon = gtk_image_new ();
-      xfce_indicator_button_update_icon (button);
-
-      gtk_box_pack_start (GTK_BOX (button->box), button->icon, TRUE, FALSE, 2);
-      gtk_widget_show (button->icon);
-
-      xfce_indicator_button_update_layout (button);
-    }
+  indicator_button_box_set_image (XFCE_INDICATOR_BUTTON_BOX (button->box), image);
 }
 
 
@@ -474,26 +192,6 @@ xfce_indicator_button_set_menu (XfceIndicatorButton *button,
 
 
 
-GtkWidget *
-xfce_indicator_button_get_label (XfceIndicatorButton *button)
-{
-  g_return_val_if_fail (XFCE_IS_INDICATOR_BUTTON (button), NULL);
-
-  return button->label;
-}
-
-
-
-GtkWidget *
-xfce_indicator_button_get_image (XfceIndicatorButton *button)
-{
-  g_return_val_if_fail (XFCE_IS_INDICATOR_BUTTON (button), NULL);
-
-  return button->orig_icon;
-}
-
-
-
 IndicatorObjectEntry *
 xfce_indicator_button_get_entry (XfceIndicatorButton *button)
 {
@@ -551,56 +249,33 @@ xfce_indicator_button_get_menu (XfceIndicatorButton *button)
 
 
 gboolean
-xfce_indicator_button_is_icon_rectangular (XfceIndicatorButton *button)
+xfce_indicator_button_is_small (XfceIndicatorButton *button)
 {
   g_return_val_if_fail (XFCE_IS_INDICATOR_BUTTON (button), FALSE);
 
-  return button->rectangular_icon;
+  return indicator_button_box_is_small (XFCE_INDICATOR_BUTTON_BOX (button->box));
 }
 
 
 
 
-static gint
-xfce_indicator_button_get_icon_size (XfceIndicatorButton *button)
+gint
+xfce_indicator_button_get_button_border (XfceIndicatorButton  *button)
 {
-  gint                 indicator_size;
-  gint                 border_thickness;
   GtkStyleContext     *ctx;
   GtkBorder            padding, border;
 
-  g_return_val_if_fail (XFCE_IS_INDICATOR_BUTTON (button), 22);
-
-  indicator_size = MIN (indicator_config_get_panel_size (button->config) /
-                        indicator_config_get_nrows (button->config),
-                        indicator_config_get_row_size_max (button->config));
+  g_return_val_if_fail (XFCE_IS_INDICATOR_BUTTON (button), 0);
 
   ctx = gtk_widget_get_style_context (GTK_WIDGET (button));
   gtk_style_context_get_padding (ctx, gtk_widget_get_state_flags (GTK_WIDGET (button)), &padding);
   gtk_style_context_get_border (ctx, gtk_widget_get_state_flags (GTK_WIDGET (button)), &border);
-  border_thickness = MAX (padding.left+padding.right+border.left+border.right,
-                          padding.top+padding.bottom+border.top+border.bottom);
-
-  return indicator_size - border_thickness;
-}
-
 
-
-static void
-xfce_indicator_configuration_changed (XfceIndicatorButton *button,
-                                      IndicatorConfig     *config)
-{
-  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (button));
-  g_return_if_fail (XFCE_IS_INDICATOR_CONFIG (config));
-  g_return_if_fail (gtk_widget_get_parent (GTK_WIDGET (button)) != NULL);
-
-  if (button->orig_icon != NULL)
-    xfce_indicator_button_update_icon (button);
-  xfce_indicator_button_update_layout (button);
+  return MAX (padding.left+padding.right+border.left+border.right,
+              padding.top+padding.bottom+border.top+border.bottom);
 }
 
 
-
 GtkWidget *
 xfce_indicator_button_new (IndicatorObject      *io,
                            const gchar          *io_name,
@@ -618,15 +293,16 @@ xfce_indicator_button_new (IndicatorObject      *io,
   button->plugin = plugin;
   button->config = config;
 
+  button->box = indicator_button_box_new (button->config);
+  //gtk_container_add (GTK_CONTAINER (button), button->box);
+  gtk_container_add (GTK_CONTAINER (button->align_box), button->box);
+  gtk_widget_show (button->box);
+
   if (button->io != NULL)
     g_object_ref (G_OBJECT (button->io));
   /* IndicatorObjectEntry is not GObject */
   /* g_object_ref (G_OBJECT (button->entry)); */
 
-  button->configuration_changed_id =
-    g_signal_connect_swapped (G_OBJECT (button->config), "configuration-changed",
-                              G_CALLBACK (xfce_indicator_configuration_changed), button);
-
   return GTK_WIDGET (button);
 }
 
@@ -641,19 +317,6 @@ xfce_indicator_button_disconnect_signals (XfceIndicatorButton *button)
     {
       gtk_menu_popdown (button->menu);
     }
-
-  if (button->configuration_changed_id != 0)
-    {
-      g_signal_handler_disconnect (button->config, button->configuration_changed_id);
-      button->configuration_changed_id = 0;
-    }
-
-  if (button->orig_icon_changed_id != 0)
-    {
-      g_signal_handler_disconnect (G_OBJECT (button->orig_icon), button->orig_icon_changed_id);
-      button->orig_icon_changed_id = 0;
-    }
-
 }
 
 
@@ -702,7 +365,6 @@ xfce_indicator_button_menu_deactivate (XfceIndicatorButton *button,
 
 
 
-#ifdef GTK_BUTTON_SIZING_FIX
 /* When can_focus is true, GtkButton allocates larger size than requested *
  * and causes the panel image to grow indefinitely.                       *
  * This workaround compensates for this difference.                       *
@@ -734,23 +396,24 @@ xfce_indicator_button_padding_correction (GtkWidget *widget)
 }
 
 
-
 static void
 xfce_indicator_button_get_preferred_width (GtkWidget *widget,
                                            gint      *minimum_width,
                                            gint      *natural_width)
 {
-  gint correction;
+  gint                 correction;
+
+  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (widget));
 
   (*GTK_WIDGET_CLASS (xfce_indicator_button_parent_class)->get_preferred_width) (widget, minimum_width, natural_width);
 
   correction = xfce_indicator_button_padding_correction (widget);
 
   if (minimum_width != NULL)
-    *minimum_width = MAX (0, *minimum_width - correction);
+    *minimum_width = MAX (1, *minimum_width - correction);
 
   if (natural_width != NULL)
-    *natural_width = MAX (0, *natural_width - correction);
+    *natural_width = MAX (1, *natural_width - correction);
 }
 
 
@@ -760,16 +423,17 @@ xfce_indicator_button_get_preferred_height (GtkWidget *widget,
                                             gint      *minimum_height,
                                             gint      *natural_height)
 {
-  gint correction;
+  gint                 correction;
+
+  g_return_if_fail (XFCE_IS_INDICATOR_BUTTON (widget));
 
   (*GTK_WIDGET_CLASS (xfce_indicator_button_parent_class)->get_preferred_height) (widget, minimum_height, natural_height);
 
   correction = xfce_indicator_button_padding_correction (widget);
 
   if (minimum_height != NULL)
-    *minimum_height = MAX (0, *minimum_height - correction);
+    *minimum_height = MAX (1, *minimum_height - correction);
 
   if (natural_height != NULL)
-    *natural_height = MAX (0, *natural_height - correction);
+    *natural_height = MAX (1, *natural_height - correction);
 }
-#endif
diff --git a/panel-plugin/indicator-button.h b/panel-plugin/indicator-button.h
index 427d1e6..9347838 100644
--- a/panel-plugin/indicator-button.h
+++ b/panel-plugin/indicator-button.h
@@ -49,10 +49,6 @@ void                    xfce_indicator_button_set_image   (XfceIndicatorButton
 void                    xfce_indicator_button_set_menu    (XfceIndicatorButton        *button,
                                                            GtkMenu                    *menu);
 
-GtkWidget              *xfce_indicator_button_get_label   (XfceIndicatorButton        *button);
-
-GtkWidget              *xfce_indicator_button_get_image   (XfceIndicatorButton        *button);
-
 IndicatorObjectEntry   *xfce_indicator_button_get_entry   (XfceIndicatorButton        *button);
 
 IndicatorObject        *xfce_indicator_button_get_io      (XfceIndicatorButton        *button);
@@ -63,7 +59,9 @@ guint                   xfce_indicator_button_get_pos     (XfceIndicatorButton
 
 GtkMenu                *xfce_indicator_button_get_menu    (XfceIndicatorButton        *button);
 
-gboolean                xfce_indicator_button_is_icon_rectangular (XfceIndicatorButton *button);
+gboolean                xfce_indicator_button_is_small    (XfceIndicatorButton        *button);
+
+gint                    xfce_indicator_button_get_button_border (XfceIndicatorButton  *button);
 
 GtkWidget              *xfce_indicator_button_new         (IndicatorObject            *io,
                                                            const gchar                *io_name,


More information about the Xfce4-commits mailing list