[Xfce4-commits] <xfce4-panel:andrzejr/deskbar-github> plugin applicationsmenu: improved sizing and layout.

Andrzej noreply at xfce.org
Mon Dec 12 11:40:49 CET 2011


Updating branch refs/heads/andrzejr/deskbar-github
         to 762683f79f2096946b748070701faf76691f998b (commit)
       from 130b2387f73732a4b64fe7f7ce9cc8f5b3005425 (commit)

commit 762683f79f2096946b748070701faf76691f998b
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Mon Dec 5 23:09:32 2011 +0900

    plugin applicationsmenu: improved sizing and layout.

 plugins/applicationsmenu/applicationsmenu.c |   45 ++++++++++++++++----------
 1 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/plugins/applicationsmenu/applicationsmenu.c b/plugins/applicationsmenu/applicationsmenu.c
index 560fcd6..f5aa8f3 100644
--- a/plugins/applicationsmenu/applicationsmenu.c
+++ b/plugins/applicationsmenu/applicationsmenu.c
@@ -349,6 +349,8 @@ applications_menu_plugin_set_property (GObject      *object,
           plugin->button_title != NULL ? plugin->button_title : "");
       gtk_widget_set_tooltip_text (plugin->button,
           exo_str_is_empty (plugin->button_title) ? NULL : plugin->button_title);
+      applications_menu_plugin_size_changed (XFCE_PANEL_PLUGIN (plugin),
+          xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (plugin)));
       return;
 
     case PROP_BUTTON_ICON:
@@ -430,6 +432,8 @@ applications_menu_plugin_size_changed (XfcePanelPlugin *panel_plugin,
   GtkStyle               *style;
   gint                    plugin_size;
   gint                    plugin_nrows;
+  GtkOrientation          orientation;
+  GtkRequisition          label_size;
 
   plugin_size = xfce_panel_plugin_get_size (panel_plugin);
   plugin_nrows = (gint) xfce_panel_plugin_get_nrows (panel_plugin);
@@ -437,23 +441,28 @@ applications_menu_plugin_size_changed (XfcePanelPlugin *panel_plugin,
   if (size > 2 * plugin_size / plugin_nrows)
     size = 2 * plugin_size / plugin_nrows;
 
-  gtk_box_set_child_packing (GTK_BOX (plugin->box), plugin->icon,
-                             !plugin->show_button_title, !plugin->show_button_title,
-                             0, GTK_PACK_START);
+  style = gtk_widget_get_style (plugin->button);
+  icon_size = size - 2 * MAX (style->xthickness, style->ythickness);
 
-  if (!plugin->show_button_title)
-    {
-      xfce_panel_image_set_size (XFCE_PANEL_IMAGE (plugin->icon), -1);
-      gtk_widget_set_size_request (GTK_WIDGET (panel_plugin), size, size);
-    }
-  else
+  xfce_panel_image_set_size (XFCE_PANEL_IMAGE (plugin->icon), icon_size);
+
+  orientation = xfce_panel_plugin_get_orientation (panel_plugin);
+
+  /* deskbar mode & button title */
+  if (plugin->show_button_title &&
+      xfce_panel_plugin_get_deskbar_mode (panel_plugin) &&
+      orientation == GTK_ORIENTATION_VERTICAL)
     {
-      style = gtk_widget_get_style (plugin->button);
-      icon_size = size - 2 * MAX (style->xthickness, style->ythickness);
-      xfce_panel_image_set_size (XFCE_PANEL_IMAGE (plugin->icon), icon_size);
-      gtk_widget_set_size_request (GTK_WIDGET (panel_plugin), -1, -1);
-    }
+      gtk_widget_size_request(GTK_WIDGET (plugin->label), &label_size);
 
+      /* the title fits next to the icon */
+      if (label_size.width <= plugin_size - size - MAX (style->xthickness, style->ythickness))
+        {
+          orientation = GTK_ORIENTATION_HORIZONTAL;
+        }
+    }
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (plugin->box),
+                                  orientation);
   return TRUE;
 }
 
@@ -468,7 +477,8 @@ applications_menu_plugin_orientation_changed (XfcePanelPlugin *panel_plugin,
   if (xfce_panel_plugin_get_deskbar_mode (panel_plugin))
     orientation = GTK_ORIENTATION_HORIZONTAL;
 
-  xfce_hvbox_set_orientation (XFCE_HVBOX (plugin->box), orientation);
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (plugin->box),
+                                  orientation);
   if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       gtk_box_reorder_child (GTK_BOX (plugin->box), plugin->icon, 0);
@@ -479,6 +489,8 @@ applications_menu_plugin_orientation_changed (XfcePanelPlugin *panel_plugin,
       gtk_box_reorder_child (GTK_BOX (plugin->box), plugin->icon, -1);
       gtk_label_set_angle (GTK_LABEL (plugin->label), 90);
     }
+  applications_menu_plugin_size_changed (panel_plugin,
+                                         xfce_panel_plugin_get_size (panel_plugin));
 }
 
 
@@ -486,8 +498,7 @@ static void
 applications_menu_plugin_deskbar_mode_changed (XfcePanelPlugin        *panel_plugin,
                                                gboolean                deskbar_mode)
 {
-  applications_menu_plugin_orientation_changed (
-                                                panel_plugin,
+  applications_menu_plugin_orientation_changed (panel_plugin,
                                                 xfce_panel_plugin_get_orientation (panel_plugin));
 }
 


More information about the Xfce4-commits mailing list