/* 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 gom_resource_class_set_reference (GomResourceClass *resource_class, const gchar *property_name, const gchar *ref_table_name, const gchar *ref_property_name) { GParamSpec *pspec; g_return_if_fail(GOM_IS_RESOURCE_CLASS(resource_class)); g_return_if_fail(property_name != NULL); g_return_if_fail(ref_property_name != NULL); pspec = g_object_class_find_property(G_OBJECT_CLASS(resource_class), property_name); g_assert(pspec); if (ref_table_name == NULL) ref_table_name = G_OBJECT_CLASS_NAME(resource_class); g_param_spec_set_qdata_full(pspec, GOM_RESOURCE_REF_TABLE_CLASS, g_strdup(ref_table_name), g_free); g_param_spec_set_qdata_full(pspec, GOM_RESOURCE_REF_PROPERTY_NAME, g_strdup(ref_property_name), g_free); }
void gom_resource_class_set_notnull (GomResourceClass *resource_class, const gchar *property_name) { GParamSpec *pspec; g_return_if_fail(GOM_IS_RESOURCE_CLASS(resource_class)); g_return_if_fail(property_name != NULL); pspec = g_object_class_find_property(G_OBJECT_CLASS(resource_class), property_name); if (!pspec) { g_warning("NOT NULL property '%s' isn't declared yet. Are you running gom_resource_class_set_notnull() too early?", property_name); return; } g_param_spec_set_qdata_full(pspec, GOM_RESOURCE_NOTNULL, GUINT_TO_POINTER (TRUE), NULL); }