[Xfce4-commits] <xfce4-panel:andrzejr/deskbar2> systray plugin: limiting icon size to row size, fixing orientation.

Andrzej noreply at xfce.org
Mon Jan 16 16:16:01 CET 2012


Updating branch refs/heads/andrzejr/deskbar2
         to bfb2dac65d855d2ac4e2bccc84e1e1b4ad907f94 (commit)
       from 4e48f5fdfd743d9eb407e8c8c7b792a1ccc4f024 (commit)

commit bfb2dac65d855d2ac4e2bccc84e1e1b4ad907f94
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Tue Jan 17 00:13:54 2012 +0900

    systray plugin: limiting icon size to row size, fixing orientation.
    
    Icon size is now max row size.
    The user controlled max icon size is still available for 4.8 compat.
    Maybe a better way would be to allow the user to set
    a min number of rows instead of max icon size?
    
    Centering of group of icons in the panel is disabled for consistency
    with other plugins and the itembar behavior. (icons are flushed to
    the top (horizontal mode) or to the left).
    
    Allocation order of icons is changed to mimic that of itembar.
    Icons are allocated along the columns (not rows, as it was before).
    
    Haven't tested the support for non-square icons
    - hopefully it still works. Can anyone confirm that?

 plugins/systray/systray-box.c |   37 ++++++++++++++++++++++++++++++-------
 plugins/systray/systray-box.h |    3 +++
 plugins/systray/systray.c     |   14 ++++++++++++++
 3 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/plugins/systray/systray-box.c b/plugins/systray/systray-box.c
index 06f0b46..827a1e1 100644
--- a/plugins/systray/systray-box.c
+++ b/plugins/systray/systray-box.c
@@ -100,6 +100,9 @@ struct _SystrayBox
 
   /* allocated size by the plugin */
   gint          size_alloc;
+
+  /* (minimum) number of rows */
+  gint          nrows;
 };
 
 
@@ -147,6 +150,7 @@ systray_box_init (SystrayBox *box)
   box->childeren = NULL;
   box->size_max = SIZE_MAX_DEFAULT;
   box->size_alloc = SIZE_MAX_DEFAULT;
+  box->nrows = 1;
   box->n_hidden_childeren = 0;
   box->n_visible_children = 0;
   box->horizontal = TRUE;
@@ -223,6 +227,8 @@ systray_box_size_get_max_child_size (SystrayBox *box,
       break;
     }
 
+  rows = MAX (rows, box->nrows);
+
   row_size = (alloc_size - (rows - 1) * SPACING) / rows;
   row_size = MIN (box->size_max, row_size);
 
