mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
st/bin: Use class handlers for ::child-{added,removed}
Now these signals are directly on ClutterActor, we can use class handlers instead Note we don't make the same change to StScrollView as it would clash with the internal children. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3014>
This commit is contained in:
parent
552f1456eb
commit
0204920d8c
1 changed files with 43 additions and 43 deletions
|
|
@ -176,6 +176,47 @@ st_bin_get_preferred_height (ClutterActor *self,
|
|||
st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
|
||||
}
|
||||
|
||||
static void
|
||||
set_child (StBin *bin, ClutterActor *child)
|
||||
{
|
||||
StBinPrivate *priv = st_bin_get_instance_private (bin);
|
||||
|
||||
if (!g_set_weak_pointer (&priv->child, child))
|
||||
return;
|
||||
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (bin));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (bin), props[PROP_CHILD]);
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_child_added (ClutterActor *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
StBin *bin = ST_BIN (container);
|
||||
StBinPrivate *priv = st_bin_get_instance_private (bin);
|
||||
|
||||
if (priv->child)
|
||||
g_warning ("Attempting to add an actor of type %s to "
|
||||
"an StBin, but the bin already contains a %s. "
|
||||
"Was add_child() used repeatedly?",
|
||||
G_OBJECT_TYPE_NAME (actor),
|
||||
G_OBJECT_TYPE_NAME (priv->child));
|
||||
|
||||
set_child (ST_BIN (container), actor);
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_child_removed (ClutterActor *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
StBin *bin = ST_BIN (container);
|
||||
StBinPrivate *priv = st_bin_get_instance_private (bin);
|
||||
|
||||
if (priv->child == actor)
|
||||
set_child (bin, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_popup_menu (StWidget *widget)
|
||||
{
|
||||
|
|
@ -266,6 +307,8 @@ st_bin_class_init (StBinClass *klass)
|
|||
actor_class->get_preferred_width = st_bin_get_preferred_width;
|
||||
actor_class->get_preferred_height = st_bin_get_preferred_height;
|
||||
actor_class->allocate = st_bin_allocate;
|
||||
actor_class->child_added = st_bin_child_added;
|
||||
actor_class->child_removed = st_bin_child_removed;
|
||||
|
||||
widget_class->popup_menu = st_bin_popup_menu;
|
||||
widget_class->navigate_focus = st_bin_navigate_focus;
|
||||
|
|
@ -285,52 +328,9 @@ st_bin_class_init (StBinClass *klass)
|
|||
g_object_class_install_properties (gobject_class, N_PROPS, props);
|
||||
}
|
||||
|
||||
static void
|
||||
set_child (StBin *bin, ClutterActor *child)
|
||||
{
|
||||
StBinPrivate *priv = st_bin_get_instance_private (bin);
|
||||
|
||||
if (!g_set_weak_pointer (&priv->child, child))
|
||||
return;
|
||||
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (bin));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (bin), props[PROP_CHILD]);
|
||||
}
|
||||
|
||||
static void
|
||||
actor_added (ClutterActor *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
StBin *bin = ST_BIN (container);
|
||||
StBinPrivate *priv = st_bin_get_instance_private (bin);
|
||||
|
||||
if (priv->child)
|
||||
g_warning ("Attempting to add an actor of type %s to "
|
||||
"an StBin, but the bin already contains a %s. "
|
||||
"Was add_child() used repeatedly?",
|
||||
G_OBJECT_TYPE_NAME (actor),
|
||||
G_OBJECT_TYPE_NAME (priv->child));
|
||||
|
||||
set_child (ST_BIN (container), actor);
|
||||
}
|
||||
|
||||
static void
|
||||
actor_removed (ClutterActor *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
StBin *bin = ST_BIN (container);
|
||||
StBinPrivate *priv = st_bin_get_instance_private (bin);
|
||||
|
||||
if (priv->child == actor)
|
||||
set_child (bin, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
st_bin_init (StBin *bin)
|
||||
{
|
||||
g_signal_connect (bin, "actor-added", G_CALLBACK (actor_added), NULL);
|
||||
g_signal_connect (bin, "actor-removed", G_CALLBACK (actor_removed), NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue