[gtk+] menubar: compute in advance wether to add toggle size



commit 5aac83bf08215164f8d7569c9eeb0aed14b7788f
Author: Benjamin Otte <otte redhat com>
Date:   Sat Apr 30 06:16:18 2011 +0200

    menubar: compute in advance wether to add toggle size

 gtk/gtkmenubar.c |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index e42cd9b..b456cf4 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -305,6 +305,7 @@ gtk_menu_bar_size_request (GtkWidget      *widget,
   GtkRequisition requisition;
   gint ipadding;
   guint border_width;
+  gboolean use_toggle_size;
 
   requisition.width = 0;
   requisition.height = 0;
@@ -315,6 +316,12 @@ gtk_menu_bar_size_request (GtkWidget      *widget,
 
   children = menu_shell->priv->children;
 
+  if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
+      priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
+    use_toggle_size = (orientation == GTK_ORIENTATION_HORIZONTAL);
+  else
+    use_toggle_size = (orientation == GTK_ORIENTATION_VERTICAL);
+
   while (children)
     {
       child = children->data;
@@ -322,17 +329,18 @@ gtk_menu_bar_size_request (GtkWidget      *widget,
 
       if (gtk_widget_get_visible (child))
         {
-          gint toggle_size;
-
           gtk_widget_get_preferred_size (child, &child_requisition, NULL);
-          gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
-                                             &toggle_size);
 
-          if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
-              priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
-            child_requisition.width += toggle_size;
-          else
-            child_requisition.height += toggle_size;
+          if (use_toggle_size)
+            {
+              gint toggle_size;
+
+              gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
+                                                 &toggle_size);
+
+              child_requisition.width += toggle_size;
+              child_requisition.height += toggle_size;
+            }
 
           if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
               priv->pack_direction == GTK_PACK_DIRECTION_RTL)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]