@@ -389,7 +395,7 @@ systray_box_size_allocate (GtkWidget     *widget,
   gdouble         ratio;
   gint            x, x_start, x_end;
   gint            y, y_start, y_end;
-  gint            offset;
+  gint            offset = 0;
   GSList         *li;
   gint            alloc_size;
   gint            idx;
@@ -400,7 +406,7 @@ systray_box_size_allocate (GtkWidget     *widget,
 
   alloc_size = box->horizontal ? allocation->height : allocation->width;
 
-  systray_box_size_get_max_child_size (box, alloc_size, &rows, &row_size, &offset);
+  systray_box_size_get_max_child_size (box, alloc_size, &rows, &row_size, NULL);
 
   panel_debug_filtered (PANEL_DEBUG_SYSTRAY, "allocate rows=%d, row_size=%d, w=%d, h=%d, horiz=%s, border=%d",
                         rows, row_size, allocation->width, allocation->height,
@@ -454,7 +460,7 @@ systray_box_size_allocate (GtkWidget     *widget,
             {
               ratio = (gdouble) child_req.width / (gdouble) child_req.height;
 
-              if (box->horizontal)
+              if (!box->horizontal)
                 {
                   child_alloc.height = row_size;
                   child_alloc.width = row_size * ratio;
@@ -492,8 +498,8 @@ systray_box_size_allocate (GtkWidget     *widget,
               ratio = 1.00;
             }
 
-          if ((box->horizontal && x + child_alloc.width > x_end)
-              || (!box->horizontal && y + child_alloc.height > y_end))
+          if ((!box->horizontal && x + child_alloc.width > x_end)
+              || (box->horizontal && y + child_alloc.height > y_end))
             {
               if (ratio >= 2
                   && li->next != NULL)
@@ -508,7 +514,7 @@ systray_box_size_allocate (GtkWidget     *widget,
                   goto restart_allocation;
                 }
 
-              if (box->horizontal)
+              if (!box->horizontal)
                 {
                   x = x_start;
                   y += row_size + SPACING;
@@ -549,7 +555,7 @@ systray_box_size_allocate (GtkWidget     *widget,
           child_alloc.x += x;
           child_alloc.y += y;
 
-          if (box->horizontal)
+          if (!box->horizontal)
             x += row_size * ratio + SPACING;
           else
             y += row_size * ratio + SPACING;
@@ -743,6 +749,23 @@ systray_box_set_size_alloc (SystrayBox *box,
 
 
 void
+systray_box_set_nrows (SystrayBox *box,
+                       gint        nrows)
+{
+  panel_return_if_fail (XFCE_IS_SYSTRAY_BOX (box));
+
+  if (G_LIKELY (nrows != box->nrows))
+    {
+      box->nrows = nrows;
+
+      if (box->childeren != NULL)
+        gtk_widget_queue_resize (GTK_WIDGET (box));
+    }
+}
+
+
+
+void
 systray_box_set_show_hidden (SystrayBox *box,
                               gboolean   show_hidden)
 {
diff --git a/plugins/systray/systray-box.h b/plugins/systray/systray-box.h
index d396344..d2853ee 100644
--- a/plugins/systray/systray-box.h
+++ b/plugins/systray/systray-box.h
@@ -51,6 +51,9 @@ gint       systray_box_get_size_max    (SystrayBox          *box);
 void       systray_box_set_size_alloc  (SystrayBox          *box,
                                         gint                 size_alloc);
 
+void       systray_box_set_nrows       (SystrayBox          *box,
+                                        gint                 nrows);
+
 void       systray_box_set_show_hidden (SystrayBox          *box,
                                         gboolean             show_hidden);
 
diff --git a/plugins/systray/systray.c b/plugins/systray/systray.c
index 154bc03..975cc3f 100644
--- a/plugins/systray/systray.c
+++ b/plugins/systray/systray.c
@@ -54,6 +54,8 @@ static void     systray_plugin_orientation_changed          (XfcePanelPlugin
                                                              GtkOrientation         orientation);
 static gboolean systray_plugin_size_changed                 (XfcePanelPlugin       *panel_plugin,
                                                              gint                   size);
+static void     systray_plugin_nrows_changed                (XfcePanelPlugin       *panel_plugin,
+                                                             guint                  nrows);
 static void     systray_plugin_configure_plugin             (XfcePanelPlugin       *panel_plugin);
 static void     systray_plugin_box_expose_event             (GtkWidget             *box,
                                                              GdkEventExpose        *event);
@@ -172,6 +174,7 @@ systray_plugin_class_init (SystrayPluginClass *klass)
   plugin_class->construct = systray_plugin_construct;
   plugin_class->free_data = systray_plugin_free_data;
   plugin_class->size_changed = systray_plugin_size_changed;
+  plugin_class->nrows_changed = systray_plugin_nrows_changed;
   plugin_class->configure_plugin = systray_plugin_configure_plugin;
   plugin_class->orientation_changed = systray_plugin_orientation_changed;
 
@@ -547,6 +550,17 @@ systray_plugin_size_changed (XfcePanelPlugin *panel_plugin,
 
 
 static void
+systray_plugin_nrows_changed (XfcePanelPlugin *panel_plugin,
+                              guint            nrows)
+{
+  SystrayPlugin *plugin = XFCE_SYSTRAY_PLUGIN (panel_plugin);
+
+  systray_box_set_nrows (XFCE_SYSTRAY_BOX (plugin->box), (gint) nrows);
+}
+
+
+
+static void
 systray_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
 {
   SystrayPlugin *plugin = XFCE_SYSTRAY_PLUGIN (panel_plugin);


More information about the Xfce4-commits mailing list