[gtk+] GtkBox: don't propagate the expand child property



commit 80513aa2c7ed4aecc235723ea6c6f044cf98ba1d
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat May 25 14:04:36 2013 -0400

    GtkBox: don't propagate the expand child property
    
    The intention of the expand widget flags was to in fact propagate
    legacy expand child properties as well. Due to implementation errors,
    this was only happening in some cases, but not in others. To avoid
    breaking old code assuming traditional expand flag behavior, this
    commit removes all attempts to propagate GtkBox::expand.
    
    This was discussed in
    https://bugzilla.gnome.org/show_bug.cgi?id=698656 and
    https://bugzilla.gnome.org/show_bug.cgi?id=628902
    
    This patch was written by Tristan Van Berkom.

 README.in    |    7 +++++++
 gtk/gtkbox.c |   54 +++---------------------------------------------------
 2 files changed, 10 insertions(+), 51 deletions(-)
---
diff --git a/README.in b/README.in
index 8511064..c002e11 100644
--- a/README.in
+++ b/README.in
@@ -81,6 +81,13 @@ Release notes for 3.10
   setups (not multi-monitor!) are very rare nowadays. If you really
   need multiple X screens, open them as separate displays.
 
+* The behavior of GtkBox::expand has been changed to never propagate
+  up. Previously, this was happening inconsistently. If you want the
+  expand to propagate, use the GtkWidget h/v expand properties.
+  If you experience sizing problems with widgets in ported code,
+  carefully check the expand and fill flags of your boxes.
+
+
 Release notes for 3.8
 =====================
 
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index e60fb4f..94e8907 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -150,9 +150,6 @@ struct _GtkBoxChild
 static void gtk_box_size_allocate         (GtkWidget              *widget,
                                            GtkAllocation          *allocation);
 
-static void gtk_box_compute_expand     (GtkWidget      *widget,
-                                        gboolean       *hexpand,
-                                        gboolean       *vexpand);
 static void gtk_box_direction_changed  (GtkWidget        *widget,
                                         GtkTextDirection  previous_direction);
 
@@ -230,7 +227,6 @@ gtk_box_class_init (GtkBoxClass *class)
   widget_class->get_preferred_height_for_width = gtk_box_get_preferred_height_for_width;
   widget_class->get_preferred_height_and_baseline_for_width = 
gtk_box_get_preferred_height_and_baseline_for_width;
   widget_class->get_preferred_width_for_height = gtk_box_get_preferred_width_for_height;
-  widget_class->compute_expand                 = gtk_box_compute_expand;
   widget_class->direction_changed              = gtk_box_direction_changed;
 
   container_class->add = gtk_box_add;
@@ -285,6 +281,9 @@ gtk_box_class_init (GtkBoxClass *class)
    * Note that the #GtkWidget:halign, #GtkWidget:valign, #GtkWidget:hexpand
    * and #GtkWidget:vexpand properties are the preferred way to influence
    * child size allocation in containers.
+   *
+   * In contrast to #GtkWidget::hexpand, the expand child property does
+   * not cause the box to expand itself.
    */
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_EXPAND,
@@ -779,53 +778,6 @@ gtk_box_size_allocate (GtkWidget     *widget,
     }
 }
 
-static void
-gtk_box_compute_expand (GtkWidget      *widget,
-                        gboolean       *hexpand_p,
-                        gboolean       *vexpand_p)
-{
-  GtkBoxPrivate  *private = GTK_BOX (widget)->priv;
-  GList       *children;
-  GtkBoxChild *child;
-  gboolean our_expand;
-  gboolean opposite_expand;
-  GtkOrientation opposite_orientation;
-
-  opposite_orientation = OPPOSITE_ORIENTATION (private->orientation);
-
-  our_expand = FALSE;
-  opposite_expand = FALSE;
-
-  for (children = private->children; children; children = children->next)
-    {
-      child = children->data;
-
-      /* we don't recurse into children anymore as soon as we know
-       * expand=TRUE in an orientation
-       */
-
-      if (child->expand || (!our_expand && gtk_widget_compute_expand (child->widget, private->orientation)))
-        our_expand = TRUE;
-
-      if (!opposite_expand && gtk_widget_compute_expand (child->widget, opposite_orientation))
-        opposite_expand = TRUE;
-
-      if (our_expand && opposite_expand)
-        break;
-    }
-
-  if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
-    {
-      *hexpand_p = our_expand;
-      *vexpand_p = opposite_expand;
-    }
-  else
-    {
-      *hexpand_p = opposite_expand;
-      *vexpand_p = our_expand;
-    }
-}
-
 static GType
 gtk_box_child_type (GtkContainer   *container)
 {


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