[gnome-shell] st/adjustment: Add ::actor property
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st/adjustment: Add ::actor property
- Date: Thu, 2 Jul 2020 20:58:13 +0000 (UTC)
commit 5ea54426b9c85d7d7a8888a2024f5815187aeba5
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Tue Jun 16 22:03:07 2020 +0200
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
js/ui/overviewControls.js | 1 +
js/ui/unlockDialog.js | 1 +
src/st/st-adjustment.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++-
src/st/st-adjustment.h | 3 ++-
src/st/st-scroll-view.c | 8 +++++--
5 files changed, 65 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index 9f73408d0c..3d665dc1e7 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 c6d70d3382..ad3aab977a 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 dfd1efe677..eb170488f8 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 302755a097..08a0fc30a2 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 1d2dbec8d4..349c8c8409 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]