diff options
author | Benjamin Otte <otte@redhat.com> | 2011-04-30 06:24:51 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2011-05-01 04:44:56 +0200 |
commit | 923fcaa9283e4203a22c65ec48d8a5f499cc78d5 (patch) | |
tree | 0fda70cafb14ccc04149e842115aa97f1d3ea846 /gtk/gtkmenubar.c | |
parent | 5aac83bf08215164f8d7569c9eeb0aed14b7788f (diff) | |
download | gtk+-923fcaa9283e4203a22c65ec48d8a5f499cc78d5.tar.gz |
menubar: Only compute the necessary size
There's no need to compute height when we're only interested in width
Diffstat (limited to 'gtk/gtkmenubar.c')
-rw-r--r-- | gtk/gtkmenubar.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index b456cf418e..da116d4833 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -302,14 +302,11 @@ gtk_menu_bar_size_request (GtkWidget *widget, GtkWidget *child; GList *children; GtkRequisition child_requisition; - GtkRequisition requisition; gint ipadding; guint border_width; gboolean use_toggle_size; + gint size = 0; - requisition.width = 0; - requisition.height = 0; - menu_bar = GTK_MENU_BAR (widget); menu_shell = GTK_MENU_SHELL (widget); priv = menu_bar->priv; @@ -345,13 +342,17 @@ gtk_menu_bar_size_request (GtkWidget *widget, 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); + if (orientation == GTK_ORIENTATION_HORIZONTAL) + size += child_requisition.width; + else + size = MAX (size, child_requisition.height); } else { - requisition.width = MAX (requisition.width, child_requisition.width); - requisition.height += child_requisition.height; + if (orientation == GTK_ORIENTATION_HORIZONTAL) + size = MAX (size, child_requisition.width); + else + size += child_requisition.height; } } } @@ -359,12 +360,7 @@ gtk_menu_bar_size_request (GtkWidget *widget, 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; + size += (border_width + ipadding + BORDER_SPACING) * 2; if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE) { @@ -377,15 +373,14 @@ gtk_menu_bar_size_request (GtkWidget *widget, "border-width", &border, NULL); - requisition.width += border->left + border->right; - requisition.height += border->top + border->bottom; + if (orientation == GTK_ORIENTATION_HORIZONTAL) + size += border->left + border->right; + else + size += border->top + border->bottom; gtk_border_free (border); } - if (orientation == GTK_ORIENTATION_HORIZONTAL) - *minimum = *natural = requisition.width; - else - *minimum = *natural = requisition.height; + *minimum = *natural = size; } static void |