gtktable: don't try to propagate expand related child props in compute_expand()

It tried to set the expand state if either xexpand/yexpand where true.
Due to a missing queue_compute_expand when adding a child it actually
only computed the expand state in case a child queued after being added
or in case a child had the expand property set (see optimization in
gtk_widget_set_parent)

In my case this broke layouts as a child of GtkCombBox started setting
an exand flag with 3.20 which queued a compute_expand, which in turn
propagated an expand child props set for a cell in the same table up
and overrode the expand child prop of a parent GtkBox.

This removes the custom compute_expand implementation to match the
behaviour of GtkBox (don't propagate child prop expand flags
but let child expand flags override the child props) and not get random
expand behaviour depending on whether and when child widgets set their
expand state.

https://bugzilla.gnome.org/show_bug.cgi?id=769162
This commit is contained in:
Christoph Reiter 2016-07-26 12:37:55 +02:00 committed by Matthias Clasen
parent e4c072fc11
commit a72f1c76c8

View File

@ -114,9 +114,6 @@ static void gtk_table_get_preferred_height (GtkWidget *widget,
gint *natural);
static void gtk_table_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_table_compute_expand (GtkWidget *widget,
gboolean *hexpand,
gboolean *vexpand);
static void gtk_table_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_table_remove (GtkContainer *container,
@ -173,7 +170,6 @@ gtk_table_class_init (GtkTableClass *class)
widget_class->get_preferred_width = gtk_table_get_preferred_width;
widget_class->get_preferred_height = gtk_table_get_preferred_height;
widget_class->size_allocate = gtk_table_size_allocate;
widget_class->compute_expand = gtk_table_compute_expand;
container_class->add = gtk_table_add;
container_class->remove = gtk_table_remove;
@ -285,43 +281,6 @@ gtk_table_class_init (GtkTableClass *class)
GTK_PARAM_READWRITE));
}
static void
gtk_table_compute_expand (GtkWidget *widget,
gboolean *hexpand_p,
gboolean *vexpand_p)
{
GtkTable *table = GTK_TABLE (widget);
GtkTablePrivate *priv = table->priv;
GList *list;
GtkTableChild *child;
gboolean hexpand;
gboolean vexpand;
hexpand = FALSE;
vexpand = FALSE;
for (list = priv->children; list; list = list->next)
{
child = list->data;
if (!hexpand)
hexpand = child->xexpand ||
gtk_widget_compute_expand (child->widget,
GTK_ORIENTATION_HORIZONTAL);
if (!vexpand)
vexpand = child->yexpand ||
gtk_widget_compute_expand (child->widget,
GTK_ORIENTATION_VERTICAL);
if (hexpand && vexpand)
break;
}
*hexpand_p = hexpand;
*vexpand_p = vexpand;
}
static GType
gtk_table_child_type (GtkContainer *container)
{
@ -450,32 +409,14 @@ gtk_table_set_child_property (GtkContainer *container,
break;
case CHILD_PROP_X_OPTIONS:
{
gboolean xexpand;
xexpand = (g_value_get_flags (value) & GTK_EXPAND) != 0;
if (table_child->xexpand != xexpand)
{
table_child->xexpand = xexpand;
gtk_widget_queue_compute_expand (GTK_WIDGET (table));
}
table_child->xexpand = (g_value_get_flags (value) & GTK_EXPAND) != 0;
table_child->xshrink = (g_value_get_flags (value) & GTK_SHRINK) != 0;
table_child->xfill = (g_value_get_flags (value) & GTK_FILL) != 0;
}
break;
case CHILD_PROP_Y_OPTIONS:
{
gboolean yexpand;
yexpand = (g_value_get_flags (value) & GTK_EXPAND) != 0;
if (table_child->yexpand != yexpand)
{
table_child->yexpand = yexpand;
gtk_widget_queue_compute_expand (GTK_WIDGET (table));
}
table_child->yexpand = (g_value_get_flags (value) & GTK_EXPAND) != 0;
table_child->yshrink = (g_value_get_flags (value) & GTK_SHRINK) != 0;
table_child->yfill = (g_value_get_flags (value) & GTK_FILL) != 0;
}