box: follow children visibility when building the sibling path
This fixes nth-child not working for widgets which were not visible before being added to the box, but it's also a better fix for https://bugzilla.gnome.org/show_bug.cgi?id=652769
This commit is contained in:
26
gtk/gtkbox.c
26
gtk/gtkbox.c
@ -847,11 +847,8 @@ count_widget_position (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
CountingData *count = data;
|
CountingData *count = data;
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* We cannot reliably detect changes in widget visibility */
|
|
||||||
if (!gtk_widget_get_visible (widget))
|
if (!gtk_widget_get_visible (widget))
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (count->widget == widget)
|
if (count->widget == widget)
|
||||||
count->found = TRUE;
|
count->found = TRUE;
|
||||||
@ -904,11 +901,9 @@ gtk_box_get_path_for_child (GtkContainer *container,
|
|||||||
|
|
||||||
for (list = children; list; list = list->next)
|
for (list = children; list; list = list->next)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
/* We cannot reliably detect changes in widget visibility */
|
|
||||||
if (!gtk_widget_get_visible (list->data))
|
if (!gtk_widget_get_visible (list->data))
|
||||||
return;
|
continue;
|
||||||
#endif
|
|
||||||
gtk_widget_path_append_for_widget (private->sibling_path, list->data);
|
gtk_widget_path_append_for_widget (private->sibling_path, list->data);
|
||||||
}
|
}
|
||||||
g_list_free (children);
|
g_list_free (children);
|
||||||
@ -949,6 +944,16 @@ gtk_box_direction_changed (GtkWidget *widget,
|
|||||||
gtk_box_invalidate_order (GTK_BOX (widget));
|
gtk_box_invalidate_order (GTK_BOX (widget));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
box_child_visibility_notify_cb (GObject *obj,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkBox *box = user_data;
|
||||||
|
|
||||||
|
gtk_box_invalidate_order (box);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_box_pack (GtkBox *box,
|
gtk_box_pack (GtkBox *box,
|
||||||
GtkWidget *child,
|
GtkWidget *child,
|
||||||
@ -978,6 +983,9 @@ gtk_box_pack (GtkBox *box,
|
|||||||
gtk_box_invalidate_order (box);
|
gtk_box_invalidate_order (box);
|
||||||
gtk_widget_set_parent (child, GTK_WIDGET (box));
|
gtk_widget_set_parent (child, GTK_WIDGET (box));
|
||||||
|
|
||||||
|
g_signal_connect (child, "notify::visible",
|
||||||
|
G_CALLBACK (box_child_visibility_notify_cb), box);
|
||||||
|
|
||||||
gtk_widget_child_notify (child, "expand");
|
gtk_widget_child_notify (child, "expand");
|
||||||
gtk_widget_child_notify (child, "fill");
|
gtk_widget_child_notify (child, "fill");
|
||||||
gtk_widget_child_notify (child, "padding");
|
gtk_widget_child_notify (child, "padding");
|
||||||
@ -1795,6 +1803,10 @@ gtk_box_remove (GtkContainer *container,
|
|||||||
was_visible = gtk_widget_get_visible (widget);
|
was_visible = gtk_widget_get_visible (widget);
|
||||||
gtk_widget_unparent (widget);
|
gtk_widget_unparent (widget);
|
||||||
|
|
||||||
|
g_signal_handlers_disconnect_by_func (widget,
|
||||||
|
box_child_visibility_notify_cb,
|
||||||
|
box);
|
||||||
|
|
||||||
priv->children = g_list_remove_link (priv->children, children);
|
priv->children = g_list_remove_link (priv->children, children);
|
||||||
g_list_free (children);
|
g_list_free (children);
|
||||||
g_free (child);
|
g_free (child);
|
||||||
|
|||||||
Reference in New Issue
Block a user