st-widget: Keep track of first/last children
Clutter now provides two new properties on ClutterActor - first-child and last-child, so we have notifiers on when they change. Unfortunately, it still doesn't help us too much - we need to keep track of the previous values of the properties so we can remove their pseudoclasses. https://bugzilla.gnome.org/show_bug.cgi?id=670034
This commit is contained in:
parent
3736d81d8f
commit
a9f728d2a7
@ -70,6 +70,12 @@ struct _StWidgetPrivate
|
||||
AtkObject *accessible;
|
||||
|
||||
ClutterActor *label_actor;
|
||||
|
||||
/* Even though Clutter has first_child/last_child properties,
|
||||
* we need to keep track of the old first/last children so
|
||||
* that we can remove the pseudo classes on them. */
|
||||
StWidget *prev_last_child;
|
||||
StWidget *prev_first_child;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -275,6 +281,9 @@ st_widget_dispose (GObject *gobject)
|
||||
priv->label_actor = NULL;
|
||||
}
|
||||
|
||||
g_clear_object (&priv->prev_first_child);
|
||||
g_clear_object (&priv->prev_last_child);
|
||||
|
||||
G_OBJECT_CLASS (st_widget_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
@ -1282,6 +1291,56 @@ st_widget_name_notify (StWidget *widget,
|
||||
st_widget_style_changed (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
st_widget_first_child_notify (StWidget *widget,
|
||||
GParamSpec *pspec,
|
||||
gpointer data)
|
||||
{
|
||||
ClutterActor *first_child;
|
||||
|
||||
if (widget->priv->prev_first_child != NULL)
|
||||
{
|
||||
st_widget_remove_style_pseudo_class (widget->priv->prev_first_child, "first-child");
|
||||
g_clear_object (&widget->priv->prev_first_child);
|
||||
}
|
||||
|
||||
first_child = clutter_actor_get_first_child (CLUTTER_ACTOR (widget));
|
||||
|
||||
if (first_child == NULL)
|
||||
return;
|
||||
|
||||
if (ST_IS_WIDGET (first_child))
|
||||
{
|
||||
st_widget_add_style_pseudo_class (ST_WIDGET (first_child), "first-child");
|
||||
widget->priv->prev_first_child = g_object_ref (ST_WIDGET (first_child));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_widget_last_child_notify (StWidget *widget,
|
||||
GParamSpec *pspec,
|
||||
gpointer data)
|
||||
{
|
||||
ClutterActor *last_child;
|
||||
|
||||
if (widget->priv->prev_last_child != NULL)
|
||||
{
|
||||
st_widget_remove_style_pseudo_class (widget->priv->prev_last_child, "last-child");
|
||||
g_clear_object (&widget->priv->prev_last_child);
|
||||
}
|
||||
|
||||
last_child = clutter_actor_get_last_child (CLUTTER_ACTOR (widget));
|
||||
|
||||
if (last_child == NULL)
|
||||
return;
|
||||
|
||||
if (ST_IS_WIDGET (last_child))
|
||||
{
|
||||
st_widget_add_style_pseudo_class (ST_WIDGET (last_child), "last-child");
|
||||
widget->priv->prev_last_child = g_object_ref (ST_WIDGET (last_child));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_widget_init (StWidget *actor)
|
||||
{
|
||||
@ -1293,6 +1352,9 @@ st_widget_init (StWidget *actor)
|
||||
|
||||
/* connect style changed */
|
||||
g_signal_connect (actor, "notify::name", G_CALLBACK (st_widget_name_notify), NULL);
|
||||
|
||||
g_signal_connect (actor, "notify::first-child", G_CALLBACK (st_widget_first_child_notify), NULL);
|
||||
g_signal_connect (actor, "notify::last-child", G_CALLBACK (st_widget_last_child_notify), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user