/* Register stylable property of a class */ void xfdashboard_actor_install_stylable_property(XfdashboardActorClass *klass, GParamSpec *inParamSpec) { GParamSpec *stylableParamSpec; g_return_if_fail(XFDASHBOARD_IS_ACTOR_CLASS(klass)); g_return_if_fail(G_IS_PARAM_SPEC(inParamSpec)); g_return_if_fail(inParamSpec->flags & G_PARAM_WRITABLE); g_return_if_fail(!(inParamSpec->flags & G_PARAM_CONSTRUCT_ONLY)); /* Check if param-spec is already registered */ if(g_param_spec_pool_lookup(_xfdashboard_actor_stylable_properties_pool, g_param_spec_get_name(inParamSpec), G_OBJECT_CLASS_TYPE(klass), FALSE)) { g_warning("Class '%s' already contains a stylable property '%s'", G_OBJECT_CLASS_NAME(klass), g_param_spec_get_name(inParamSpec)); return; } /* Add param-spec to pool of themable properties */ stylableParamSpec=g_param_spec_internal(G_PARAM_SPEC_TYPE(inParamSpec), g_param_spec_get_name(inParamSpec), NULL, NULL, 0); g_param_spec_set_qdata_full(stylableParamSpec, XFDASHBOARD_ACTOR_PARAM_SPEC_REF, g_param_spec_ref(inParamSpec), (GDestroyNotify)g_param_spec_unref); g_param_spec_pool_insert(_xfdashboard_actor_stylable_properties_pool, stylableParamSpec, G_OBJECT_CLASS_TYPE(klass)); XFDASHBOARD_DEBUG(NULL, STYLE, "Registered stylable property '%s' for class '%s'", g_param_spec_get_name(inParamSpec), G_OBJECT_CLASS_NAME(klass)); }
/** * tidy_stylable_iface_install_property: * @iface: a #TidyStylableIface * @owner_type: #GType of the style property owner * @pspec: a #GParamSpec * * Installs a property for @owner_type using @pspec as the property * description. * * This function should be used inside the #TidyStylableIface initialization * function of a class, for instance: * * <informalexample><programlisting> * G_DEFINE_TYPE_WITH_CODE (FooActor, foo_actor, CLUTTER_TYPE_ACTOR, * G_IMPLEMENT_INTERFACE (TIDY_TYPE_STYLABLE, * tidy_stylable_init)); * ... * static void * tidy_stylable_init (TidyStylableIface *iface) * { * static gboolean is_initialized = FALSE; * * if (!is_initialized) * { * ... * tidy_stylable_iface_install_property (stylable, * FOO_TYPE_ACTOR, * g_param_spec_int ("x-spacing", * "X Spacing", * "Horizontal spacing", * -1, G_MAXINT, * 2, * G_PARAM_READWRITE)); * ... * } * } * </programlisting></informalexample> */ void tidy_stylable_iface_install_property (TidyStylableIface *iface, GType owner_type, GParamSpec *pspec) { g_return_if_fail (TIDY_IS_STYLABLE_IFACE (iface)); g_return_if_fail (owner_type != G_TYPE_INVALID); g_return_if_fail (G_IS_PARAM_SPEC (pspec)); g_return_if_fail (pspec->flags & G_PARAM_READABLE); g_return_if_fail (!(pspec->flags & (G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT ))); if (g_param_spec_pool_lookup (style_property_spec_pool, pspec->name, owner_type, FALSE)) { g_warning ("%s: class `%s' already contains a style property named `%s'", G_STRLOC, g_type_name (owner_type), pspec->name); return; } g_param_spec_ref_sink (pspec); g_param_spec_set_qdata_full (pspec, quark_real_owner, g_strdup (g_type_name (owner_type)), g_free); g_param_spec_pool_insert (style_property_spec_pool, pspec, owner_type); }
void tidy_stylable_notify (TidyStylable *stylable, const gchar *property_name) { GParamSpec *pspec; g_return_if_fail (TIDY_IS_STYLABLE (stylable)); g_return_if_fail (property_name != NULL); g_object_ref (stylable); pspec = g_param_spec_pool_lookup (style_property_spec_pool, property_name, G_OBJECT_TYPE (stylable), TRUE); if (!pspec) g_warning ("%s: object class `%s' has no style property named `%s'", G_STRFUNC, G_OBJECT_TYPE_NAME (stylable), property_name); else { GObjectNotifyQueue *nqueue; nqueue = g_object_notify_queue_freeze (G_OBJECT (stylable), &property_notify_context); g_object_notify_queue_add (G_OBJECT (stylable), nqueue, pspec); g_object_notify_queue_thaw (G_OBJECT (stylable), nqueue); } g_object_unref (stylable); }
/** * goo_canvas_item_model_class_find_child_property: * @mclass: a #GObjectClass * @property_name: the name of the child property to find * * This function is only intended to be used when implementing new canvas * item models, specifically layout container item models such as * #GooCanvasTableModel. * * It finds a child property of a canvas item class by name. * * Returns: (type GObject.ParamSpec) (transfer none): The #GParamSpec of the child * property or %NULL if @class has no child property with that name. */ GParamSpec* goo_canvas_item_model_class_find_child_property (GObjectClass *mclass, const gchar *property_name) { g_return_val_if_fail (G_IS_OBJECT_CLASS (mclass), NULL); g_return_val_if_fail (property_name != NULL, NULL); return g_param_spec_pool_lookup (_goo_canvas_item_model_child_property_pool, property_name, G_OBJECT_CLASS_TYPE (mclass), TRUE); }
/** * tidy_stylable_find_property: * @stylable: a #TidyStylable * @property_name: the name of the property to find * * Finds the #GParamSpec installed by @stylable for the property * with @property_name. * * Return value: a #GParamSpec for the given property, or %NULL if * no property with that name was found */ GParamSpec * tidy_stylable_find_property (TidyStylable *stylable, const gchar *property_name) { g_return_val_if_fail (TIDY_IS_STYLABLE (stylable), NULL); g_return_val_if_fail (property_name != NULL, NULL); return g_param_spec_pool_lookup (style_property_spec_pool, property_name, G_OBJECT_TYPE (stylable), TRUE); }
/** * goo_canvas_item_model_class_install_child_property: * @mclass: a #GObjectClass * @property_id: the id for the property * @pspec: the #GParamSpec for the property * * This function is only intended to be used when implementing new canvas * item models, specifically layout container item models such as * #GooCanvasTableModel. * * It installs a child property on a canvas item class. **/ void goo_canvas_item_model_class_install_child_property (GObjectClass *mclass, guint property_id, GParamSpec *pspec) { g_return_if_fail (G_IS_OBJECT_CLASS (mclass)); g_return_if_fail (G_IS_PARAM_SPEC (pspec)); g_return_if_fail (property_id > 0); if (g_param_spec_pool_lookup (_goo_canvas_item_model_child_property_pool, pspec->name, G_OBJECT_CLASS_TYPE (mclass), FALSE)) { g_warning (G_STRLOC ": class `%s' already contains a child property named `%s'", G_OBJECT_CLASS_NAME (mclass), pspec->name); return; } g_param_spec_ref (pspec); g_param_spec_sink (pspec); pspec->param_id = property_id; g_param_spec_pool_insert (_goo_canvas_item_model_child_property_pool, pspec, G_OBJECT_CLASS_TYPE (mclass)); }