From 847a43c4311c1952a5027381521120e3a817ee04 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 24 Jun 2016 12:16:40 -0400 Subject: [PATCH] headerbar: compute nominal size of sides up front In order to support the expand property on children, we're going to need to look at the size of the packed children on each side of the title widget, up front, before allocating them (to compute how much extra allocation each expanded child gets). This commit lays the groundwork for that analysis by splitting the size calculation of each side of the header bar outside of the loop that allocates each child of the header bar. https://bugzilla.gnome.org/show_bug.cgi?id=724332 --- gtk/gtkheaderbar.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c index eba695b8ab..031199b2a7 100644 --- a/gtk/gtkheaderbar.c +++ b/gtk/gtkheaderbar.c @@ -1074,7 +1074,28 @@ gtk_header_bar_allocate_contents (GtkCssGadget *gadget, width = gtk_distribute_natural_allocation (MAX (0, width), nvis_children, sizes); - side[0] = side[1] = 0; + /* compute the nominal size of the children filling up each side of + * the title in titlebar + */ + side[0] = start_width; + side[1] = end_width; + for (packing = GTK_PACK_START; packing <= GTK_PACK_END; packing++) + { + i = 0; + for (l = priv->children; l != NULL; l = l->next) + { + child = l->data; + if (!gtk_widget_get_visible (child->widget)) + continue; + + if (child->pack_type == packing) + side[packing] += sizes[i].minimum_size + priv->spacing; + + i++; + } + } + + /* allocate the children on both sides of the title */ for (packing = GTK_PACK_START; packing <= GTK_PACK_END; packing++) { child_allocation.y = allocation->y; @@ -1111,8 +1132,6 @@ gtk_header_bar_allocate_contents (GtkCssGadget *gadget, x -= priv->spacing; } - side[packing] += child_size + priv->spacing; - if (direction == GTK_TEXT_DIR_RTL) child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; @@ -1123,9 +1142,6 @@ gtk_header_bar_allocate_contents (GtkCssGadget *gadget, } } - side[0] += start_width; - side[1] += end_width; - /* We don't enforce css borders on the center widget, to make * title/subtitle combinations fit without growing the header */