st: Add static setters
Even where properties can only be set via g_object_set(), separate setters help with code organization and consistency with other properties. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2168>
This commit is contained in:
parent
6a6b7eb341
commit
76e5e22dac
@ -202,6 +202,26 @@ actor_destroyed (gpointer user_data,
|
||||
g_object_notify_by_pspec (G_OBJECT (adj), props[PROP_ACTOR]);
|
||||
}
|
||||
|
||||
static void
|
||||
st_adjustment_set_actor (StAdjustment *adj,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
StAdjustmentPrivate *priv;
|
||||
|
||||
priv = st_adjustment_get_instance_private (adj);
|
||||
|
||||
if (priv->actor == actor)
|
||||
return;
|
||||
|
||||
if (priv->actor)
|
||||
g_object_weak_unref (G_OBJECT (priv->actor), actor_destroyed, adj);
|
||||
priv->actor = actor;
|
||||
if (priv->actor)
|
||||
g_object_weak_ref (G_OBJECT (priv->actor), actor_destroyed, adj);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (adj), props[PROP_ACTOR]);
|
||||
}
|
||||
|
||||
static void
|
||||
st_adjustment_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
@ -209,18 +229,11 @@ 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);
|
||||
st_adjustment_set_actor (adj, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_LOWER:
|
||||
|
@ -103,6 +103,27 @@ handle_button_press_event_cb (ClutterActor *actor,
|
||||
|
||||
static void stop_scrolling (StScrollBar *bar);
|
||||
|
||||
static void
|
||||
st_scroll_bar_set_vertical (StScrollBar *bar,
|
||||
gboolean vertical)
|
||||
{
|
||||
StScrollBarPrivate *priv = ST_SCROLL_BAR_PRIVATE (bar);
|
||||
|
||||
if (priv->vertical == vertical)
|
||||
return;
|
||||
|
||||
priv->vertical = vertical;
|
||||
|
||||
if (priv->vertical)
|
||||
clutter_actor_set_name (CLUTTER_ACTOR (priv->handle),
|
||||
"vhandle");
|
||||
else
|
||||
clutter_actor_set_name (CLUTTER_ACTOR (priv->handle),
|
||||
"hhandle");
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (bar));
|
||||
g_object_notify_by_pspec (G_OBJECT (bar), props[PROP_VERTICAL]);
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_bar_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
@ -134,7 +155,6 @@ st_scroll_bar_set_property (GObject *gobject,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
StScrollBar *bar = ST_SCROLL_BAR (gobject);
|
||||
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -143,14 +163,7 @@ st_scroll_bar_set_property (GObject *gobject,
|
||||
break;
|
||||
|
||||
case PROP_VERTICAL:
|
||||
priv->vertical = g_value_get_boolean (value);
|
||||
if (priv->vertical)
|
||||
clutter_actor_set_name (CLUTTER_ACTOR (priv->handle),
|
||||
"vhandle");
|
||||
else
|
||||
clutter_actor_set_name (CLUTTER_ACTOR (priv->handle),
|
||||
"hhandle");
|
||||
clutter_actor_queue_relayout ((ClutterActor*) gobject);
|
||||
st_scroll_bar_set_vertical (bar, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -210,6 +210,23 @@ st_scroll_view_update_fade_effect (StScrollView *scroll,
|
||||
clutter_actor_queue_redraw (CLUTTER_ACTOR (scroll));
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_set_content_padding (StScrollView *scroll,
|
||||
ClutterMargin *content_padding)
|
||||
{
|
||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (scroll)->priv;
|
||||
|
||||
if (priv->content_padding.left == content_padding->left &&
|
||||
priv->content_padding.right == content_padding->right &&
|
||||
priv->content_padding.top == content_padding->top &&
|
||||
priv->content_padding.bottom == content_padding->bottom)
|
||||
return;
|
||||
|
||||
priv->content_padding = *content_padding;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (scroll), props[PROP_CONTENT_PADDING]);
|
||||
}
|
||||
|
||||
static void
|
||||
st_scroll_view_set_property (GObject *object,
|
||||
guint property_id,
|
||||
@ -240,7 +257,8 @@ st_scroll_view_set_property (GObject *object,
|
||||
g_value_get_enum (value));
|
||||
break;
|
||||
case PROP_CONTENT_PADDING:
|
||||
priv->content_padding = * (ClutterMargin *) g_value_get_boxed (value);
|
||||
st_scroll_view_set_content_padding (self,
|
||||
(ClutterMargin *)g_value_get_boxed (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -77,6 +77,19 @@ static void st_theme_context_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void
|
||||
st_theme_context_set_scale_factor (StThemeContext *context,
|
||||
int scale_factor)
|
||||
{
|
||||
if (scale_factor == context->scale_factor)
|
||||
return;
|
||||
|
||||
context->scale_factor = scale_factor;
|
||||
g_object_notify (G_OBJECT (context), "scale-factor");
|
||||
st_theme_context_changed (context);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
st_theme_context_finalize (GObject *object)
|
||||
{
|
||||
@ -179,16 +192,8 @@ st_theme_context_set_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SCALE_FACTOR:
|
||||
{
|
||||
int scale_factor = g_value_get_int (value);
|
||||
if (scale_factor != context->scale_factor)
|
||||
{
|
||||
context->scale_factor = scale_factor;
|
||||
st_theme_context_changed (context);
|
||||
}
|
||||
|
||||
st_theme_context_set_scale_factor (context, g_value_get_int (value));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user