diff options
author | Colin Walters <walters@verbum.org> | 2011-11-30 17:26:59 -0500 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2011-12-08 18:05:14 -0500 |
commit | 41e5ba86a791a17bb560dd7813ad7e849e0230dc (patch) | |
tree | 6da03b8324d8db0c07040465178b895907e30f80 /gio/gsimpleaction.c | |
parent | 76527e5cd5e864f1695b3afe0d6350e7546606bb (diff) | |
download | glib-41e5ba86a791a17bb560dd7813ad7e849e0230dc.tar.gz |
GSimpleAction: Fix to comply with constructor rules
foo_new_*() must be pure wrappers around g_object_new(), otherwise
their functionality is inaccessible to bindings.
Diffstat (limited to 'gio/gsimpleaction.c')
-rw-r--r-- | gio/gsimpleaction.c | 82 |
1 files changed, 49 insertions, 33 deletions
diff --git a/gio/gsimpleaction.c b/gio/gsimpleaction.c index c0d5340c8..d412e1dea 100644 --- a/gio/gsimpleaction.c +++ b/gio/gsimpleaction.c @@ -208,6 +208,37 @@ g_simple_action_activate (GAction *action, } static void +g_simple_action_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GSimpleAction *action = G_SIMPLE_ACTION (object); + + switch (prop_id) + { + case PROP_NAME: + action->name = g_strdup (g_value_get_string (value)); + break; + + case PROP_PARAMETER_TYPE: + action->parameter_type = g_value_dup_boxed (value); + break; + + case PROP_ENABLED: + action->enabled = g_value_get_boolean (value); + break; + + case PROP_STATE: + action->state = g_value_dup_variant (value); + break; + + default: + g_assert_not_reached (); + } +} + +static void g_simple_action_get_property (GObject *object, guint prop_id, GValue *value, @@ -280,6 +311,7 @@ g_simple_action_class_init (GSimpleActionClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); + object_class->set_property = g_simple_action_set_property; object_class->get_property = g_simple_action_get_property; object_class->finalize = g_simple_action_finalize; @@ -367,7 +399,8 @@ g_simple_action_class_init (GSimpleActionClass *class) P_("Action Name"), P_("The name used to invoke the action"), NULL, - G_PARAM_READABLE | + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); /** @@ -383,7 +416,8 @@ g_simple_action_class_init (GSimpleActionClass *class) P_("Parameter Type"), P_("The type of GVariant passed to activate()"), G_TYPE_VARIANT_TYPE, - G_PARAM_READABLE | + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); /** @@ -401,7 +435,8 @@ g_simple_action_class_init (GSimpleActionClass *class) P_("Enabled"), P_("If the action can be activated"), TRUE, - G_PARAM_READABLE | + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); /** @@ -433,7 +468,8 @@ g_simple_action_class_init (GSimpleActionClass *class) P_("The state the action is in"), G_VARIANT_TYPE_ANY, NULL, - G_PARAM_READABLE | + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); } @@ -483,19 +519,10 @@ GSimpleAction * g_simple_action_new (const gchar *name, const GVariantType *parameter_type) { - GSimpleAction *simple; - - g_return_val_if_fail (name != NULL, NULL); - - simple = g_object_new (G_TYPE_SIMPLE_ACTION, NULL); - simple->name = g_strdup (name); - - if (parameter_type) - simple->parameter_type = g_variant_type_copy (parameter_type); - - simple->enabled = TRUE; - - return simple; + return (GSimpleAction*) g_object_new (G_TYPE_SIMPLE_ACTION, + "name", name, + "parameter-type", parameter_type, + NULL); } /** @@ -520,20 +547,9 @@ g_simple_action_new_stateful (const gchar *name, const GVariantType *parameter_type, GVariant *state) { - GSimpleAction *simple; - - g_return_val_if_fail (name != NULL, NULL); - g_return_val_if_fail (state != NULL, NULL); - - simple = g_object_new (G_TYPE_SIMPLE_ACTION, NULL); - simple->name = g_strdup (name); - - if (parameter_type) - simple->parameter_type = g_variant_type_copy (parameter_type); - - simple->state = g_variant_ref_sink (state); - - simple->enabled = TRUE; - - return simple; + return (GSimpleAction*) g_object_new (G_TYPE_SIMPLE_ACTION, + "name", name, + "parameter-type", parameter_type, + "state", state, + NULL); } |