st/adjustment: Add ::actor property
Will be used by transitions to set the timeline actor. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1299
This commit is contained in:
parent
4aabcd9e7d
commit
5ea54426b9
@ -423,6 +423,7 @@ class ControlsManager extends St.Widget {
|
||||
let activeWorkspaceIndex = workspaceManager.get_active_workspace_index();
|
||||
|
||||
this._workspaceAdjustment = new St.Adjustment({
|
||||
actor: this,
|
||||
value: activeWorkspaceIndex,
|
||||
lower: 0,
|
||||
page_increment: 1,
|
||||
|
@ -485,6 +485,7 @@ var UnlockDialog = GObject.registerClass({
|
||||
this._gdmClient = new Gdm.Client();
|
||||
|
||||
this._adjustment = new St.Adjustment({
|
||||
actor: this,
|
||||
lower: 0,
|
||||
upper: 2,
|
||||
page_size: 1,
|
||||
|
@ -41,6 +41,8 @@ typedef struct _StAdjustmentPrivate StAdjustmentPrivate;
|
||||
|
||||
struct _StAdjustmentPrivate
|
||||
{
|
||||
ClutterActor *actor;
|
||||
|
||||
/* Do not sanity-check values while constructing,
|
||||
* not all properties may be set yet. */
|
||||
guint is_constructing : 1;
|
||||
@ -66,6 +68,7 @@ enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_ACTOR,
|
||||
PROP_LOWER,
|
||||
PROP_UPPER,
|
||||
PROP_VALUE,
|
||||
@ -106,9 +109,21 @@ static gboolean st_adjustment_set_page_increment (StAdjustment *adjustment,
|
||||
static gboolean st_adjustment_set_page_size (StAdjustment *adjustment,
|
||||
gdouble size);
|
||||
|
||||
static ClutterActor *
|
||||
st_adjustment_get_actor (ClutterAnimatable *animatable)
|
||||
{
|
||||
StAdjustment *adjustment = ST_ADJUSTMENT (animatable);
|
||||
StAdjustmentPrivate *priv = st_adjustment_get_instance_private (adjustment);
|
||||
|
||||
g_warn_if_fail (priv->actor);
|
||||
|
||||
return priv->actor;
|
||||
}
|
||||
|
||||
static void
|
||||
animatable_iface_init (ClutterAnimatableInterface *iface)
|
||||
{
|
||||
iface->get_actor = st_adjustment_get_actor;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -141,6 +156,10 @@ st_adjustment_get_property (GObject *gobject,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ACTOR:
|
||||
g_value_set_object (value, priv->actor);
|
||||
break;
|
||||
|
||||
case PROP_LOWER:
|
||||
g_value_set_double (value, priv->lower);
|
||||
break;
|
||||
@ -171,6 +190,18 @@ st_adjustment_get_property (GObject *gobject,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
actor_destroyed (gpointer user_data,
|
||||
GObject *where_the_object_was)
|
||||
{
|
||||
StAdjustment *adj = ST_ADJUSTMENT (user_data);
|
||||
StAdjustmentPrivate *priv = st_adjustment_get_instance_private (adj);
|
||||
|
||||
priv->actor = NULL;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (adj), props[PROP_ACTOR]);
|
||||
}
|
||||
|
||||
static void
|
||||
st_adjustment_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
@ -178,9 +209,20 @@ st_adjustment_set_property (GObject *gobject,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StAdjustment *adj = ST_ADJUSTMENT (gobject);
|
||||
StAdjustmentPrivate *priv;
|
||||
|
||||
priv = st_adjustment_get_instance_private (ST_ADJUSTMENT (gobject));
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ACTOR:
|
||||
if (priv->actor)
|
||||
g_object_weak_unref (G_OBJECT (priv->actor), actor_destroyed, adj);
|
||||
priv->actor = g_value_get_object (value);
|
||||
if (priv->actor)
|
||||
g_object_weak_ref (G_OBJECT (priv->actor), actor_destroyed, adj);
|
||||
break;
|
||||
|
||||
case PROP_LOWER:
|
||||
st_adjustment_set_lower (adj, g_value_get_double (value));
|
||||
break;
|
||||
@ -217,6 +259,11 @@ st_adjustment_dispose (GObject *object)
|
||||
StAdjustmentPrivate *priv;
|
||||
|
||||
priv = st_adjustment_get_instance_private (ST_ADJUSTMENT (object));
|
||||
if (priv->actor)
|
||||
{
|
||||
g_object_weak_unref (G_OBJECT (priv->actor), actor_destroyed, object);
|
||||
priv->actor = NULL;
|
||||
}
|
||||
g_clear_pointer (&priv->transitions, g_hash_table_unref);
|
||||
|
||||
G_OBJECT_CLASS (st_adjustment_parent_class)->dispose (object);
|
||||
@ -232,6 +279,11 @@ st_adjustment_class_init (StAdjustmentClass *klass)
|
||||
object_class->set_property = st_adjustment_set_property;
|
||||
object_class->dispose = st_adjustment_dispose;
|
||||
|
||||
props[PROP_ACTOR] =
|
||||
g_param_spec_object ("actor", "Actor", "Actor",
|
||||
CLUTTER_TYPE_ACTOR,
|
||||
ST_PARAM_READWRITE);
|
||||
|
||||
props[PROP_LOWER] =
|
||||
g_param_spec_double ("lower", "Lower", "Lower bound",
|
||||
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
|
||||
@ -299,7 +351,8 @@ st_adjustment_init (StAdjustment *self)
|
||||
}
|
||||
|
||||
StAdjustment *
|
||||
st_adjustment_new (gdouble value,
|
||||
st_adjustment_new (ClutterActor *actor,
|
||||
gdouble value,
|
||||
gdouble lower,
|
||||
gdouble upper,
|
||||
gdouble step_increment,
|
||||
@ -307,6 +360,7 @@ st_adjustment_new (gdouble value,
|
||||
gdouble page_size)
|
||||
{
|
||||
return g_object_new (ST_TYPE_ADJUSTMENT,
|
||||
"actor", actor,
|
||||
"value", value,
|
||||
"lower", lower,
|
||||
"upper", upper,
|
||||
|
@ -48,7 +48,8 @@ struct _StAdjustmentClass
|
||||
void (* changed) (StAdjustment *adjustment);
|
||||
};
|
||||
|
||||
StAdjustment *st_adjustment_new (gdouble value,
|
||||
StAdjustment *st_adjustment_new (ClutterActor *actor,
|
||||
gdouble value,
|
||||
gdouble lower,
|
||||
gdouble upper,
|
||||
gdouble step_increment,
|
||||
|
@ -899,13 +899,17 @@ st_scroll_view_init (StScrollView *self)
|
||||
priv->hscrollbar_policy = ST_POLICY_AUTOMATIC;
|
||||
priv->vscrollbar_policy = ST_POLICY_AUTOMATIC;
|
||||
|
||||
priv->hadjustment = g_object_new (ST_TYPE_ADJUSTMENT, NULL);
|
||||
priv->hadjustment = g_object_new (ST_TYPE_ADJUSTMENT,
|
||||
"actor", self,
|
||||
NULL);
|
||||
priv->hscroll = g_object_new (ST_TYPE_SCROLL_BAR,
|
||||
"adjustment", priv->hadjustment,
|
||||
"vertical", FALSE,
|
||||
NULL);
|
||||
|
||||
priv->vadjustment = g_object_new (ST_TYPE_ADJUSTMENT, NULL);
|
||||
priv->vadjustment = g_object_new (ST_TYPE_ADJUSTMENT,
|
||||
"actor", self,
|
||||
NULL);
|
||||
priv->vscroll = g_object_new (ST_TYPE_SCROLL_BAR,
|
||||
"adjustment", priv->vadjustment,
|
||||
"vertical", TRUE,
|
||||
|
Loading…
Reference in New Issue
Block a user