st: Use g_object_notify_by_pspec()

`g_object_notify()` actually takes a global lock to look up the property
by its name, which means there is a performance hit (albeit tiny) every
time this function is called. For this reason, always try to use
`g_object_notify_by_pspec()` instead.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/652
This commit is contained in:
Niels De Graef 2019-07-29 17:59:41 +02:00
parent 668128f8c9
commit 8f3554ff3e
10 changed files with 453 additions and 450 deletions

View File

@ -70,8 +70,12 @@ enum
PROP_STEP_INC, PROP_STEP_INC,
PROP_PAGE_INC, PROP_PAGE_INC,
PROP_PAGE_SIZE, PROP_PAGE_SIZE,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
enum enum
{ {
CHANGED, CHANGED,
@ -206,72 +210,50 @@ st_adjustment_class_init (StAdjustmentClass *klass)
object_class->get_property = st_adjustment_get_property; object_class->get_property = st_adjustment_get_property;
object_class->set_property = st_adjustment_set_property; object_class->set_property = st_adjustment_set_property;
g_object_class_install_property (object_class, props[PROP_LOWER] =
PROP_LOWER, g_param_spec_double ("lower", "Lower", "Lower bound",
g_param_spec_double ("lower", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
"Lower", ST_PARAM_READWRITE |
"Lower bound", G_PARAM_CONSTRUCT |
-G_MAXDOUBLE, G_PARAM_EXPLICIT_NOTIFY);
G_MAXDOUBLE,
0.0, props[PROP_UPPER] =
ST_PARAM_READWRITE | g_param_spec_double ("upper", "Upper", "Upper bound",
G_PARAM_CONSTRUCT | -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
G_PARAM_EXPLICIT_NOTIFY)); ST_PARAM_READWRITE |
g_object_class_install_property (object_class, G_PARAM_CONSTRUCT |
PROP_UPPER, G_PARAM_EXPLICIT_NOTIFY);
g_param_spec_double ("upper",
"Upper", props[PROP_VALUE] =
"Upper bound", g_param_spec_double ("value", "Value", "Current value",
-G_MAXDOUBLE, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
G_MAXDOUBLE, ST_PARAM_READWRITE |
0.0, G_PARAM_CONSTRUCT |
ST_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
G_PARAM_CONSTRUCT |
G_PARAM_EXPLICIT_NOTIFY)); props[PROP_STEP_INC] =
g_object_class_install_property (object_class, g_param_spec_double ("step-increment", "Step Increment", "Step increment",
PROP_VALUE, 0.0, G_MAXDOUBLE, 0.0,
g_param_spec_double ("value", ST_PARAM_READWRITE |
"Value", G_PARAM_CONSTRUCT |
"Current value", G_PARAM_EXPLICIT_NOTIFY);
-G_MAXDOUBLE,
G_MAXDOUBLE, props[PROP_PAGE_INC] =
0.0, g_param_spec_double ("page-increment", "Page Increment", "Page increment",
ST_PARAM_READWRITE | 0.0, G_MAXDOUBLE, 0.0,
G_PARAM_CONSTRUCT | ST_PARAM_READWRITE |
G_PARAM_EXPLICIT_NOTIFY)); G_PARAM_CONSTRUCT |
g_object_class_install_property (object_class, G_PARAM_EXPLICIT_NOTIFY);
PROP_STEP_INC,
g_param_spec_double ("step-increment", props[PROP_PAGE_SIZE] =
"Step Increment", g_param_spec_double ("page-size", "Page Size", "Page size",
"Step increment", 0.0, G_MAXDOUBLE, 0.0,
0.0, ST_PARAM_READWRITE |
G_MAXDOUBLE, G_PARAM_CONSTRUCT |
0.0, G_PARAM_EXPLICIT_NOTIFY);
ST_PARAM_READWRITE |
G_PARAM_CONSTRUCT | g_object_class_install_properties (object_class, N_PROPS, props);
G_PARAM_EXPLICIT_NOTIFY));
g_object_class_install_property (object_class,
PROP_PAGE_INC,
g_param_spec_double ("page-increment",
"Page Increment",
"Page increment",
0.0,
G_MAXDOUBLE,
0.0,
ST_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_EXPLICIT_NOTIFY));
g_object_class_install_property (object_class,
PROP_PAGE_SIZE,
g_param_spec_double ("page-size",
"Page Size",
"Page size",
0.0,
G_MAXDOUBLE,
0.0,
ST_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_EXPLICIT_NOTIFY));
/** /**
* StAdjustment::changed: * StAdjustment::changed:
* @self: the #StAdjustment * @self: the #StAdjustment
@ -342,7 +324,7 @@ st_adjustment_set_value (StAdjustment *adjustment,
{ {
priv->value = value; priv->value = value;
g_object_notify (G_OBJECT (adjustment), "value"); g_object_notify_by_pspec (G_OBJECT (adjustment), props[PROP_VALUE]);
} }
} }
@ -376,7 +358,7 @@ st_adjustment_clamp_page (StAdjustment *adjustment,
} }
if (changed) if (changed)
g_object_notify (G_OBJECT (adjustment), "value"); g_object_notify_by_pspec (G_OBJECT (adjustment), props[PROP_VALUE]);
} }
static gboolean static gboolean
@ -391,7 +373,7 @@ st_adjustment_set_lower (StAdjustment *adjustment,
g_signal_emit (adjustment, signals[CHANGED], 0); g_signal_emit (adjustment, signals[CHANGED], 0);
g_object_notify (G_OBJECT (adjustment), "lower"); g_object_notify_by_pspec (G_OBJECT (adjustment), props[PROP_LOWER]);
/* Defer clamp until after construction. */ /* Defer clamp until after construction. */
if (!priv->is_constructing) if (!priv->is_constructing)
@ -415,7 +397,7 @@ st_adjustment_set_upper (StAdjustment *adjustment,
g_signal_emit (adjustment, signals[CHANGED], 0); g_signal_emit (adjustment, signals[CHANGED], 0);
g_object_notify (G_OBJECT (adjustment), "upper"); g_object_notify_by_pspec (G_OBJECT (adjustment), props[PROP_UPPER]);
/* Defer clamp until after construction. */ /* Defer clamp until after construction. */
if (!priv->is_constructing) if (!priv->is_constructing)
@ -439,7 +421,7 @@ st_adjustment_set_step_increment (StAdjustment *adjustment,
g_signal_emit (adjustment, signals[CHANGED], 0); g_signal_emit (adjustment, signals[CHANGED], 0);
g_object_notify (G_OBJECT (adjustment), "step-increment"); g_object_notify_by_pspec (G_OBJECT (adjustment), props[PROP_STEP_INC]);
return TRUE; return TRUE;
} }
@ -459,7 +441,7 @@ st_adjustment_set_page_increment (StAdjustment *adjustment,
g_signal_emit (adjustment, signals[CHANGED], 0); g_signal_emit (adjustment, signals[CHANGED], 0);
g_object_notify (G_OBJECT (adjustment), "page-increment"); g_object_notify_by_pspec (G_OBJECT (adjustment), props[PROP_PAGE_INC]);
return TRUE; return TRUE;
} }
@ -479,7 +461,7 @@ st_adjustment_set_page_size (StAdjustment *adjustment,
g_signal_emit (adjustment, signals[CHANGED], 0); g_signal_emit (adjustment, signals[CHANGED], 0);
g_object_notify (G_OBJECT (adjustment), "page_size"); g_object_notify_by_pspec (G_OBJECT (adjustment), props[PROP_PAGE_SIZE]);
/* Well explicitely clamp after construction. */ /* Well explicitely clamp after construction. */
if (!priv->is_constructing) if (!priv->is_constructing)

View File

@ -58,9 +58,13 @@ enum
PROP_X_ALIGN, PROP_X_ALIGN,
PROP_Y_ALIGN, PROP_Y_ALIGN,
PROP_X_FILL, PROP_X_FILL,
PROP_Y_FILL PROP_Y_FILL,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
static void clutter_container_iface_init (ClutterContainerIface *iface); static void clutter_container_iface_init (ClutterContainerIface *iface);
G_DEFINE_TYPE_WITH_CODE (StBin, st_bin, ST_TYPE_WIDGET, G_DEFINE_TYPE_WITH_CODE (StBin, st_bin, ST_TYPE_WIDGET,
@ -311,7 +315,6 @@ st_bin_class_init (StBinClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass); StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
GParamSpec *pspec;
gobject_class->set_property = st_bin_set_property; gobject_class->set_property = st_bin_set_property;
gobject_class->get_property = st_bin_get_property; gobject_class->get_property = st_bin_get_property;
@ -329,64 +332,66 @@ st_bin_class_init (StBinClass *klass)
* *
* The child #ClutterActor of the #StBin container. * The child #ClutterActor of the #StBin container.
*/ */
pspec = g_param_spec_object ("child", props[PROP_CHILD] =
"Child", g_param_spec_object ("child",
"The child of the Bin", "Child",
CLUTTER_TYPE_ACTOR, "The child of the Bin",
ST_PARAM_READWRITE); CLUTTER_TYPE_ACTOR,
g_object_class_install_property (gobject_class, PROP_CHILD, pspec); ST_PARAM_READWRITE);
/** /**
* StBin:x-align: * StBin:x-align:
* *
* The horizontal alignment of the #StBin child. * The horizontal alignment of the #StBin child.
*/ */
pspec = g_param_spec_enum ("x-align", props[PROP_X_ALIGN] =
"X Align", g_param_spec_enum ("x-align",
"The horizontal alignment", "X Align",
ST_TYPE_ALIGN, "The horizontal alignment",
ST_ALIGN_MIDDLE, ST_TYPE_ALIGN,
ST_PARAM_READWRITE); ST_ALIGN_MIDDLE,
g_object_class_install_property (gobject_class, PROP_X_ALIGN, pspec); ST_PARAM_READWRITE);
/** /**
* StBin:y-align: * StBin:y-align:
* *
* The vertical alignment of the #StBin child. * The vertical alignment of the #StBin child.
*/ */
pspec = g_param_spec_enum ("y-align", props[PROP_Y_ALIGN] =
"Y Align", g_param_spec_enum ("y-align",
"The vertical alignment", "Y Align",
ST_TYPE_ALIGN, "The vertical alignment",
ST_ALIGN_MIDDLE, ST_TYPE_ALIGN,
ST_PARAM_READWRITE); ST_ALIGN_MIDDLE,
g_object_class_install_property (gobject_class, PROP_Y_ALIGN, pspec); ST_PARAM_READWRITE);
/** /**
* StBin:x-fill: * StBin:x-fill:
* *
* Whether the child should fill the horizontal allocation * Whether the child should fill the horizontal allocation
*/ */
pspec = g_param_spec_boolean ("x-fill", props[PROP_X_FILL] =
"X Fill", g_param_spec_boolean ("x-fill",
"Whether the child should fill the " "X Fill",
"horizontal allocation", "Whether the child should fill the "
FALSE, "horizontal allocation",
ST_PARAM_READWRITE); FALSE,
g_object_class_install_property (gobject_class, PROP_X_FILL, pspec); ST_PARAM_READWRITE);
/** /**
* StBin:y-fill: * StBin:y-fill:
* *
* Whether the child should fill the vertical allocation * Whether the child should fill the vertical allocation
*/ */
pspec = g_param_spec_boolean ("y-fill", props[PROP_Y_FILL] =
"Y Fill", g_param_spec_boolean ("y-fill",
"Whether the child should fill the " "Y Fill",
"vertical allocation", "Whether the child should fill the "
FALSE, "vertical allocation",
ST_PARAM_READWRITE); FALSE,
g_object_class_install_property (gobject_class, PROP_Y_FILL, pspec); ST_PARAM_READWRITE);
g_object_class_install_properties (gobject_class, N_PROPS, props);
} }
static void static void
@ -447,7 +452,7 @@ st_bin_set_child (StBin *bin,
clutter_actor_queue_relayout (CLUTTER_ACTOR (bin)); clutter_actor_queue_relayout (CLUTTER_ACTOR (bin));
g_object_notify (G_OBJECT (bin), "child"); g_object_notify_by_pspec (G_OBJECT (bin), props[PROP_CHILD]);
} }
/** /**
@ -492,14 +497,14 @@ st_bin_set_alignment (StBin *bin,
if (priv->x_align != x_align) if (priv->x_align != x_align)
{ {
priv->x_align = x_align; priv->x_align = x_align;
g_object_notify (G_OBJECT (bin), "x-align"); g_object_notify_by_pspec (G_OBJECT (bin), props[PROP_X_ALIGN]);
changed = TRUE; changed = TRUE;
} }
if (priv->y_align != y_align) if (priv->y_align != y_align)
{ {
priv->y_align = y_align; priv->y_align = y_align;
g_object_notify (G_OBJECT (bin), "y-align"); g_object_notify_by_pspec (G_OBJECT (bin), props[PROP_Y_ALIGN]);
changed = TRUE; changed = TRUE;
} }
@ -564,7 +569,7 @@ st_bin_set_fill (StBin *bin,
priv->x_fill = x_fill; priv->x_fill = x_fill;
changed = TRUE; changed = TRUE;
g_object_notify (G_OBJECT (bin), "x-fill"); g_object_notify_by_pspec (G_OBJECT (bin), props[PROP_X_FILL]);
} }
if (priv->y_fill != y_fill) if (priv->y_fill != y_fill)
@ -572,7 +577,7 @@ st_bin_set_fill (StBin *bin,
priv->y_fill = y_fill; priv->y_fill = y_fill;
changed = TRUE; changed = TRUE;
g_object_notify (G_OBJECT (bin), "y-fill"); g_object_notify_by_pspec (G_OBJECT (bin), props[PROP_Y_FILL]);
} }
if (changed) if (changed)

View File

@ -54,9 +54,13 @@ enum
PROP_BUTTON_MASK, PROP_BUTTON_MASK,
PROP_TOGGLE_MODE, PROP_TOGGLE_MODE,
PROP_CHECKED, PROP_CHECKED,
PROP_PRESSED PROP_PRESSED,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
enum enum
{ {
CLICKED, CLICKED,
@ -458,7 +462,6 @@ st_button_class_init (StButtonClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass); StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
GParamSpec *pspec;
gobject_class->set_property = st_button_set_property; gobject_class->set_property = st_button_set_property;
gobject_class->get_property = st_button_get_property; gobject_class->get_property = st_button_get_property;
@ -476,41 +479,42 @@ st_button_class_init (StButtonClass *klass)
widget_class->style_changed = st_button_style_changed; widget_class->style_changed = st_button_style_changed;
widget_class->get_accessible_type = st_button_accessible_get_type; widget_class->get_accessible_type = st_button_accessible_get_type;
pspec = g_param_spec_string ("label", props[PROP_LABEL] =
"Label", g_param_spec_string ("label",
"Label of the button", "Label",
NULL, "Label of the button",
ST_PARAM_READWRITE); NULL,
g_object_class_install_property (gobject_class, PROP_LABEL, pspec); ST_PARAM_READWRITE);
pspec = g_param_spec_flags ("button-mask", props[PROP_BUTTON_MASK] =
"Button mask", g_param_spec_flags ("button-mask",
"Which buttons trigger the 'clicked' signal", "Button mask",
ST_TYPE_BUTTON_MASK, ST_BUTTON_ONE, "Which buttons trigger the 'clicked' signal",
ST_PARAM_READWRITE); ST_TYPE_BUTTON_MASK, ST_BUTTON_ONE,
g_object_class_install_property (gobject_class, PROP_BUTTON_MASK, pspec); ST_PARAM_READWRITE);
pspec = g_param_spec_boolean ("toggle-mode", props[PROP_TOGGLE_MODE] =
"Toggle Mode", g_param_spec_boolean ("toggle-mode",
"Enable or disable toggling", "Toggle Mode",
FALSE, "Enable or disable toggling",
ST_PARAM_READWRITE); FALSE,
g_object_class_install_property (gobject_class, PROP_TOGGLE_MODE, pspec); ST_PARAM_READWRITE);
pspec = g_param_spec_boolean ("checked", props[PROP_CHECKED] =
"Checked", g_param_spec_boolean ("checked",
"Indicates if a toggle button is \"on\"" "Checked",
" or \"off\"", "Indicates if a toggle button is \"on\" or \"off\"",
FALSE, FALSE,
ST_PARAM_READWRITE); ST_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_CHECKED, pspec);
pspec = g_param_spec_boolean ("pressed", props[PROP_PRESSED] =
"Pressed", g_param_spec_boolean ("pressed",
"Indicates if the button is pressed in", "Pressed",
FALSE, "Indicates if the button is pressed in",
ST_PARAM_READABLE); FALSE,
g_object_class_install_property (gobject_class, PROP_PRESSED, pspec); ST_PARAM_READABLE);
g_object_class_install_properties (gobject_class, N_PROPS, props);
/** /**
@ -631,7 +635,7 @@ st_button_set_label (StButton *button,
/* Fake a style change so that we reset the style properties on the label */ /* Fake a style change so that we reset the style properties on the label */
st_widget_style_changed (ST_WIDGET (button)); st_widget_style_changed (ST_WIDGET (button));
g_object_notify (G_OBJECT (button), "label"); g_object_notify_by_pspec (G_OBJECT (button), props[PROP_LABEL]);
} }
/** /**
@ -670,7 +674,7 @@ st_button_set_button_mask (StButton *button,
priv = st_button_get_instance_private (button); priv = st_button_get_instance_private (button);
priv->button_mask = mask; priv->button_mask = mask;
g_object_notify (G_OBJECT (button), "button-mask"); g_object_notify_by_pspec (G_OBJECT (button), props[PROP_BUTTON_MASK]);
} }
/** /**
@ -708,7 +712,7 @@ st_button_set_toggle_mode (StButton *button,
priv = st_button_get_instance_private (button); priv = st_button_get_instance_private (button);
priv->is_toggle = toggle; priv->is_toggle = toggle;
g_object_notify (G_OBJECT (button), "toggle-mode"); g_object_notify_by_pspec (G_OBJECT (button), props[PROP_TOGGLE_MODE]);
} }
/** /**
@ -754,7 +758,7 @@ st_button_set_checked (StButton *button,
st_widget_remove_style_pseudo_class (ST_WIDGET (button), "checked"); st_widget_remove_style_pseudo_class (ST_WIDGET (button), "checked");
} }
g_object_notify (G_OBJECT (button), "checked"); g_object_notify_by_pspec (G_OBJECT (button), props[PROP_CHECKED]);
} }
/** /**

View File

@ -80,8 +80,12 @@ enum
PROP_TEXT, PROP_TEXT,
PROP_INPUT_PURPOSE, PROP_INPUT_PURPOSE,
PROP_INPUT_HINTS, PROP_INPUT_HINTS,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
/* signals */ /* signals */
enum enum
{ {
@ -910,7 +914,6 @@ st_entry_class_init (StEntryClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass); StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
GParamSpec *pspec;
gobject_class->set_property = st_entry_set_property; gobject_class->set_property = st_entry_set_property;
gobject_class->get_property = st_entry_get_property; gobject_class->get_property = st_entry_get_property;
@ -933,68 +936,67 @@ st_entry_class_init (StEntryClass *klass)
widget_class->navigate_focus = st_entry_navigate_focus; widget_class->navigate_focus = st_entry_navigate_focus;
widget_class->get_accessible_type = st_entry_accessible_get_type; widget_class->get_accessible_type = st_entry_accessible_get_type;
pspec = g_param_spec_object ("clutter-text", props[PROP_CLUTTER_TEXT] =
"Clutter Text", g_param_spec_object ("clutter-text",
"Internal ClutterText actor", "Clutter Text",
CLUTTER_TYPE_TEXT, "Internal ClutterText actor",
ST_PARAM_READABLE); CLUTTER_TYPE_TEXT,
g_object_class_install_property (gobject_class, PROP_CLUTTER_TEXT, pspec); ST_PARAM_READABLE);
pspec = g_param_spec_object ("primary-icon", props[PROP_PRIMARY_ICON] =
"Primary Icon", g_param_spec_object ("primary-icon",
"Primary Icon actor", "Primary Icon",
CLUTTER_TYPE_ACTOR, "Primary Icon actor",
ST_PARAM_READWRITE); CLUTTER_TYPE_ACTOR,
g_object_class_install_property (gobject_class, PROP_PRIMARY_ICON, pspec); ST_PARAM_READWRITE);
pspec = g_param_spec_object ("secondary-icon", props[PROP_SECONDARY_ICON] =
"Secondary Icon", g_param_spec_object ("secondary-icon",
"Secondary Icon actor", "Secondary Icon",
CLUTTER_TYPE_ACTOR, "Secondary Icon actor",
ST_PARAM_READWRITE); CLUTTER_TYPE_ACTOR,
g_object_class_install_property (gobject_class, PROP_SECONDARY_ICON, pspec); ST_PARAM_READWRITE);
pspec = g_param_spec_string ("hint-text", props[PROP_HINT_TEXT] =
"Hint Text", g_param_spec_string ("hint-text",
"Text to display when the entry is not focused " "Hint Text",
"and the text property is empty", "Text to display when the entry is not focused "
NULL, "and the text property is empty",
ST_PARAM_READWRITE); NULL,
g_object_class_install_property (gobject_class, PROP_HINT_TEXT, pspec); ST_PARAM_READWRITE);
pspec = g_param_spec_object ("hint-actor", props[PROP_HINT_ACTOR] =
"Hint Actor", g_param_spec_object ("hint-actor",
"An actor to display when the entry is not focused " "Hint Actor",
"and the text property is empty", "An actor to display when the entry is not focused "
CLUTTER_TYPE_ACTOR, "and the text property is empty",
ST_PARAM_READWRITE); CLUTTER_TYPE_ACTOR,
g_object_class_install_property (gobject_class, PROP_HINT_ACTOR, pspec); ST_PARAM_READWRITE);
pspec = g_param_spec_string ("text", props[PROP_TEXT] =
"Text", g_param_spec_string ("text",
"Text of the entry", "Text",
NULL, "Text of the entry",
ST_PARAM_READWRITE); NULL,
g_object_class_install_property (gobject_class, PROP_TEXT, pspec); ST_PARAM_READWRITE);
pspec = g_param_spec_enum ("input-purpose", props[PROP_INPUT_PURPOSE] =
"Purpose", g_param_spec_enum ("input-purpose",
"Purpose of the text field", "Purpose",
CLUTTER_TYPE_INPUT_CONTENT_PURPOSE, "Purpose of the text field",
CLUTTER_INPUT_CONTENT_PURPOSE_NORMAL, CLUTTER_TYPE_INPUT_CONTENT_PURPOSE,
ST_PARAM_READWRITE); CLUTTER_INPUT_CONTENT_PURPOSE_NORMAL,
g_object_class_install_property (gobject_class, ST_PARAM_READWRITE);
PROP_INPUT_PURPOSE,
pspec);
pspec = g_param_spec_flags ("input-hints", props[PROP_INPUT_HINTS] =
"hints", g_param_spec_flags ("input-hints",
"Hints for the text field behaviour", "hints",
CLUTTER_TYPE_INPUT_CONTENT_HINT_FLAGS, "Hints for the text field behaviour",
0, ST_PARAM_READWRITE); CLUTTER_TYPE_INPUT_CONTENT_HINT_FLAGS,
g_object_class_install_property (gobject_class, 0,
PROP_INPUT_HINTS, ST_PARAM_READWRITE);
pspec);
g_object_class_install_properties (gobject_class, N_PROPS, props);
/* signals */ /* signals */
/** /**
@ -1132,7 +1134,7 @@ st_entry_set_text (StEntry *entry,
st_entry_update_hint_visibility (entry); st_entry_update_hint_visibility (entry);
g_object_notify (G_OBJECT (entry), "text"); g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_TEXT]);
} }
/** /**
@ -1222,7 +1224,7 @@ st_entry_set_input_purpose (StEntry *entry,
{ {
clutter_text_set_input_purpose (editable, purpose); clutter_text_set_input_purpose (editable, purpose);
g_object_notify (G_OBJECT (entry), "input-purpose"); g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_INPUT_PURPOSE]);
} }
} }
@ -1267,7 +1269,7 @@ st_entry_set_input_hints (StEntry *entry,
{ {
clutter_text_set_input_hints (editable, hints); clutter_text_set_input_hints (editable, hints);
g_object_notify (G_OBJECT (entry), "input-hints"); g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_INPUT_HINTS]);
} }
} }

View File

@ -39,9 +39,13 @@ enum
PROP_GICON, PROP_GICON,
PROP_ICON_NAME, PROP_ICON_NAME,
PROP_ICON_SIZE, PROP_ICON_SIZE,
PROP_FALLBACK_ICON_NAME PROP_FALLBACK_ICON_NAME,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
struct _StIconPrivate struct _StIconPrivate
{ {
ClutterActor *icon_texture; ClutterActor *icon_texture;
@ -219,8 +223,6 @@ st_icon_resource_scale_changed (StWidget *widget)
static void static void
st_icon_class_init (StIconClass *klass) st_icon_class_init (StIconClass *klass)
{ {
GParamSpec *pspec;
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass); StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
@ -234,31 +236,35 @@ st_icon_class_init (StIconClass *klass)
widget_class->style_changed = st_icon_style_changed; widget_class->style_changed = st_icon_style_changed;
widget_class->resource_scale_changed = st_icon_resource_scale_changed; widget_class->resource_scale_changed = st_icon_resource_scale_changed;
pspec = g_param_spec_object ("gicon", props[PROP_GICON] =
"GIcon", g_param_spec_object ("gicon",
"The GIcon shown by this icon actor", "GIcon",
G_TYPE_ICON, "The GIcon shown by this icon actor",
ST_PARAM_READWRITE); G_TYPE_ICON,
g_object_class_install_property (object_class, PROP_GICON, pspec); ST_PARAM_READWRITE);
pspec = g_param_spec_string ("icon-name", props[PROP_ICON_NAME] =
"Icon name", g_param_spec_string ("icon-name",
"An icon name", "Icon name",
NULL, ST_PARAM_READWRITE); "An icon name",
g_object_class_install_property (object_class, PROP_ICON_NAME, pspec); NULL,
ST_PARAM_READWRITE);
pspec = g_param_spec_int ("icon-size", props[PROP_ICON_SIZE] =
"Icon size", g_param_spec_int ("icon-size",
"The size if the icon, if positive. Otherwise the size will be derived from the current style", "Icon size",
-1, G_MAXINT, -1, "The size if the icon, if positive. Otherwise the size will be derived from the current style",
ST_PARAM_READWRITE); -1, G_MAXINT, -1,
g_object_class_install_property (object_class, PROP_ICON_SIZE, pspec); ST_PARAM_READWRITE);
pspec = g_param_spec_string ("fallback-icon-name", props[PROP_FALLBACK_ICON_NAME] =
"Fallback icon name", g_param_spec_string ("fallback-icon-name",
"A fallback icon name", "Fallback icon name",
NULL, ST_PARAM_READWRITE); "A fallback icon name",
g_object_class_install_property (object_class, PROP_FALLBACK_ICON_NAME, pspec); NULL,
ST_PARAM_READWRITE);
g_object_class_install_properties (object_class, N_PROPS, props);
} }
static void static void
@ -528,8 +534,8 @@ st_icon_set_icon_name (StIcon *icon,
priv->gicon = gicon; priv->gicon = gicon;
g_object_notify (G_OBJECT (icon), "gicon"); g_object_notify_by_pspec (G_OBJECT (icon), props[PROP_GICON]);
g_object_notify (G_OBJECT (icon), "icon-name"); g_object_notify_by_pspec (G_OBJECT (icon), props[PROP_ICON_NAME]);
g_object_thaw_notify (G_OBJECT (icon)); g_object_thaw_notify (G_OBJECT (icon));
@ -573,7 +579,7 @@ st_icon_set_gicon (StIcon *icon, GIcon *gicon)
if (gicon) if (gicon)
icon->priv->gicon = g_object_ref (gicon); icon->priv->gicon = g_object_ref (gicon);
g_object_notify (G_OBJECT (icon), "gicon"); g_object_notify_by_pspec (G_OBJECT (icon), props[PROP_GICON]);
st_icon_update (icon); st_icon_update (icon);
} }
@ -617,7 +623,7 @@ st_icon_set_icon_size (StIcon *icon,
priv->prop_icon_size = size; priv->prop_icon_size = size;
if (st_icon_update_icon_size (icon)) if (st_icon_update_icon_size (icon))
st_icon_update (icon); st_icon_update (icon);
g_object_notify (G_OBJECT (icon), "icon-size"); g_object_notify_by_pspec (G_OBJECT (icon), props[PROP_ICON_SIZE]);
} }
} }
@ -660,7 +666,7 @@ st_icon_set_fallback_icon_name (StIcon *icon,
priv->fallback_gicon = gicon; priv->fallback_gicon = gicon;
g_object_notify (G_OBJECT (icon), "fallback-icon-name"); g_object_notify_by_pspec (G_OBJECT (icon), props[PROP_FALLBACK_ICON_NAME]);
st_icon_update (icon); st_icon_update (icon);
} }

View File

@ -51,9 +51,13 @@ enum
PROP_0, PROP_0,
PROP_CLUTTER_TEXT, PROP_CLUTTER_TEXT,
PROP_TEXT PROP_TEXT,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
struct _StLabelPrivate struct _StLabelPrivate
{ {
ClutterActor *label; ClutterActor *label;
@ -249,7 +253,6 @@ st_label_class_init (StLabelClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass); StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
GParamSpec *pspec;
gobject_class->set_property = st_label_set_property; gobject_class->set_property = st_label_set_property;
gobject_class->get_property = st_label_get_property; gobject_class->get_property = st_label_get_property;
@ -264,20 +267,21 @@ st_label_class_init (StLabelClass *klass)
widget_class->resource_scale_changed = st_label_resource_scale_changed; widget_class->resource_scale_changed = st_label_resource_scale_changed;
widget_class->get_accessible_type = st_label_accessible_get_type; widget_class->get_accessible_type = st_label_accessible_get_type;
pspec = g_param_spec_object ("clutter-text", props[PROP_CLUTTER_TEXT] =
"Clutter Text", g_param_spec_object ("clutter-text",
"Internal ClutterText actor", "Clutter Text",
CLUTTER_TYPE_TEXT, "Internal ClutterText actor",
ST_PARAM_READABLE); CLUTTER_TYPE_TEXT,
g_object_class_install_property (gobject_class, PROP_CLUTTER_TEXT, pspec); ST_PARAM_READABLE);
pspec = g_param_spec_string ("text", props[PROP_TEXT] =
"Text", g_param_spec_string ("text",
"Text of the label", "Text",
NULL, "Text of the label",
ST_PARAM_READWRITE); NULL,
g_object_class_install_property (gobject_class, PROP_TEXT, pspec); ST_PARAM_READWRITE);
g_object_class_install_properties (gobject_class, N_PROPS, props);
} }
static void static void
@ -359,7 +363,7 @@ st_label_set_text (StLabel *label,
clutter_text_set_text (ctext, text); clutter_text_set_text (ctext, text);
g_object_notify (G_OBJECT (label), "text"); g_object_notify_by_pspec (G_OBJECT (label), props[PROP_TEXT]);
} }
} }

View File

@ -79,9 +79,13 @@ enum
PROP_0, PROP_0,
PROP_ADJUSTMENT, PROP_ADJUSTMENT,
PROP_VERTICAL PROP_VERTICAL,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
enum enum
{ {
SCROLL_START, SCROLL_START,
@ -504,7 +508,6 @@ st_scroll_bar_class_init (StScrollBarClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass); StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
GParamSpec *pspec;
object_class->get_property = st_scroll_bar_get_property; object_class->get_property = st_scroll_bar_get_property;
object_class->set_property = st_scroll_bar_set_property; object_class->set_property = st_scroll_bar_set_property;
@ -519,21 +522,19 @@ st_scroll_bar_class_init (StScrollBarClass *klass)
widget_class->style_changed = st_scroll_bar_style_changed; widget_class->style_changed = st_scroll_bar_style_changed;
g_object_class_install_property props[PROP_ADJUSTMENT] =
(object_class, g_param_spec_object ("adjustment", "Adjustment", "The adjustment",
PROP_ADJUSTMENT, ST_TYPE_ADJUSTMENT,
g_param_spec_object ("adjustment", ST_PARAM_READWRITE);
"Adjustment",
"The adjustment",
ST_TYPE_ADJUSTMENT,
ST_PARAM_READWRITE));
pspec = g_param_spec_boolean ("vertical", props[PROP_VERTICAL] =
"Vertical Orientation", g_param_spec_boolean ("vertical",
"Vertical Orientation", "Vertical Orientation",
FALSE, "Vertical Orientation",
ST_PARAM_READWRITE); FALSE,
g_object_class_install_property (object_class, PROP_VERTICAL, pspec); ST_PARAM_READWRITE);
g_object_class_install_properties (object_class, N_PROPS, props);
signals[SCROLL_START] = signals[SCROLL_START] =
g_signal_new ("scroll-start", g_signal_new ("scroll-start",
@ -959,7 +960,7 @@ st_scroll_bar_set_adjustment (StScrollBar *bar,
clutter_actor_queue_relayout (CLUTTER_ACTOR (bar)); clutter_actor_queue_relayout (CLUTTER_ACTOR (bar));
} }
g_object_notify (G_OBJECT (bar), "adjustment"); g_object_notify_by_pspec (G_OBJECT (bar), props[PROP_ADJUSTMENT]);
} }
/** /**

View File

@ -59,9 +59,13 @@ enum {
PROP_VFADE_OFFSET, PROP_VFADE_OFFSET,
PROP_HFADE_OFFSET, PROP_HFADE_OFFSET,
PROP_FADE_EDGES PROP_FADE_EDGES,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
static CoglTexture * static CoglTexture *
st_scroll_view_fade_create_texture (ClutterOffscreenEffect *effect, st_scroll_view_fade_create_texture (ClutterOffscreenEffect *effect,
gfloat min_width, gfloat min_width,
@ -273,7 +277,7 @@ st_scroll_view_vfade_set_offset (StScrollViewFade *self,
if (self->actor != NULL) if (self->actor != NULL)
clutter_actor_queue_redraw (self->actor); clutter_actor_queue_redraw (self->actor);
g_object_notify (G_OBJECT (self), "vfade-offset"); g_object_notify_by_pspec (G_OBJECT (self), props[PROP_VFADE_OFFSET]);
g_object_thaw_notify (G_OBJECT (self)); g_object_thaw_notify (G_OBJECT (self));
} }
@ -291,7 +295,7 @@ st_scroll_view_hfade_set_offset (StScrollViewFade *self,
if (self->actor != NULL) if (self->actor != NULL)
clutter_actor_queue_redraw (self->actor); clutter_actor_queue_redraw (self->actor);
g_object_notify (G_OBJECT (self), "hfade-offset"); g_object_notify_by_pspec (G_OBJECT (self), props[PROP_HFADE_OFFSET]);
g_object_thaw_notify (G_OBJECT (self)); g_object_thaw_notify (G_OBJECT (self));
} }
@ -309,7 +313,7 @@ st_scroll_view_fade_set_fade_edges (StScrollViewFade *self,
if (self->actor != NULL) if (self->actor != NULL)
clutter_actor_queue_redraw (self->actor); clutter_actor_queue_redraw (self->actor);
g_object_notify (G_OBJECT (self), "fade-edges"); g_object_notify_by_pspec (G_OBJECT (self), props[PROP_FADE_EDGES]);
g_object_thaw_notify (G_OBJECT (self)); g_object_thaw_notify (G_OBJECT (self));
} }
@ -384,29 +388,28 @@ st_scroll_view_fade_class_init (StScrollViewFadeClass *klass)
offscreen_class->create_texture = st_scroll_view_fade_create_texture; offscreen_class->create_texture = st_scroll_view_fade_create_texture;
offscreen_class->paint_target = st_scroll_view_fade_paint_target; offscreen_class->paint_target = st_scroll_view_fade_paint_target;
g_object_class_install_property (gobject_class, props[PROP_VFADE_OFFSET] =
PROP_VFADE_OFFSET, g_param_spec_float ("vfade-offset",
g_param_spec_float ("vfade-offset", "Vertical Fade Offset",
"Vertical Fade Offset", "The height of the area which is faded at the edge",
"The height of the area which is faded at the edge", 0.f, G_MAXFLOAT, DEFAULT_FADE_OFFSET,
0.f, G_MAXFLOAT, DEFAULT_FADE_OFFSET, ST_PARAM_READWRITE);
ST_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_HFADE_OFFSET,
g_param_spec_float ("hfade-offset",
"Horizontal Fade Offset",
"The width of the area which is faded at the edge",
0.f, G_MAXFLOAT, DEFAULT_FADE_OFFSET,
ST_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_FADE_EDGES,
g_param_spec_boolean ("fade-edges",
"Fade Edges",
"Whether the faded area should extend to the edges",
FALSE,
ST_PARAM_READWRITE));
props[PROP_HFADE_OFFSET] =
g_param_spec_float ("hfade-offset",
"Horizontal Fade Offset",
"The width of the area which is faded at the edge",
0.f, G_MAXFLOAT, DEFAULT_FADE_OFFSET,
ST_PARAM_READWRITE);
props[PROP_FADE_EDGES] =
g_param_spec_boolean ("fade-edges",
"Fade Edges",
"Whether the faded area should extend to the edges",
FALSE,
ST_PARAM_READWRITE);
g_object_class_install_properties (gobject_class, N_PROPS, props);
} }
static void static void

View File

@ -116,8 +116,12 @@ enum {
PROP_VSCROLLBAR_VISIBLE, PROP_VSCROLLBAR_VISIBLE,
PROP_MOUSE_SCROLL, PROP_MOUSE_SCROLL,
PROP_OVERLAY_SCROLLBARS, PROP_OVERLAY_SCROLLBARS,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
static void static void
st_scroll_view_get_property (GObject *object, st_scroll_view_get_property (GObject *object,
guint property_id, guint property_id,
@ -693,7 +697,8 @@ st_scroll_view_allocate (ClutterActor *actor,
{ {
g_object_freeze_notify (G_OBJECT (actor)); g_object_freeze_notify (G_OBJECT (actor));
priv->hscrollbar_visible = hscrollbar_visible; priv->hscrollbar_visible = hscrollbar_visible;
g_object_notify (G_OBJECT (actor), "hscrollbar-visible"); g_object_notify_by_pspec (G_OBJECT (actor),
props[PROP_HSCROLLBAR_VISIBLE]);
g_object_thaw_notify (G_OBJECT (actor)); g_object_thaw_notify (G_OBJECT (actor));
} }
@ -701,7 +706,8 @@ st_scroll_view_allocate (ClutterActor *actor,
{ {
g_object_freeze_notify (G_OBJECT (actor)); g_object_freeze_notify (G_OBJECT (actor));
priv->vscrollbar_visible = vscrollbar_visible; priv->vscrollbar_visible = vscrollbar_visible;
g_object_notify (G_OBJECT (actor), "vscrollbar-visible"); g_object_notify_by_pspec (G_OBJECT (actor),
props[PROP_VSCROLLBAR_VISIBLE]);
g_object_thaw_notify (G_OBJECT (actor)); g_object_thaw_notify (G_OBJECT (actor));
} }
@ -791,7 +797,6 @@ st_scroll_view_scroll_event (ClutterActor *self,
static void static void
st_scroll_view_class_init (StScrollViewClass *klass) st_scroll_view_class_init (StScrollViewClass *klass)
{ {
GParamSpec *pspec;
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass); StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
@ -810,70 +815,65 @@ st_scroll_view_class_init (StScrollViewClass *klass)
widget_class->style_changed = st_scroll_view_style_changed; widget_class->style_changed = st_scroll_view_style_changed;
g_object_class_install_property (object_class, props[PROP_HSCROLL] =
PROP_HSCROLL, g_param_spec_object ("hscroll",
g_param_spec_object ("hscroll", "StScrollBar",
"StScrollBar", "Horizontal scroll indicator",
"Horizontal scroll indicator", ST_TYPE_SCROLL_BAR,
ST_TYPE_SCROLL_BAR, ST_PARAM_READABLE);
ST_PARAM_READABLE));
g_object_class_install_property (object_class, props[PROP_VSCROLL] =
PROP_VSCROLL, g_param_spec_object ("vscroll",
g_param_spec_object ("vscroll", "StScrollBar",
"StScrollBar", "Vertical scroll indicator",
"Vertical scroll indicator", ST_TYPE_SCROLL_BAR,
ST_TYPE_SCROLL_BAR, ST_PARAM_READABLE);
ST_PARAM_READABLE));
props[PROP_VSCROLLBAR_POLICY] =
g_param_spec_enum ("vscrollbar-policy",
"Vertical Scrollbar Policy",
"When the vertical scrollbar is displayed",
ST_TYPE_POLICY_TYPE,
ST_POLICY_AUTOMATIC,
ST_PARAM_READWRITE);
pspec = g_param_spec_enum ("vscrollbar-policy", props[PROP_HSCROLLBAR_POLICY] =
"Vertical Scrollbar Policy", g_param_spec_enum ("hscrollbar-policy",
"When the vertical scrollbar is displayed", "Horizontal Scrollbar Policy",
ST_TYPE_POLICY_TYPE, "When the horizontal scrollbar is displayed",
ST_POLICY_AUTOMATIC, ST_TYPE_POLICY_TYPE,
ST_PARAM_READWRITE); ST_POLICY_AUTOMATIC,
g_object_class_install_property (object_class, PROP_VSCROLLBAR_POLICY, pspec); ST_PARAM_READWRITE);
pspec = g_param_spec_enum ("hscrollbar-policy", props[PROP_HSCROLLBAR_VISIBLE] =
"Horizontal Scrollbar Policy", g_param_spec_boolean ("hscrollbar-visible",
"When the horizontal scrollbar is displayed", "Horizontal Scrollbar Visibility",
ST_TYPE_POLICY_TYPE, "Whether the horizontal scrollbar is visible",
ST_POLICY_AUTOMATIC, TRUE,
ST_PARAM_READWRITE); ST_PARAM_READABLE);
g_object_class_install_property (object_class, PROP_HSCROLLBAR_POLICY, pspec);
pspec = g_param_spec_boolean ("hscrollbar-visible", props[PROP_VSCROLLBAR_VISIBLE] =
"Horizontal Scrollbar Visibility", g_param_spec_boolean ("vscrollbar-visible",
"Whether the horizontal scrollbar is visible", "Vertical Scrollbar Visibility",
TRUE, "Whether the vertical scrollbar is visible",
ST_PARAM_READABLE); TRUE,
g_object_class_install_property (object_class, PROP_HSCROLLBAR_VISIBLE, pspec); ST_PARAM_READABLE);
pspec = g_param_spec_boolean ("vscrollbar-visible", props[PROP_MOUSE_SCROLL] =
"Vertical Scrollbar Visibility", g_param_spec_boolean ("enable-mouse-scrolling",
"Whether the vertical scrollbar is visible", "Enable Mouse Scrolling",
TRUE, "Enable automatic mouse wheel scrolling",
ST_PARAM_READABLE); TRUE,
g_object_class_install_property (object_class, PROP_VSCROLLBAR_VISIBLE, pspec); ST_PARAM_READWRITE);
pspec = g_param_spec_boolean ("enable-mouse-scrolling", props[PROP_OVERLAY_SCROLLBARS] =
"Enable Mouse Scrolling", g_param_spec_boolean ("overlay-scrollbars",
"Enable automatic mouse wheel scrolling", "Use Overlay Scrollbars",
TRUE, "Overlay scrollbars over the content",
ST_PARAM_READWRITE); FALSE,
g_object_class_install_property (object_class, ST_PARAM_READWRITE);
PROP_MOUSE_SCROLL,
pspec);
pspec = g_param_spec_boolean ("overlay-scrollbars", g_object_class_install_properties (object_class, N_PROPS, props);
"Use Overlay Scrollbars",
"Overlay scrollbars over the content",
FALSE,
ST_PARAM_READWRITE);
g_object_class_install_property (object_class,
PROP_OVERLAY_SCROLLBARS,
pspec);
} }
static void static void
@ -1156,7 +1156,8 @@ st_scroll_view_set_overlay_scrollbars (StScrollView *scroll,
if (priv->overlay_scrollbars != enabled) if (priv->overlay_scrollbars != enabled)
{ {
priv->overlay_scrollbars = enabled; priv->overlay_scrollbars = enabled;
g_object_notify (G_OBJECT (scroll), "overlay-scrollbars"); g_object_notify_by_pspec (G_OBJECT (scroll),
props[PROP_OVERLAY_SCROLLBARS]);
clutter_actor_queue_relayout (CLUTTER_ACTOR (scroll)); clutter_actor_queue_relayout (CLUTTER_ACTOR (scroll));
} }
} }
@ -1206,13 +1207,15 @@ st_scroll_view_set_policy (StScrollView *scroll,
if (priv->hscrollbar_policy != hscroll) if (priv->hscrollbar_policy != hscroll)
{ {
priv->hscrollbar_policy = hscroll; priv->hscrollbar_policy = hscroll;
g_object_notify ((GObject *) scroll, "hscrollbar-policy"); g_object_notify_by_pspec ((GObject *) scroll,
props[PROP_HSCROLLBAR_POLICY]);
} }
if (priv->vscrollbar_policy != vscroll) if (priv->vscrollbar_policy != vscroll)
{ {
priv->vscrollbar_policy = vscroll; priv->vscrollbar_policy = vscroll;
g_object_notify ((GObject *) scroll, "vscrollbar-policy"); g_object_notify_by_pspec ((GObject *) scroll,
props[PROP_VSCROLLBAR_POLICY]);
} }
clutter_actor_queue_relayout (CLUTTER_ACTOR (scroll)); clutter_actor_queue_relayout (CLUTTER_ACTOR (scroll));

View File

@ -115,9 +115,13 @@ enum
PROP_CAN_FOCUS, PROP_CAN_FOCUS,
PROP_LABEL_ACTOR, PROP_LABEL_ACTOR,
PROP_ACCESSIBLE_ROLE, PROP_ACCESSIBLE_ROLE,
PROP_ACCESSIBLE_NAME PROP_ACCESSIBLE_NAME,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
enum enum
{ {
STYLE_CHANGED, STYLE_CHANGED,
@ -834,7 +838,6 @@ st_widget_class_init (StWidgetClass *klass)
{ {
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GParamSpec *pspec;
gobject_class->set_property = st_widget_set_property; gobject_class->set_property = st_widget_set_property;
gobject_class->get_property = st_widget_get_property; gobject_class->get_property = st_widget_get_property;
@ -869,25 +872,24 @@ st_widget_class_init (StWidgetClass *klass)
* The pseudo-class of the actor. Typical values include "hover", "active", * The pseudo-class of the actor. Typical values include "hover", "active",
* "focus". * "focus".
*/ */
g_object_class_install_property (gobject_class, props[PROP_PSEUDO_CLASS] =
PROP_PSEUDO_CLASS, g_param_spec_string ("pseudo-class",
g_param_spec_string ("pseudo-class", "Pseudo Class",
"Pseudo Class", "Pseudo class for styling",
"Pseudo class for styling", "",
"", ST_PARAM_READWRITE);
ST_PARAM_READWRITE));
/** /**
* StWidget:style-class: * StWidget:style-class:
* *
* The style-class of the actor for use in styling. * The style-class of the actor for use in styling.
*/ */
g_object_class_install_property (gobject_class, props[PROP_STYLE_CLASS] =
PROP_STYLE_CLASS, g_param_spec_string ("style-class",
g_param_spec_string ("style-class", "Style Class",
"Style Class", "Style class for styling",
"Style class for styling", "",
"", ST_PARAM_READWRITE);
ST_PARAM_READWRITE));
/** /**
* StWidget:style: * StWidget:style:
@ -895,13 +897,12 @@ st_widget_class_init (StWidgetClass *klass)
* Inline style information for the actor as a ';'-separated list of * Inline style information for the actor as a ';'-separated list of
* CSS properties. * CSS properties.
*/ */
g_object_class_install_property (gobject_class, props[PROP_STYLE] =
PROP_STYLE, g_param_spec_string ("style",
g_param_spec_string ("style", "Style",
"Style", "Inline style string",
"Inline style string", "",
"", ST_PARAM_READWRITE);
ST_PARAM_READWRITE));
/** /**
* StWidget:theme: * StWidget:theme:
@ -909,13 +910,12 @@ st_widget_class_init (StWidgetClass *klass)
* A theme set on this actor overriding the global theming for this actor * A theme set on this actor overriding the global theming for this actor
* and its descendants * and its descendants
*/ */
g_object_class_install_property (gobject_class, props[PROP_THEME] =
PROP_THEME, g_param_spec_object ("theme",
g_param_spec_object ("theme", "Theme",
"Theme", "Theme override",
"Theme override", ST_TYPE_THEME,
ST_TYPE_THEME, ST_PARAM_READWRITE);
ST_PARAM_READWRITE));
/** /**
* StWidget:track-hover: * StWidget:track-hover:
@ -926,14 +926,12 @@ st_widget_class_init (StWidgetClass *klass)
* adjusted automatically as the pointer moves in and out of the * adjusted automatically as the pointer moves in and out of the
* widget. * widget.
*/ */
pspec = g_param_spec_boolean ("track-hover", props[PROP_TRACK_HOVER] =
"Track hover", g_param_spec_object ("track-hover",
"Determines whether the widget tracks hover state", "Track hover",
FALSE, "Determines whether the widget tracks hover state",
ST_PARAM_READWRITE); FALSE,
g_object_class_install_property (gobject_class, ST_PARAM_READWRITE);
PROP_TRACK_HOVER,
pspec);
/** /**
* StWidget:hover: * StWidget:hover:
@ -942,68 +940,63 @@ st_widget_class_init (StWidgetClass *klass)
* only tracked automatically if #StWidget:track-hover is %TRUE, but you can * only tracked automatically if #StWidget:track-hover is %TRUE, but you can
* adjust it manually in any case. * adjust it manually in any case.
*/ */
pspec = g_param_spec_boolean ("hover", props[PROP_HOVER] =
"Hover", g_param_spec_boolean ("hover",
"Whether the pointer is hovering over the widget", "Hover",
FALSE, "Whether the pointer is hovering over the widget",
ST_PARAM_READWRITE); FALSE,
g_object_class_install_property (gobject_class, ST_PARAM_READWRITE);
PROP_HOVER,
pspec);
/** /**
* StWidget:can-focus: * StWidget:can-focus:
* *
* Whether or not the widget can be focused via keyboard navigation. * Whether or not the widget can be focused via keyboard navigation.
*/ */
pspec = g_param_spec_boolean ("can-focus", props[PROP_CAN_FOCUS] =
"Can focus", g_param_spec_boolean ("can-focus",
"Whether the widget can be focused via keyboard navigation", "Can focus",
FALSE, "Whether the widget can be focused via keyboard navigation",
ST_PARAM_READWRITE); FALSE,
g_object_class_install_property (gobject_class, ST_PARAM_READWRITE);
PROP_CAN_FOCUS,
pspec);
/** /**
* ClutterActor:label-actor: * ClutterActor:label-actor:
* *
* An actor that labels this widget. * An actor that labels this widget.
*/ */
g_object_class_install_property (gobject_class, props[PROP_LABEL_ACTOR] =
PROP_LABEL_ACTOR, g_param_spec_object ("label-actor",
g_param_spec_object ("label-actor", "Label",
"Label", "Label that identifies this widget",
"Label that identifies this widget", CLUTTER_TYPE_ACTOR,
CLUTTER_TYPE_ACTOR, ST_PARAM_READWRITE);
ST_PARAM_READWRITE));
/** /**
* StWidget:accessible-role: * StWidget:accessible-role:
* *
* The accessible role of this object * The accessible role of this object
*/ */
g_object_class_install_property (gobject_class, props[PROP_ACCESSIBLE_ROLE] =
PROP_ACCESSIBLE_ROLE, g_param_spec_enum ("accessible-role",
g_param_spec_enum ("accessible-role", "Accessible Role",
"Accessible Role", "The accessible role of this object",
"The accessible role of this object", ATK_TYPE_ROLE,
ATK_TYPE_ROLE, ATK_ROLE_INVALID,
ATK_ROLE_INVALID, ST_PARAM_READWRITE);
ST_PARAM_READWRITE));
/** /**
* StWidget:accessible-name: * StWidget:accessible-name:
* *
* Object instance's name for assistive technology access. * Object instance's name for assistive technology access.
*/ */
g_object_class_install_property (gobject_class, props[PROP_ACCESSIBLE_NAME] =
PROP_ACCESSIBLE_NAME, g_param_spec_string ("accessible-name",
g_param_spec_string ("accessible-name", "Accessible name",
"Accessible name", "Object instance's name for assistive technology access.",
"Object instance's name for assistive technology access.", NULL,
NULL, ST_PARAM_READWRITE);
ST_PARAM_READWRITE));
g_object_class_install_properties (gobject_class, N_PROPS, props);
/** /**
* StWidget::style-changed: * StWidget::style-changed:
@ -1077,7 +1070,7 @@ st_widget_set_theme (StWidget *actor,
st_widget_style_changed (actor); st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "theme"); g_object_notify_by_pspec (G_OBJECT (actor), props[PROP_THEME]);
} }
} }
@ -1213,7 +1206,7 @@ st_widget_set_style_class_name (StWidget *actor,
if (set_class_list (&priv->style_class, style_class_list)) if (set_class_list (&priv->style_class, style_class_list))
{ {
st_widget_style_changed (actor); st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "style-class"); g_object_notify_by_pspec (G_OBJECT (actor), props[PROP_STYLE_CLASS]);
} }
} }
@ -1239,7 +1232,7 @@ st_widget_add_style_class_name (StWidget *actor,
if (add_class_name (&priv->style_class, style_class)) if (add_class_name (&priv->style_class, style_class))
{ {
st_widget_style_changed (actor); st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "style-class"); g_object_notify_by_pspec (G_OBJECT (actor), props[PROP_STYLE_CLASS]);
} }
} }
@ -1265,7 +1258,7 @@ st_widget_remove_style_class_name (StWidget *actor,
if (remove_class_name (&priv->style_class, style_class)) if (remove_class_name (&priv->style_class, style_class))
{ {
st_widget_style_changed (actor); st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "style-class"); g_object_notify_by_pspec (G_OBJECT (actor), props[PROP_STYLE_CLASS]);
} }
} }
@ -1376,7 +1369,7 @@ st_widget_set_style_pseudo_class (StWidget *actor,
if (set_class_list (&priv->pseudo_class, pseudo_class_list)) if (set_class_list (&priv->pseudo_class, pseudo_class_list))
{ {
st_widget_style_changed (actor); st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "pseudo-class"); g_object_notify_by_pspec (G_OBJECT (actor), props[PROP_PSEUDO_CLASS]);
} }
} }
@ -1402,7 +1395,7 @@ st_widget_add_style_pseudo_class (StWidget *actor,
if (add_class_name (&priv->pseudo_class, pseudo_class)) if (add_class_name (&priv->pseudo_class, pseudo_class))
{ {
st_widget_style_changed (actor); st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "pseudo-class"); g_object_notify_by_pspec (G_OBJECT (actor), props[PROP_PSEUDO_CLASS]);
} }
} }
@ -1427,7 +1420,7 @@ st_widget_remove_style_pseudo_class (StWidget *actor,
if (remove_class_name (&priv->pseudo_class, pseudo_class)) if (remove_class_name (&priv->pseudo_class, pseudo_class))
{ {
st_widget_style_changed (actor); st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "pseudo-class"); g_object_notify_by_pspec (G_OBJECT (actor), props[PROP_PSEUDO_CLASS]);
} }
} }
@ -1457,7 +1450,7 @@ st_widget_set_style (StWidget *actor,
st_widget_style_changed (actor); st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "style"); g_object_notify_by_pspec (G_OBJECT (actor), props[PROP_STYLE]);
} }
} }
@ -1907,7 +1900,7 @@ st_widget_set_track_hover (StWidget *widget,
if (priv->track_hover != track_hover) if (priv->track_hover != track_hover)
{ {
priv->track_hover = track_hover; priv->track_hover = track_hover;
g_object_notify (G_OBJECT (widget), "track-hover"); g_object_notify_by_pspec (G_OBJECT (widget), props[PROP_TRACK_HOVER]);
if (priv->track_hover) if (priv->track_hover)
st_widget_sync_hover (widget); st_widget_sync_hover (widget);
@ -1962,7 +1955,7 @@ st_widget_set_hover (StWidget *widget,
st_widget_add_style_pseudo_class (widget, "hover"); st_widget_add_style_pseudo_class (widget, "hover");
else else
st_widget_remove_style_pseudo_class (widget, "hover"); st_widget_remove_style_pseudo_class (widget, "hover");
g_object_notify (G_OBJECT (widget), "hover"); g_object_notify_by_pspec (G_OBJECT (widget), props[PROP_HOVER]);
} }
} }
@ -2029,7 +2022,7 @@ st_widget_set_can_focus (StWidget *widget,
if (priv->can_focus != can_focus) if (priv->can_focus != can_focus)
{ {
priv->can_focus = can_focus; priv->can_focus = can_focus;
g_object_notify (G_OBJECT (widget), "can-focus"); g_object_notify_by_pspec (G_OBJECT (widget), props[PROP_CAN_FOCUS]);
} }
} }
@ -2526,7 +2519,7 @@ st_widget_set_label_actor (StWidget *widget,
else else
priv->label_actor = NULL; priv->label_actor = NULL;
g_object_notify (G_OBJECT (widget), "label-actor"); g_object_notify_by_pspec (G_OBJECT (widget), props[PROP_LABEL_ACTOR]);
} }
} }
@ -2559,7 +2552,7 @@ st_widget_set_accessible_name (StWidget *widget,
g_free (priv->accessible_name); g_free (priv->accessible_name);
priv->accessible_name = g_strdup (name); priv->accessible_name = g_strdup (name);
g_object_notify (G_OBJECT (widget), "accessible-name"); g_object_notify_by_pspec (G_OBJECT (widget), props[PROP_ACCESSIBLE_NAME]);
} }
/** /**
@ -2613,7 +2606,7 @@ st_widget_set_accessible_role (StWidget *widget,
priv = st_widget_get_instance_private (widget); priv = st_widget_get_instance_private (widget);
priv->accessible_role = role; priv->accessible_role = role;
g_object_notify (G_OBJECT (widget), "accessible-role"); g_object_notify_by_pspec (G_OBJECT (widget), props[PROP_ACCESSIBLE_ROLE]);
} }