/** * 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 gimp_procedure_add_return_value (GimpProcedure *procedure, GParamSpec *pspec) { g_return_if_fail (GIMP_IS_PROCEDURE (procedure)); g_return_if_fail (G_IS_PARAM_SPEC (pspec)); procedure->values = g_renew (GParamSpec *, procedure->values, procedure->num_values + 1); procedure->values[procedure->num_values] = pspec; g_param_spec_ref_sink (pspec); procedure->num_values++; }
/* Helper function to create a new encoder property object */ static GstVaapiEncoderPropData * prop_new (gint id, GParamSpec * pspec) { GstVaapiEncoderPropData *prop; if (!id || !pspec) return NULL; prop = g_slice_new (GstVaapiEncoderPropData); if (!prop) return NULL; prop->prop = id; prop->pspec = g_param_spec_ref_sink (pspec); return prop; }
static void test_param_spec_char (void) { GParamSpec *pspec; GValue value = { 0, }; gboolean modified; pspec = g_param_spec_char ("char", "nick", "blurb", 20, 40, 30, G_PARAM_READWRITE); //g_param_spec_ref_force_floating(pspec); //g_assert(g_param_spec_is_floating(pspec)); g_param_spec_ref_sink(pspec); g_assert (strcmp (g_param_spec_get_name (pspec), "char") == 0); g_assert (strcmp (g_param_spec_get_nick (pspec), "nick") == 0); g_assert (strcmp (g_param_spec_get_blurb (pspec), "blurb") == 0); g_value_init (&value, G_TYPE_CHAR); g_value_set_char (&value, 30); g_assert (g_param_value_defaults (pspec, &value)); g_value_set_char (&value, 0); modified = g_param_value_validate (pspec, &value); g_assert (modified && g_value_get_char (&value) == 20); g_value_set_char (&value, 20); modified = g_param_value_validate (pspec, &value); g_assert (!modified && g_value_get_char (&value) == 20); g_value_set_char (&value, 40); modified = g_param_value_validate (pspec, &value); g_assert (!modified && g_value_get_char (&value) == 40); g_value_set_char (&value, 60); modified = g_param_value_validate (pspec, &value); g_assert (modified && g_value_get_char (&value) == 40); g_param_spec_unref (pspec); }
void ParamSpec::incref() const { if ( m_obj ) g_param_spec_ref_sink( (GParamSpec*) m_obj ); }