static void gimp_procedure_finalize (GObject *object) { GimpProcedure *procedure = GIMP_PROCEDURE (object); gint i; gimp_procedure_free_strings (procedure); if (procedure->args) { for (i = 0; i < procedure->num_args; i++) g_param_spec_unref (procedure->args[i]); g_free (procedure->args); procedure->args = NULL; } if (procedure->values) { for (i = 0; i < procedure->num_values; i++) g_param_spec_unref (procedure->values[i]); g_free (procedure->values); procedure->values = NULL; } G_OBJECT_CLASS (parent_class)->finalize (object); }
/** * initilize/override parent class methods, create signals, properties. */ static void mdw_dvb_demux_class_init (MdwDvbDemuxClass *klass) { /* top ancestral */ GObjectClass *gobject_class = G_OBJECT_CLASS (klass); /* private alocation */ g_type_class_add_private (klass, sizeof (MdwDvbDemuxPrivate)); /* methods */ //klass->method1 = mdw_dvb_demux_method1; //klass->method2 = mdw_dvb_demux_method2; /* destructors */ gobject_class->dispose = mdw_dvb_demux_dispose; gobject_class->finalize = mdw_dvb_demux_finalize; /* properties */ GParamSpec *pspec; gobject_class->set_property = mdw_dvb_demux_set_property; gobject_class->get_property = mdw_dvb_demux_get_property; /* Property demux-device (type: string) (contruct_only) (read/write) */ pspec = g_param_spec_string( "demux-device", //name "Demux device", //nick "Set/Get the demux device", //description DVB_BASE"/demux0", //default value G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY //flags ); g_object_class_install_property(gobject_class, MDW_DVB_DEMUX_DEMUX_DEVICE, pspec); g_param_spec_unref(pspec); /* Property dvr-device (type: string) (read/write) (contruct_only) */ pspec = g_param_spec_string( "dvr-device", //name "DVR device", //nick "Set/Get the DVR device", //description DVB_BASE"/dvr0", //default value G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY //flags ); g_object_class_install_property(gobject_class, MDW_DVB_DEMUX_DVR_DEVICE, pspec); g_param_spec_unref(pspec); /* signals */ /* chain-up */ }
static void _ges_container_remove_child_properties (GESContainer * container, GESTimelineElement * child) { guint n_props, i; GParamSpec **child_props = ges_timeline_element_list_children_properties (child, &n_props); for (i = 0; i < n_props; i++) { GObject *prop_child; if (ges_timeline_element_lookup_child (child, child_props[i]->name, &prop_child, NULL)) { ges_timeline_element_remove_child_property (GES_TIMELINE_ELEMENT (container), child_props[i]); } g_param_spec_unref (child_props[i]); } g_free (child_props); }
static GrlKeyID register_metadata_key (GrlRegistry *registry, const char *name, const char *nick, const char *blurb) { GParamSpec *spec; GrlKeyID key; spec = g_param_spec_string (name, nick, blurb, NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); key = grl_registry_register_metadata_key (registry, spec, NULL); g_param_spec_unref (spec); if (key == GRL_METADATA_KEY_INVALID) { key = grl_registry_lookup_metadata_key (registry, name); if (grl_metadata_key_get_type (key) != G_TYPE_STRING) { key = GRL_METADATA_KEY_INVALID; } } return key; }
static void pspec_free(pspec_holder *holder) { if (holder->instance) { rbgobj_instance_call_cinfo_free(holder->instance); g_param_spec_set_qdata(holder->instance, qparamspec, NULL); g_param_spec_unref(holder->instance); } free(holder); }
/* Helper function to release a property object and any memory held herein */ static void prop_free (GstVaapiEncoderPropData * prop) { if (!prop) return; if (prop->pspec) { g_param_spec_unref (prop->pspec); prop->pspec = NULL; } g_slice_free (GstVaapiEncoderPropData, prop); }
void gegl_pad_set_param_spec (GeglPad *self, GParamSpec *param_spec) { g_return_if_fail (GEGL_IS_PAD (self)); if (self->param_spec) g_param_spec_unref (self->param_spec); self->param_spec = g_param_spec_ref (param_spec); gegl_pad_set_name (self, g_param_spec_get_name (param_spec)); }
static void obex_agent_manager_class_init(ObexAgentManagerClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); gobject_class->dispose = obex_agent_manager_dispose; /* Properties registration */ GParamSpec *pspec = NULL; gobject_class->get_property = _obex_agent_manager_get_property; gobject_class->set_property = _obex_agent_manager_set_property; if (pspec) g_param_spec_unref(pspec); }
static void param_value_array_finalize (GParamSpec *pspec) { GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec); GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_VALUE_ARRAY)); if (aspec->element_spec) { g_param_spec_unref (aspec->element_spec); aspec->element_spec = NULL; } parent_class->finalize (pspec); }
static void prop_value_free (PropValue * prop_value) { if (!prop_value) return; if (G_VALUE_TYPE (&prop_value->value)) g_value_unset (&prop_value->value); if (prop_value->pspec) { g_param_spec_unref (prop_value->pspec); prop_value->pspec = NULL; } g_slice_free (PropValue, prop_value); }
static gboolean _set_child_property (GQuark field_id, const GValue * value, GESTrackElement * effect) { GParamSpec *pspec; GstElement *element; /* FIXME: error handling? */ if (!ges_track_element_lookup_child (effect, g_quark_to_string (field_id), &element, &pspec)) return TRUE; g_object_set_property (G_OBJECT (element), pspec->name, value); g_param_spec_unref (pspec); gst_object_unref (element); return TRUE; }
static gboolean param_param_validate (GParamSpec *pspec, GValue *value) { /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */ GParamSpec *param = value->data[0].v_pointer; guint changed = 0; if (param && !g_value_type_compatible (G_PARAM_SPEC_TYPE (param), G_PARAM_SPEC_VALUE_TYPE (pspec))) { g_param_spec_unref (param); value->data[0].v_pointer = NULL; changed++; } return changed; }
static void obex_phonebook_access_class_init(ObexPhonebookAccessClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); gobject_class->dispose = obex_phonebook_access_dispose; /* Properties registration */ GParamSpec *pspec = NULL; gobject_class->get_property = _obex_phonebook_access_get_property; gobject_class->set_property = _obex_phonebook_access_set_property; /* object DBusObjectPath [readwrite, construct only] */ pspec = g_param_spec_string("DBusObjectPath", "dbus_object_path", "ObexPhonebookAccess D-Bus object path", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); g_object_class_install_property(gobject_class, PROP_DBUS_OBJECT_PATH, pspec); if (pspec) g_param_spec_unref(pspec); }
static void proximity_monitor_class_init(ProximityMonitorClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); gobject_class->dispose = proximity_monitor_dispose; /* Properties registration */ GParamSpec *pspec = NULL; gobject_class->get_property = _proximity_monitor_get_property; gobject_class->set_property = _proximity_monitor_set_property; /* object DBusObjectPath [readwrite, construct only] */ pspec = g_param_spec_string("DBusObjectPath", "dbus_object_path", "ProximityMonitor D-Bus object path", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); g_object_class_install_property(gobject_class, PROP_DBUS_OBJECT_PATH, pspec); if (pspec) g_param_spec_unref(pspec); }
static void tidy_stylable_base_finalize (gpointer g_iface) { GList *list, *node; list = g_param_spec_pool_list_owned (style_property_spec_pool, G_TYPE_FROM_INTERFACE (g_iface)); for (node = list; node; node = node->next) { GParamSpec *pspec = node->data; g_param_spec_pool_remove (style_property_spec_pool, pspec); g_param_spec_unref (pspec); } g_list_free (list); }
static void param_finalize(JSFreeOp *fop, JSObject *obj) { Param *priv; priv = (Param*) JS_GetPrivate(obj); gjs_debug_lifecycle(GJS_DEBUG_GPARAM, "finalize, obj %p priv %p", obj, priv); if (priv == NULL) return; /* wrong class? */ if (priv->gparam) { g_param_spec_unref(priv->gparam); priv->gparam = NULL; } GJS_DEC_COUNTER(param); g_slice_free(Param, priv); }
static void param_finalize(JSContext *context, JSObject *obj) { Param *priv; priv = priv_from_js(context, obj); gjs_debug_lifecycle(GJS_DEBUG_GPARAM, "finalize, obj %p priv %p", obj, priv); if (priv == NULL) return; /* wrong class? */ if (priv->gparam) { g_param_spec_unref(priv->gparam); priv->gparam = NULL; } GJS_DEC_COUNTER(param); g_slice_free(Param, priv); }
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); }
static void af_transition_free (AfTransition *transition) { guint i; g_object_unref (transition->object); if (transition->child) g_object_unref (transition->child); for (i = 0; i < transition->properties->len; i++) { AfPropertyRange *property_range; property_range = &g_array_index (transition->properties, AfPropertyRange, i); g_param_spec_unref (property_range->pspec); } g_array_free (transition->properties, TRUE); g_slice_free (AfTransition, transition); }
/* Base class finalization */ void xfdashboard_actor_base_class_finalize(XfdashboardActorClass *klass) { GList *paramSpecs, *entry; paramSpecs=g_param_spec_pool_list_owned(_xfdashboard_actor_stylable_properties_pool, G_OBJECT_CLASS_TYPE(klass)); for(entry=paramSpecs; entry; entry=g_list_next(entry)) { GParamSpec *paramSpec=G_PARAM_SPEC(entry->data); if(paramSpec) { g_param_spec_pool_remove(_xfdashboard_actor_stylable_properties_pool, paramSpec); g_debug("Unregistered stylable property named '%s' for class '%s'", g_param_spec_get_name(paramSpec), G_OBJECT_CLASS_NAME(klass)); g_param_spec_unref(paramSpec); } } g_list_free(paramSpecs); }
PyObject * _pygi_marshal_to_py_object (GIArgument *arg, GITransfer transfer) { PyObject *pyobj; if (arg->v_pointer == NULL) { pyobj = Py_None; Py_INCREF (pyobj); } else if (G_IS_PARAM_SPEC(arg->v_pointer)) { pyobj = pyg_param_spec_new (arg->v_pointer); if (transfer == GI_TRANSFER_EVERYTHING) g_param_spec_unref (arg->v_pointer); } else { pyobj = pygobject_new_full (arg->v_pointer, /*steal=*/ transfer == GI_TRANSFER_EVERYTHING, /*type=*/ NULL); } return pyobj; }
static gboolean grl_bookmarks_plugin_init (GrlRegistry *registry, GrlPlugin *plugin, GList *configs) { GParamSpec *spec; GRL_LOG_DOMAIN_INIT (bookmarks_log_domain, "bookmarks"); GRL_DEBUG ("grl_bookmarks_plugin_init"); /* Initialize i18n */ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); spec = g_param_spec_boxed ("bookmark-date", "Bookmark date", "When the media was bookmarked", G_TYPE_DATE_TIME, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE), GRL_BOOKMARKS_KEY_BOOKMARK_TIME = grl_registry_register_metadata_key (registry, spec, NULL); /* If key was not registered, could be that it is already registered. If so, check if type is the expected one, and reuse it */ if (GRL_BOOKMARKS_KEY_BOOKMARK_TIME == GRL_METADATA_KEY_INVALID) { g_param_spec_unref (spec); GRL_BOOKMARKS_KEY_BOOKMARK_TIME = grl_registry_lookup_metadata_key (registry, "bookmark-date"); if (grl_metadata_key_get_type (GRL_BOOKMARKS_KEY_BOOKMARK_TIME) != G_TYPE_DATE_TIME) { GRL_BOOKMARKS_KEY_BOOKMARK_TIME = GRL_METADATA_KEY_INVALID; } } GrlBookmarksSource *source = grl_bookmarks_source_new (); grl_registry_register_source (registry, plugin, GRL_SOURCE (source), NULL); return TRUE; }
/** * gst_param_spec_fraction: * @name: canonical name of the property specified * @nick: nick name for the property specified * @blurb: description of the property specified * @min_num: minimum value (fraction numerator) * @min_denom: minimum value (fraction denominator) * @max_num: maximum value (fraction numerator) * @max_denom: maximum value (fraction denominator) * @default_num: default value (fraction numerator) * @default_denom: default value (fraction denominator) * @flags: flags for the property specified * * This function creates a fraction GParamSpec for use by objects/elements * that want to expose properties of fraction type. This function is typically * used in connection with g_object_class_install_property() in a GObjects's * instance_init function. * * Returns: a newly created parameter specification * * Since: 0.10.14 */ GParamSpec * gst_param_spec_fraction (const gchar * name, const gchar * nick, const gchar * blurb, gint min_num, gint min_denom, gint max_num, gint max_denom, gint default_num, gint default_denom, GParamFlags flags) { GstParamSpecFraction *fspec; GParamSpec *pspec; GValue default_val = { 0, }; fspec = g_param_spec_internal (GST_TYPE_PARAM_FRACTION, name, nick, blurb, flags); fspec->min_num = min_num; fspec->min_den = min_denom; fspec->max_num = max_num; fspec->max_den = max_denom; fspec->def_num = default_num; fspec->def_den = default_denom; pspec = G_PARAM_SPEC (fspec); /* check that min <= default <= max */ g_value_init (&default_val, GST_TYPE_FRACTION); gst_value_set_fraction (&default_val, default_num, default_denom); /* validate returns TRUE if the validation fails */ if (_gst_param_fraction_validate (pspec, &default_val)) { g_critical ("GstParamSpec of type 'fraction' for property '%s' has a " "default value of %d/%d, which is not within the allowed range of " "%d/%d to %d/%d", name, default_num, default_denom, min_num, min_denom, max_num, max_denom); g_param_spec_ref (pspec); g_param_spec_sink (pspec); g_param_spec_unref (pspec); pspec = NULL; } g_value_unset (&default_val); return pspec; }
/** * gst_vaapi_param_spec_id: * @name: canonical name of the property specified * @nick: nick name for the property specified * @blurb: description of the property specified * @default_value: default value * @flags: flags for the property specified * * This function creates an ID GParamSpec for use by #GstVaapiObject * objects. This function is typically used in connection with * g_object_class_install_property() in a GObjects's instance_init * function. * * Return value: a newly created parameter specification */ GParamSpec * gst_vaapi_param_spec_id( const gchar *name, const gchar *nick, const gchar *blurb, GstVaapiID default_value, GParamFlags flags ) { GstVaapiParamSpecID *ispec; GParamSpec *pspec; GValue value = { 0, }; ispec = g_param_spec_internal( GST_VAAPI_TYPE_PARAM_ID, name, nick, blurb, flags ); if (!ispec) return NULL; ispec->default_value = default_value; pspec = G_PARAM_SPEC(ispec); /* Validate default value */ g_value_init(&value, GST_VAAPI_TYPE_ID); gst_vaapi_value_set_id(&value, default_value); if (gst_vaapi_param_id_validate(pspec, &value)) { g_param_spec_ref(pspec); g_param_spec_sink(pspec); g_param_spec_unref(pspec); pspec = NULL; } g_value_unset(&value); return pspec; }
static void test_sanity_checker_fixture_do_cleanup (TestSanityCheckerFixture * fixture) { if (fixture->pspec != NULL) { g_param_spec_unref (fixture->pspec); fixture->pspec = NULL; } forget_block (&fixture->first_block); forget_block (&fixture->second_block); forget_block (&fixture->third_block); forget_object (&fixture->first_pony); if (fixture->second_pony != NULL) { g_object_unref (fixture->second_pony); forget_object (&fixture->second_pony); } forget_object (&fixture->first_zebra); forget_object (&fixture->second_zebra); }
/** * ppg_animation_finalize: * @object: (in): A #PpgAnimation. * * Finalizes the object and releases any resources allocated. * * Returns: None. * Side effects: None. */ static void ppg_animation_finalize (GObject *object) { PpgAnimationPrivate *priv = PPG_ANIMATION(object)->priv; Tween *tween; gint i; for (i = 0; i < priv->tweens->len; i++) { tween = &g_array_index(priv->tweens, Tween, i); g_value_unset(&tween->begin); g_value_unset(&tween->end); g_param_spec_unref(tween->pspec); } g_array_unref(priv->tweens); if (debug) { g_print("Rendered %d frames in %d msec animation.\n", priv->frame_count, priv->duration_msec); } G_OBJECT_CLASS(ppg_animation_parent_class)->finalize(object); }
void ParamSpec::decref() const { if ( m_obj ) g_param_spec_unref( (GParamSpec*) m_obj ); }
gint release_plgi_blob(atom_t a) { PLGIBlob *blob = PL_blob_data(a, NULL, NULL); PLGI_debug("[GC] releasing: <%s>%p", PL_atom_chars(blob->name), blob->data); if ( blob->magic != PLGI_BLOB_MAGIC) { return TRUE; } blob->magic = 0x0; switch ( blob->blob_type ) { case PLGI_BLOB_GOBJECT: { g_object_unref(blob->data); break; } case PLGI_BLOB_GPARAMSPEC: { g_param_spec_unref(blob->data); break; } case PLGI_BLOB_GVARIANT: { g_variant_unref(blob->data); break; } case PLGI_BLOB_SIMPLE: { if ( blob->is_owned ) { g_free(blob->data); } break; } case PLGI_BLOB_BOXED: { if ( blob->is_owned ) { g_boxed_free(blob->gtype, blob->data); } break; } case PLGI_BLOB_FOREIGN: { chokeme(PLGI_BLOB_FOREIGN); break; } case PLGI_BLOB_OPAQUE: { break; } case PLGI_BLOB_UNTYPED: { break; } default: { g_assert_not_reached(); } } return TRUE; }
Property::~Property() { for (auto &it : subscribed_handlers_) g_signal_handler_disconnect(object_, it.second); g_param_spec_unref(property_); g_object_unref(object_); }
static void parse_property(Log4gConfigurator *base, xmlNodePtr node, gpointer object) { GParamSpec *spec = NULL; xmlChar *name = xmlGetProp(node, (const xmlChar *)"name"); xmlChar *value = xmlGetProp(node, (const xmlChar *)"value"); if (!name) { log4g_log_error(Q_("properties must have a `name' attribute")); goto exit; } if (!value) { log4g_log_error(Q_("properties must have a " "`value' attribute")); goto exit; } spec = g_object_class_find_property(G_OBJECT_GET_CLASS(object), (gchar *)name); if (!spec) { log4g_log_error(Q_("object does not have the property `%s'"), (gchar *)name); goto exit; } if (G_TYPE_STRING == spec->value_type) { g_object_set(object, (const gchar *)name, (const gchar *)value, NULL); } else if (G_TYPE_BOOLEAN == spec->value_type) { if (!g_ascii_strcasecmp((const gchar *)value, "true")) { g_object_set(object, (const gchar *)name, TRUE, NULL); } else if (!g_ascii_strcasecmp((const gchar *)value, "false")) { g_object_set(object, (const gchar *)name, FALSE, NULL); } else { log4g_log_error(Q_("%s: not a boolean value " "(true|false)"), value); goto exit; } } else if (G_TYPE_CHAR == spec->value_type) { if (1 != strlen((const char *)value)) { log4g_log_error(Q_("%s: not a char"), value); goto exit; } g_object_set(object, (const gchar *)name, *value, NULL); } else if (G_TYPE_UCHAR == spec->value_type) { if (1 != strlen((const char *)value)) { log4g_log_error(Q_("%s: not an uchar"), value); goto exit; } g_object_set(object, (const gchar *)name, *value, NULL); } else if (G_TYPE_INT == spec->value_type) { gint64 i; errno = 0; i = g_ascii_strtoll((const char *)value, NULL, 10); if (errno) { log4g_log_error(Q_("%s: not an int"), value); goto exit; } g_object_set(object, (const char *)name, (gint)i, NULL); } else if (G_TYPE_UINT == spec->value_type) { guint64 i; errno = 0; i = g_ascii_strtoull((const char *)value, NULL, 10); if (errno) { log4g_log_error(Q_("%s: not an uint"), value); goto exit; } g_object_set(object, (const char *)name, (guint)i, NULL); } else if (G_TYPE_LONG == spec->value_type) { gint64 i; errno = 0; i = g_ascii_strtoll((const char *)value, NULL, 10); if (errno) { log4g_log_error(Q_("%s: not a long"), value); goto exit; } g_object_set(object, (const char *)name, (glong)i, NULL); } else if (G_TYPE_ULONG == spec->value_type) { guint64 i; errno = 0; i = g_ascii_strtoull((const char *)value, NULL, 10); if (errno) { log4g_log_error(Q_("%s: not an ulong"), value); goto exit; } g_object_set(object, (const char *)name, (gulong)i, NULL); } else if (G_TYPE_INT64 == spec->value_type) { gint64 i; errno = 0; i = g_ascii_strtoll((const char *)value, NULL, 10); if (errno) { log4g_log_error(Q_("%s: not an int64"), value); goto exit; } g_object_set(object, (const char *)name, i, NULL); } else if (G_TYPE_UINT64 == spec->value_type) { guint64 i; errno = 0; i = g_ascii_strtoull((const char *)value, NULL, 10); if (errno) { log4g_log_error(Q_("%s: not an uint64"), value); goto exit; } g_object_set(object, (const char *)name, i, NULL); } else if (G_TYPE_FLOAT == spec->value_type) { gdouble d; errno = 0; d = g_ascii_strtod((gchar *)value, NULL); if (errno) { log4g_log_error(Q_("%s: not a float"), value); goto exit; } g_object_set(object, (const gchar *)name, (gfloat)d, NULL); } else if (G_TYPE_DOUBLE == spec->value_type) { gdouble d; errno = 0; d = g_ascii_strtod((gchar *)value, NULL); if (errno) { log4g_log_error(Q_("%s: not a double"), value); goto exit; } g_object_set(object, (const gchar *)name, d, NULL); } else if (G_TYPE_OBJECT == spec->value_type) { struct Private *priv = GET_PRIVATE(base); GObject *o = g_hash_table_lookup(priv->objects, (const gchar *)value); if (!o) { log4g_log_error(Q_("%s: undefined object"), value); goto exit; } g_object_set(object, (const gchar *)name, o, NULL); } else { log4g_log_warn(Q_("%s: property cannot be set via DOM " "configuration"), name); goto exit; } exit: if (spec) { g_param_spec_unref(spec); } if (name) { xmlFree(name); } if (value) { xmlFree(value); } }