[gtk+/wip/csoriano/pathbar-bin-view-window: 49/65] gtkhidingbox: take into account child expand property



commit a5366f40f9ae72a81a9066d7ccf549e117e41b36
Author: Carlos Soriano <csoriano gnome org>
Date:   Wed Nov 4 16:59:26 2015 +0100

    gtkhidingbox: take into account child expand property

 gtk/gtkhidingbox.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkhidingbox.c b/gtk/gtkhidingbox.c
index ddf5901..df1013a 100644
--- a/gtk/gtkhidingbox.c
+++ b/gtk/gtkhidingbox.c
@@ -176,6 +176,7 @@ gtk_hiding_box_size_allocate (GtkWidget     *widget,
   gint spacing = priv->spacing;
   gint children_size;
   gint n_visible_children;
+  gint n_visible_children_expanding = 0;
   GtkAllocation clip, child_clip;
 
   gtk_widget_set_allocation (widget, allocation);
@@ -226,6 +227,8 @@ gtk_hiding_box_size_allocate (GtkWidget     *widget,
       size -= sizes[i].minimum_size;
       sizes[i].data = child_widget;
 
+      if (gtk_widget_get_hexpand (child_widget))
+        n_visible_children_expanding++;
       i++;
     }
   n_visible_children = i;
@@ -237,7 +240,7 @@ gtk_hiding_box_size_allocate (GtkWidget     *widget,
 
   if (n_visible_children > 1)
     {
-      extra = size / n_visible_children;
+      extra = size / MAX (1, n_visible_children_expanding);
       n_extra_widgets = size % n_visible_children;
     }
 
@@ -258,7 +261,11 @@ gtk_hiding_box_size_allocate (GtkWidget     *widget,
 
       child_allocation.x = x;
       child_allocation.y = allocation->y;
-      child_allocation.width = sizes[i].minimum_size + extra;
+      if (gtk_widget_get_hexpand (child_widget))
+        child_allocation.width = sizes[i].minimum_size + extra;
+      else
+        child_allocation.width = sizes[i].minimum_size;
+
       child_allocation.height = allocation->height;
       if (n_extra_widgets)
         {


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