Commit 1e4369e8 authored by Matthias Clasen's avatar Matthias Clasen

box: Convert to gtk_container_child_notify_by_pspec

For the same reasons as g_object_child_notify_by_pspec.
parent 93f8f12e
......@@ -106,7 +106,8 @@ enum {
CHILD_PROP_FILL,
CHILD_PROP_PADDING,
CHILD_PROP_PACK_TYPE,
CHILD_PROP_POSITION
CHILD_PROP_POSITION,
LAST_CHILD_PROP
};
typedef struct _GtkBoxChild GtkBoxChild;
......@@ -126,6 +127,7 @@ struct _GtkBoxPrivate
};
static GParamSpec *props[LAST_PROP] = { NULL, };
static GParamSpec *child_props[LAST_CHILD_PROP] = { NULL, };
/*
* GtkBoxChild:
......@@ -292,13 +294,12 @@ gtk_box_class_init (GtkBoxClass *class)
* 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,
g_param_spec_boolean ("expand",
P_("Expand"),
P_("Whether the child should receive extra space when the parent grows"),
FALSE,
GTK_PARAM_READWRITE));
child_props[CHILD_PROP_EXPAND] =
g_param_spec_boolean ("expand",
P_("Expand"),
P_("Whether the child should receive extra space when the parent grows"),
FALSE,
GTK_PARAM_READWRITE);
/**
* GtkBox:fill:
......@@ -309,35 +310,37 @@ gtk_box_class_init (GtkBoxClass *class)
* and #GtkWidget:vexpand properties are the preferred way to influence
* child size allocation in containers.
*/
gtk_container_class_install_child_property (container_class,
CHILD_PROP_FILL,
g_param_spec_boolean ("fill",
P_("Fill"),
P_("Whether extra space given to the child should be allocated to the child or used as padding"),
TRUE,
GTK_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_PADDING,
g_param_spec_uint ("padding",
P_("Padding"),
P_("Extra space to put between the child and its neighbors, in pixels"),
0, G_MAXINT, 0,
GTK_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_PACK_TYPE,
g_param_spec_enum ("pack-type",
P_("Pack type"),
P_("A GtkPackType indicating whether the child is packed with reference to the start or end of the parent"),
GTK_TYPE_PACK_TYPE, GTK_PACK_START,
GTK_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_POSITION,
g_param_spec_int ("position",
P_("Position"),
P_("The index of the child in the parent"),
-1, G_MAXINT, 0,
GTK_PARAM_READWRITE));
child_props[CHILD_PROP_FILL] =
g_param_spec_boolean ("fill",
P_("Fill"),
P_("Whether extra space given to the child should be allocated to the child or used as padding"),
TRUE,
GTK_PARAM_READWRITE);
child_props[CHILD_PROP_PADDING] =
g_param_spec_uint ("padding",
P_("Padding"),
P_("Extra space to put between the child and its neighbors, in pixels"),
0, G_MAXINT,
0,
GTK_PARAM_READWRITE);
child_props[CHILD_PROP_PACK_TYPE] =
g_param_spec_enum ("pack-type",
P_("Pack type"),
P_("A GtkPackType indicating whether the child is packed with reference to the start or end of the parent"),
GTK_TYPE_PACK_TYPE, GTK_PACK_START,
GTK_PARAM_READWRITE);
child_props[CHILD_PROP_POSITION] =
g_param_spec_int ("position",
P_("Position"),
P_("The index of the child in the parent"),
-1, G_MAXINT,
0,
GTK_PARAM_READWRITE);
gtk_container_class_install_child_properties (container_class, LAST_CHILD_PROP, child_props);
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_FILLER);
}
......@@ -1495,6 +1498,7 @@ gtk_box_pack (GtkBox *box,
guint padding,
GtkPackType pack_type)
{
GtkContainer *container = GTK_CONTAINER (box);
GtkBoxPrivate *private = box->priv;
GtkBoxChild *child_info;
......@@ -1519,11 +1523,12 @@ gtk_box_pack (GtkBox *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, "fill");
gtk_widget_child_notify (child, "padding");
gtk_widget_child_notify (child, "pack-type");
gtk_widget_child_notify (child, "position");
gtk_container_child_notify_by_pspec (container, child, child_props[CHILD_PROP_EXPAND]);
gtk_container_child_notify_by_pspec (container, child, child_props[CHILD_PROP_FILL]);
gtk_container_child_notify_by_pspec (container, child, child_props[CHILD_PROP_PADDING]);
gtk_container_child_notify_by_pspec (container, child, child_props[CHILD_PROP_PACK_TYPE]);
gtk_container_child_notify_by_pspec (container, child, child_props[CHILD_PROP_POSITION]);
gtk_widget_thaw_child_notify (child);
return child_info;
......@@ -2346,7 +2351,7 @@ gtk_box_reorder_child (GtkBox *box,
priv->children = g_list_insert_before (priv->children, new_link, child_info);
gtk_widget_child_notify (child, "position");
gtk_container_child_notify_by_pspec (GTK_CONTAINER (box), child, child_props[CHILD_PROP_POSITION]);
if (_gtk_widget_get_visible (child) &&
_gtk_widget_get_visible (GTK_WIDGET (box)))
{
......@@ -2462,19 +2467,19 @@ gtk_box_set_child_packing (GtkBox *box,
{
child_info->expand = expand != FALSE;
gtk_widget_queue_compute_expand (GTK_WIDGET (box));
gtk_widget_child_notify (child, "expand");
gtk_container_child_notify_by_pspec (GTK_CONTAINER (box), child, child_props[CHILD_PROP_EXPAND]);
}
child_info->fill = fill != FALSE;
gtk_widget_child_notify (child, "fill");
gtk_container_child_notify_by_pspec (GTK_CONTAINER (box), child, child_props[CHILD_PROP_FILL]);
child_info->padding = padding;
gtk_widget_child_notify (child, "padding");
gtk_container_child_notify_by_pspec (GTK_CONTAINER (box), child, child_props[CHILD_PROP_PADDING]);
if (pack_type != GTK_PACK_END)
pack_type = GTK_PACK_START;
if (child_info->pack != pack_type)
{
child_info->pack = pack_type;
gtk_widget_child_notify (child, "pack-type");
gtk_container_child_notify_by_pspec (GTK_CONTAINER (box), child, child_props[CHILD_PROP_PACK_TYPE]);
gtk_box_invalidate_order (box);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment