diff --git a/clutter/clutter-binding-pool.c b/clutter/clutter-binding-pool.c index 037b290c5..73398a58d 100644 --- a/clutter/clutter-binding-pool.c +++ b/clutter/clutter-binding-pool.c @@ -118,7 +118,7 @@ typedef struct _ClutterBindingPoolClass ClutterBindingPoolClass; typedef struct _ClutterBindingEntry ClutterBindingEntry; -static GSList *binding_pools = NULL; +static GSList *clutter_binding_pools = NULL; static GQuark key_class_bindings = 0; struct _ClutterBindingPool @@ -148,6 +148,13 @@ struct _ClutterBindingEntry guint is_blocked : 1; }; +enum +{ + PROP_0, + + PROP_NAME +}; + G_DEFINE_TYPE (ClutterBindingPool, clutter_binding_pool, G_TYPE_OBJECT); static guint @@ -223,7 +230,7 @@ clutter_binding_pool_finalize (GObject *gobject) ClutterBindingPool *pool = CLUTTER_BINDING_POOL (gobject); /* remove from the pools */ - binding_pools = g_slist_remove (binding_pools, pool); + clutter_binding_pools = g_slist_remove (clutter_binding_pools, pool); g_hash_table_destroy (pool->entries_hash); @@ -233,22 +240,95 @@ clutter_binding_pool_finalize (GObject *gobject) G_OBJECT_CLASS (clutter_binding_pool_parent_class)->finalize (gobject); } +static void +clutter_binding_pool_set_property (GObject *gobject, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ClutterBindingPool *pool = CLUTTER_BINDING_POOL (gobject); + + switch (prop_id) + { + case PROP_NAME: + pool->name = (gchar *) g_intern_string (g_value_get_string (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); + break; + } +} + +static void +clutter_binding_pool_get_property (GObject *gobject, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + ClutterBindingPool *pool = CLUTTER_BINDING_POOL (gobject); + + switch (prop_id) + { + case PROP_NAME: + g_value_set_string (value, pool->name); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); + break; + } +} + +static void +clutter_binding_pool_constructed (GObject *gobject) +{ + ClutterBindingPool *pool = CLUTTER_BINDING_POOL (gobject); + + /* bad monkey! bad, bad monkey! */ + if (G_UNLIKELY (pool->name == NULL)) + g_critical ("No name set for ClutterBindingPool %p", pool); + + if (G_OBJECT_CLASS (clutter_binding_pool_parent_class)->constructed) + G_OBJECT_CLASS (clutter_binding_pool_parent_class)->constructed (gobject); +} + static void clutter_binding_pool_class_init (ClutterBindingPoolClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GParamSpec *pspec = NULL; + gobject_class->constructed = clutter_binding_pool_constructed; + gobject_class->set_property = clutter_binding_pool_set_property; + gobject_class->get_property = clutter_binding_pool_get_property; gobject_class->finalize = clutter_binding_pool_finalize; + + /** + * ClutterBindingPool:name: + * + * The unique name of the #ClutterBindingPool. + * + * Since: 1.0 + */ + pspec = g_param_spec_string ("name", + "Name", + "The unique name of the binding pool", + NULL, + CLUTTER_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY); + g_object_class_install_property (gobject_class, PROP_NAME, pspec); } static void clutter_binding_pool_init (ClutterBindingPool *pool) { + pool->name = NULL; pool->entries = NULL; pool->entries_hash = g_hash_table_new (binding_entry_hash, binding_entry_compare); - binding_pools = g_slist_prepend (binding_pools, pool); + clutter_binding_pools = g_slist_prepend (clutter_binding_pools, pool); } /** @@ -261,8 +341,7 @@ clutter_binding_pool_init (ClutterBindingPool *pool) * be able to return the correct binding pool. * * Return value: the newly created binding pool with the given - * name. The binding pool is owned by Clutter and should not - * be freed directly + * name. Use g_object_unref() when done. * * Since: 1.0 */ @@ -282,10 +361,7 @@ clutter_binding_pool_new (const gchar *name) return NULL; } - pool = g_object_new (CLUTTER_TYPE_BINDING_POOL, NULL); - pool->name = (gchar *) g_intern_string (name); - - return pool; + return g_object_new (CLUTTER_TYPE_BINDING_POOL, "name", name, NULL); } /** @@ -352,7 +428,7 @@ clutter_binding_pool_find (const gchar *name) g_return_val_if_fail (name != NULL, NULL); - for (l = binding_pools; l != NULL; l = l->next) + for (l = clutter_binding_pools; l != NULL; l = l->next) { ClutterBindingPool *pool = l->data;