diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js index 9f73408d0..3d665dc1e 100644 --- a/js/ui/overviewControls.js +++ b/js/ui/overviewControls.js @@ -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, diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js index c6d70d338..ad3aab977 100644 --- a/js/ui/unlockDialog.js +++ b/js/ui/unlockDialog.js @@ -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, diff --git a/src/st/st-adjustment.c b/src/st/st-adjustment.c index dfd1efe67..eb170488f 100644 --- a/src/st/st-adjustment.c +++ b/src/st/st-adjustment.c @@ -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, diff --git a/src/st/st-adjustment.h b/src/st/st-adjustment.h index 302755a09..08a0fc30a 100644 --- a/src/st/st-adjustment.h +++ b/src/st/st-adjustment.h @@ -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, diff --git a/src/st/st-scroll-view.c b/src/st/st-scroll-view.c index 1d2dbec8d..349c8c840 100644 --- a/src/st/st-scroll-view.c +++ b/src/st/st-scroll-view.c @@ -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,