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();
|
let activeWorkspaceIndex = workspaceManager.get_active_workspace_index();
|
||||||
|
|
||||||
this._workspaceAdjustment = new St.Adjustment({
|
this._workspaceAdjustment = new St.Adjustment({
|
||||||
|
actor: this,
|
||||||
value: activeWorkspaceIndex,
|
value: activeWorkspaceIndex,
|
||||||
lower: 0,
|
lower: 0,
|
||||||
page_increment: 1,
|
page_increment: 1,
|
||||||
|
@ -485,6 +485,7 @@ var UnlockDialog = GObject.registerClass({
|
|||||||
this._gdmClient = new Gdm.Client();
|
this._gdmClient = new Gdm.Client();
|
||||||
|
|
||||||
this._adjustment = new St.Adjustment({
|
this._adjustment = new St.Adjustment({
|
||||||
|
actor: this,
|
||||||
lower: 0,
|
lower: 0,
|
||||||
upper: 2,
|
upper: 2,
|
||||||
page_size: 1,
|
page_size: 1,
|
||||||
|
@ -41,6 +41,8 @@ typedef struct _StAdjustmentPrivate StAdjustmentPrivate;
|
|||||||
|
|
||||||
struct _StAdjustmentPrivate
|
struct _StAdjustmentPrivate
|
||||||
{
|
{
|
||||||
|
ClutterActor *actor;
|
||||||
|
|
||||||
/* Do not sanity-check values while constructing,
|
/* Do not sanity-check values while constructing,
|
||||||
* not all properties may be set yet. */
|
* not all properties may be set yet. */
|
||||||
guint is_constructing : 1;
|
guint is_constructing : 1;
|
||||||
@ -66,6 +68,7 @@ enum
|
|||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
|
||||||
|
PROP_ACTOR,
|
||||||
PROP_LOWER,
|
PROP_LOWER,
|
||||||
PROP_UPPER,
|
PROP_UPPER,
|
||||||
PROP_VALUE,
|
PROP_VALUE,
|
||||||
@ -106,9 +109,21 @@ static gboolean st_adjustment_set_page_increment (StAdjustment *adjustment,
|
|||||||
static gboolean st_adjustment_set_page_size (StAdjustment *adjustment,
|
static gboolean st_adjustment_set_page_size (StAdjustment *adjustment,
|
||||||
gdouble size);
|
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
|
static void
|
||||||
animatable_iface_init (ClutterAnimatableInterface *iface)
|
animatable_iface_init (ClutterAnimatableInterface *iface)
|
||||||
{
|
{
|
||||||
|
iface->get_actor = st_adjustment_get_actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -141,6 +156,10 @@ st_adjustment_get_property (GObject *gobject,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
|
case PROP_ACTOR:
|
||||||
|
g_value_set_object (value, priv->actor);
|
||||||
|
break;
|
||||||
|
|
||||||
case PROP_LOWER:
|
case PROP_LOWER:
|
||||||
g_value_set_double (value, priv->lower);
|
g_value_set_double (value, priv->lower);
|
||||||
break;
|
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
|
static void
|
||||||
st_adjustment_set_property (GObject *gobject,
|
st_adjustment_set_property (GObject *gobject,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@ -178,9 +209,20 @@ st_adjustment_set_property (GObject *gobject,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
StAdjustment *adj = ST_ADJUSTMENT (gobject);
|
StAdjustment *adj = ST_ADJUSTMENT (gobject);
|
||||||
|
StAdjustmentPrivate *priv;
|
||||||
|
|
||||||
|
priv = st_adjustment_get_instance_private (ST_ADJUSTMENT (gobject));
|
||||||
|
|
||||||
switch (prop_id)
|
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:
|
case PROP_LOWER:
|
||||||
st_adjustment_set_lower (adj, g_value_get_double (value));
|
st_adjustment_set_lower (adj, g_value_get_double (value));
|
||||||
break;
|
break;
|
||||||
@ -217,6 +259,11 @@ st_adjustment_dispose (GObject *object)
|
|||||||
StAdjustmentPrivate *priv;
|
StAdjustmentPrivate *priv;
|
||||||
|
|
||||||
priv = st_adjustment_get_instance_private (ST_ADJUSTMENT (object));
|
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_clear_pointer (&priv->transitions, g_hash_table_unref);
|
||||||
|
|
||||||
G_OBJECT_CLASS (st_adjustment_parent_class)->dispose (object);
|
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->set_property = st_adjustment_set_property;
|
||||||
object_class->dispose = st_adjustment_dispose;
|
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] =
|
props[PROP_LOWER] =
|
||||||
g_param_spec_double ("lower", "Lower", "Lower bound",
|
g_param_spec_double ("lower", "Lower", "Lower bound",
|
||||||
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
|
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
|
||||||
@ -299,7 +351,8 @@ st_adjustment_init (StAdjustment *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
StAdjustment *
|
StAdjustment *
|
||||||
st_adjustment_new (gdouble value,
|
st_adjustment_new (ClutterActor *actor,
|
||||||
|
gdouble value,
|
||||||
gdouble lower,
|
gdouble lower,
|
||||||
gdouble upper,
|
gdouble upper,
|
||||||
gdouble step_increment,
|
gdouble step_increment,
|
||||||
@ -307,6 +360,7 @@ st_adjustment_new (gdouble value,
|
|||||||
gdouble page_size)
|
gdouble page_size)
|
||||||
{
|
{
|
||||||
return g_object_new (ST_TYPE_ADJUSTMENT,
|
return g_object_new (ST_TYPE_ADJUSTMENT,
|
||||||
|
"actor", actor,
|
||||||
"value", value,
|
"value", value,
|
||||||
"lower", lower,
|
"lower", lower,
|
||||||
"upper", upper,
|
"upper", upper,
|
||||||
|
@ -48,7 +48,8 @@ struct _StAdjustmentClass
|
|||||||
void (* changed) (StAdjustment *adjustment);
|
void (* changed) (StAdjustment *adjustment);
|
||||||
};
|
};
|
||||||
|
|
||||||
StAdjustment *st_adjustment_new (gdouble value,
|
StAdjustment *st_adjustment_new (ClutterActor *actor,
|
||||||
|
gdouble value,
|
||||||
gdouble lower,
|
gdouble lower,
|
||||||
gdouble upper,
|
gdouble upper,
|
||||||
gdouble step_increment,
|
gdouble step_increment,
|
||||||
|
@ -899,13 +899,17 @@ st_scroll_view_init (StScrollView *self)
|
|||||||
priv->hscrollbar_policy = ST_POLICY_AUTOMATIC;
|
priv->hscrollbar_policy = ST_POLICY_AUTOMATIC;
|
||||||
priv->vscrollbar_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,
|
priv->hscroll = g_object_new (ST_TYPE_SCROLL_BAR,
|
||||||
"adjustment", priv->hadjustment,
|
"adjustment", priv->hadjustment,
|
||||||
"vertical", FALSE,
|
"vertical", FALSE,
|
||||||
NULL);
|
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,
|
priv->vscroll = g_object_new (ST_TYPE_SCROLL_BAR,
|
||||||
"adjustment", priv->vadjustment,
|
"adjustment", priv->vadjustment,
|
||||||
"vertical", TRUE,
|
"vertical", TRUE,
|
||||||
|
Loading…
Reference in New Issue
Block a user