[gtk+/quartz-integration: 70/108] menubar: Compute proper size even when invisible



commit 53248b22037622b73bce4b162d8bc761de5e9da2
Author: Benjamin Otte <otte redhat com>
Date:   Sat Apr 30 05:10:55 2011 +0200

    menubar: Compute proper size even when invisible

 gtk/gtkmenubar.c |  131 ++++++++++++++++++++++++++---------------------------
 1 files changed, 64 insertions(+), 67 deletions(-)
---
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index b234b27..d790e31 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -312,74 +312,71 @@ gtk_menu_bar_size_request (GtkWidget      *widget,
   requisition->width = 0;
   requisition->height = 0;
   
-  if (gtk_widget_get_visible (widget))
-    {
-      menu_bar = GTK_MENU_BAR (widget);
-      menu_shell = GTK_MENU_SHELL (widget);
-      priv = menu_bar->priv;
+  menu_bar = GTK_MENU_BAR (widget);
+  menu_shell = GTK_MENU_SHELL (widget);
+  priv = menu_bar->priv;
 
-      nchildren = 0;
-      children = menu_shell->priv->children;
+  nchildren = 0;
+  children = menu_shell->priv->children;
 
-      while (children)
-	{
-	  child = children->data;
-	  children = children->next;
+  while (children)
+    {
+      child = children->data;
+      children = children->next;
 
-	  if (gtk_widget_get_visible (child))
-	    {
-              gint toggle_size;
+      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);
+          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 (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 (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
-		  priv->pack_direction == GTK_PACK_DIRECTION_RTL)
-		{
-		  requisition->width += child_requisition.width;
-		  requisition->height = MAX (requisition->height, child_requisition.height);
-		}
-	      else
-		{
-		  requisition->width = MAX (requisition->width, child_requisition.width);
-		  requisition->height += child_requisition.height;
-		}
-	      nchildren += 1;
-	    }
-	}
+          if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
+              priv->pack_direction == GTK_PACK_DIRECTION_RTL)
+            {
+              requisition->width += child_requisition.width;
+              requisition->height = MAX (requisition->height, child_requisition.height);
+            }
+          else
+            {
+              requisition->width = MAX (requisition->width, child_requisition.width);
+              requisition->height += child_requisition.height;
+            }
+          nchildren += 1;
+        }
+    }
 
-      gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
+  gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
 
-      border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
-      requisition->width += (border_width +
-                             ipadding + 
-			     BORDER_SPACING) * 2;
-      requisition->height += (border_width +
-                              ipadding +
-			      BORDER_SPACING) * 2;
+  border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
+  requisition->width += (border_width +
+                         ipadding + 
+                         BORDER_SPACING) * 2;
+  requisition->height += (border_width +
+                          ipadding +
+                          BORDER_SPACING) * 2;
 
-      if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
-	{
-          GtkStyleContext *context;
-          GtkBorder *border;
+  if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
+    {
+      GtkStyleContext *context;
+      GtkBorder *border;
 
-          context = gtk_widget_get_style_context (widget);
+      context = gtk_widget_get_style_context (widget);
 
-          gtk_style_context_get (context, 0,
-                                 "border-width", &border,
-                                 NULL);
+      gtk_style_context_get (context, 0,
+                             "border-width", &border,
+                             NULL);
 
-	  requisition->width += border->left + border->right;
-	  requisition->height += border->top + border->bottom;
-          gtk_border_free (border);
-	}
+      requisition->width += border->left + border->right;
+      requisition->height += border->top + border->bottom;
+      gtk_border_free (border);
     }
 }
 



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