[Xfce4-commits] <xfce4-panel:nick/gtk3> ApplicationsMenu: button layout fixes.

Andrzej noreply at xfce.org
Wed Apr 17 22:38:01 CEST 2013


Updating branch refs/heads/nick/gtk3
         to 4d61a000fc680b8b0b57c20699cd2636ca33ac46 (commit)
       from ecffe289ffb0a4718589e58184af452c9792a667 (commit)

commit 4d61a000fc680b8b0b57c20699cd2636ca33ac46
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Wed Apr 17 21:36:48 2013 +0100

    ApplicationsMenu: button layout fixes.

 plugins/applicationsmenu/applicationsmenu.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/plugins/applicationsmenu/applicationsmenu.c b/plugins/applicationsmenu/applicationsmenu.c
index 70d9090..e94753c 100644
--- a/plugins/applicationsmenu/applicationsmenu.c
+++ b/plugins/applicationsmenu/applicationsmenu.c
@@ -442,7 +442,6 @@ applications_menu_plugin_size_changed (XfcePanelPlugin *panel_plugin,
 {
   ApplicationsMenuPlugin *plugin = XFCE_APPLICATIONS_MENU_PLUGIN (panel_plugin);
   gint                    row_size;
-  GtkStyle               *style;
   XfcePanelPluginMode     mode;
   GtkRequisition          label_size;
   GtkOrientation          orientation;
@@ -453,6 +452,8 @@ applications_menu_plugin_size_changed (XfcePanelPlugin *panel_plugin,
   GdkScreen              *screen;
   GtkIconTheme           *icon_theme = NULL;
   gchar                  *icon_name;
+  GtkStyleContext        *ctx;
+  GtkBorder               padding, border;
 
   gtk_box_set_child_packing (GTK_BOX (plugin->box), plugin->icon,
                              !plugin->show_button_title,
@@ -467,13 +468,16 @@ applications_menu_plugin_size_changed (XfcePanelPlugin *panel_plugin,
     orientation = GTK_ORIENTATION_VERTICAL;
 
   row_size = size / xfce_panel_plugin_get_nrows (panel_plugin);
-  style = gtk_widget_get_style (plugin->button);
-  border_thickness = 2 * MAX (style->xthickness, style->ythickness) + 2;
+  /* style thickness */
+  ctx = gtk_widget_get_style_context (plugin->button);
+  gtk_style_context_get_padding (ctx, gtk_widget_get_state_flags (plugin->button), &padding);
+  gtk_style_context_get_border (ctx, gtk_widget_get_state_flags (plugin->button), &border);
+  border_thickness = MAX (padding.left + padding.right + border.left + border.right,
+                          padding.top + padding.bottom + border.top + border.bottom);
 
   /* arbitrary limit on non-square icon width in horizontal panel */
   icon_width_max = (mode == XFCE_PANEL_PLUGIN_MODE_HORIZONTAL) ?
-    6 * row_size - border_thickness :
-    size - border_thickness;
+    6 * row_size - border_thickness : size - border_thickness;
   icon_height_max = row_size - border_thickness;
 
   screen = gtk_widget_get_screen (GTK_WIDGET (plugin));
@@ -500,7 +504,7 @@ applications_menu_plugin_size_changed (XfcePanelPlugin *panel_plugin,
     {
       /* check if the label (minimum size) fits next to the icon */
       gtk_widget_get_preferred_size (GTK_WIDGET (plugin->label), &label_size, NULL);
-      if (label_size.width <= size - border_thickness - icon_width)
+      if (label_size.width <= size - icon_width - 2 - border_thickness)
         orientation = GTK_ORIENTATION_HORIZONTAL;
     }
 


More information about the Xfce4-commits mailing list