Settings

Description The GSettings class provides a convenient API for storing and retrieving application settings. Reads and writes can be considered to be non-blocking. Reading settings with GSettings is typically extremely fast: on approximately the same order of magnitude (but slower than) a GHashTable lookup. Writing settings is also extremely fast in terms of time to return to your application, but can be extremely expensive for other threads and other processes. Many settings backends (including dconf) have lazy initialisation which means in the common case of the user using their computer without modifying any settings a lot of work can be avoided. For dconf, the D-Bus service doesn't even need to be started in this case. For this reason, you should only ever modify GSettings keys in response to explicit user action. Particular care should be paid to ensure that modifications are not made during startup -- for example, when settings the initial value of preferences widgets. The built-in g_settings_bind() functionality is careful not to write settings in response to notify signals as a result of modifications that it makes to widgets. When creating a GSettings instance, you have to specify a schema that describes the keys in your settings and their types and default values, as well as some other information. Normally, a schema has as fixed path that determines where the settings are stored in the conceptual global tree of settings. However, schemas can also be 'relocatable', i.e. not equipped with a fixed path. This is useful e.g. when the schema describes an 'account', and you want to be able to store a arbitrary number of accounts. Unlike other configuration systems (like GConf), GSettings does not restrict keys to basic types like strings and numbers. GSettings stores values as GVariant, and allows any GVariantType for keys. Key names are restricted to lowercase characters, numbers and '-'. Furthermore, the names must begin with a lowercase character, must not end with a '-', and must not contain consecutive dashes. Key names can be up to 32 characters long. Similar to GConf, the default values in GSettings schemas can be localized, but the localized values are stored in gettext catalogs and looked up with the domain that is specified in the gettext-domain attribute of the <schemalist> or <schema> elements and the category that is specified in the l10n attribute of the <key> element. GSettings uses schemas in a compact binary form that is created by the glib-compile-schemas utility. The input is a schema description in an XML format that can be described by the following DTD: glib-compile-schemas expects schema files to have the extension .gschema.xml At runtime, schemas are identified by their id (as specified in the id attribute of the <schema> element). The convention for schema ids is to use a dotted name, similar in style to a D-Bus bus name, e.g. "org.gnome.SessionManager". In particular, if the settings are for a specific service that owns a D-Bus bus name, the D-Bus bus name and schema id should match. For schemas which deal with settings not associated with one named application, the id should not use StudlyCaps, e.g. "org.gnome.font-rendering". In addition to GVariant types, keys can have types that have enumerated types. These can be described by a <choice>, <enum> or <flags> element, see Example 12, “Ranges, choices and enumerated types”. The underlying type of such a key is string, but you can use g_settings_get_enum(), g_settings_set_enum(), g_settings_get_flags(), g_settings_set_flags() access the numeric values corresponding to the string value of enum and flags keys. Vendor overrides Default values are defined in the schemas that get installed by an application. Sometimes, it is necessary for a vendor or distributor to adjust these defaults. Since patching the XML source for the schema is inconvenient and error-prone, glib-compile-schemas reads so-called 'vendor override' files. These are keyfiles in the same directory as the XML schema sources which can override default values. The schema id serves as the group name in the key file, and the values are expected in serialized GVariant form, as in the following example: glib-compile-schemas expects schema files to have the extension .gschema.override Binding A very convenient feature of GSettings lets you bind GObject properties directly to settings, using g_settings_bind(). Once a GObject property has been bound to a setting, changes on either side are automatically propagated to the other side. GSettings handles details like mapping between GObject and GVariant types, and preventing infinite cycles. This makes it very easy to hook up a preferences dialog to the underlying settings. To make this even more convenient, GSettings looks for a boolean property with the name "sensitivity" and automatically binds it to the writability of the bound setting. If this 'magic' gets in the way, it can be suppressed with the G_SETTINGS_BIND_NO_SENSITIVITY flag.

class Settings : ObjectG {}

Constructors

this
this(GSettings* gSettings)

Sets our main struct and passes it to the parent class

this
this(string schema)

Creates a new GSettings object with a given schema. Signals on the newly created GSettings object will be dispatched via the thread-default GMainContext in effect at the time of the call to g_settings_new(). The new GSettings will hold a reference on the context. See g_main_context_push_thread_default(). Since 2.26

this
this(string schema, string path)

Creates a new GSettings object with a given schema and path. You only need to do this if you want to directly create a settings object with a schema that doesn't have a specified path of its own. That's quite rare. It is a programmer error to call this function for a schema that has an explicitly specified path. Since 2.26

this
this(string schema, SettingsBackend backend)

Creates a new GSettings object with a given schema and backend. Creating settings objects with an different backend allows accessing settings from a database other than the usual one. For example, it may make sense to pass a backend corresponding to the "defaults" settings database on the system to get a settings object that modifies the system default settings instead of the settings for this user. Since 2.26

this
this(string schema, SettingsBackend backend, string path)

Creates a new GSettings object with a given schema, backend and path. This is a mix of g_settings_new_with_backend() and g_settings_new_with_path(). Since 2.26

Members

Functions

addOnChange
void addOnChange(bool delegate(void*, gint, Settings) dlg, ConnectFlags connectFlags)

The "change-event" signal is emitted once per change event that affects this settings object. You should connect to this signal only if you are interested in viewing groups of changes before they are split out into multiple emissions of the "changed" signal. For most use cases it is more appropriate to use the "changed" signal. In the event that the change event applies to one or more specified keys, keys will be an array of GQuark of length n_keys. In the event that the change event applies to the GSettings object as a whole (ie: potentially every key has been changed) then keys will be NULL and n_keys will be 0. The default handler for this signal invokes the "changed" signal for each affected key. If any other connected handler returns TRUE then this default functionality will be supressed. TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further.

addOnChanged
void addOnChanged(void delegate(string, Settings) dlg, ConnectFlags connectFlags)

The "changed" signal is emitted when a key has potentially changed. You should call one of the g_settings_get() calls to check the new value. This signal supports detailed connections. You can connect to the detailed signal "changed::x" in order to only receive callbacks when key "x" changes.

addOnWritableChange
void addOnWritableChange(bool delegate(guint, Settings) dlg, ConnectFlags connectFlags)

The "writable-change-event" signal is emitted once per writability change event that affects this settings object. You should connect to this signal if you are interested in viewing groups of changes before they are split out into multiple emissions of the "writable-changed" signal. For most use cases it is more appropriate to use the "writable-changed" signal. In the event that the writability change applies only to a single key, key will be set to the GQuark for that key. In the event that the writability change affects the entire settings object, key will be 0. The default handler for this signal invokes the "writable-changed" and "changed" signals for each affected key. This is done because changes in writability might also imply changes in value (if for example, a new mandatory setting is introduced). If any other connected handler returns TRUE then this default functionality will be supressed. TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further.

addOnWritableChanged
void addOnWritableChanged(void delegate(string, Settings) dlg, ConnectFlags connectFlags)

The "writable-changed" signal is emitted when the writability of a key has potentially changed. You should call g_settings_is_writable() in order to determine the new status. This signal supports detailed connections. You can connect to the detailed signal "writable-changed::x" in order to only receive callbacks when the writability of "x" changes.

apply
void apply()

Applies any changes that have been made to the settings. This function does nothing unless settings is in 'delay-apply' mode; see g_settings_delay(). In the normal case settings are always applied immediately.

bind
void bind(string key, void* object, string property, GSettingsBindFlags flags)

Create a binding between the key in the settings object and the property property of object. The binding uses the default GIO mapping functions to map between the settings and property values. These functions handle booleans, numeric types and string types in a straightforward way. Use g_settings_bind_with_mapping() if you need a custom mapping, or map between types that are not supported by the default mapping functions. Unless the flags include G_SETTINGS_BIND_NO_SENSITIVITY, this function also establishes a binding between the writability of key and the "sensitive" property of object (if object has a boolean property by that name). See g_settings_bind_writable() for more details about writable bindings. Note that the lifecycle of the binding is tied to the object, and that you can have only one binding per object property. If you bind the same property twice on the same object, the second binding overrides the first one. Since 2.26

bindWithMapping
void bindWithMapping(string key, void* object, string property, GSettingsBindFlags flags, GSettingsBindGetMapping getMapping, GSettingsBindSetMapping setMapping, void* userData, GDestroyNotify destroy)

Create a binding between the key in the settings object and the property property of object. The binding uses the provided mapping functions to map between settings and property values. Note that the lifecycle of the binding is tied to the object, and that you can have only one binding per object property. If you bind the same property twice on the same object, the second binding overrides the first one. Since 2.26

bindWritable
void bindWritable(string key, void* object, string property, int inverted)

Create a binding between the writability of key in the settings object and the property property of object. The property must be boolean; "sensitive" or "visible" properties of widgets are the most likely candidates. Writable bindings are always uni-directional; changes of the writability of the setting will be propagated to the object property, not the other way. When the inverted argument is TRUE, the binding inverts the value as it passes from the setting to the object, i.e. property will be set to TRUE if the key is not writable. Note that the lifecycle of the binding is tied to the object, and that you can have only one binding per object property. If you bind the same property twice on the same object, the second binding overrides the first one. Since 2.26

delay
void delay()

Changes the GSettings object into 'delay-apply' mode. In this mode, changes to settings are not immediately propagated to the backend, but kept locally until g_settings_apply() is called. Since 2.26

getBoolean
int getBoolean(string key)

Gets the value that is stored at key in settings. A convenience variant of g_settings_get() for booleans. It is a programmer error to give a key that isn't specified as having a boolean type in the schema for settings. Since 2.26

getChild
Settings getChild(string name)

Creates a 'child' settings object which has a base path of base-path/name, where base-path is the base path of settings. The schema for the child settings object must have been declared in the schema of settings using a <child> element. Since 2.26

getDouble
double getDouble(string key)

Gets the value that is stored at key in settings. A convenience variant of g_settings_get() for doubles. It is a programmer error to give a key that isn't specified as having a 'double' type in the schema for settings. Since 2.26

getEnum
int getEnum(string key)

Gets the value that is stored in settings for key and converts it to the enum value that it represents. In order to use this function the type of the value must be a string and it must be marked in the schema file as an enumerated type. It is a programmer error to give a key that isn't contained in the schema for settings or is not marked as an enumerated type. If the value stored in the configuration database is not a valid value for the enumerated type then this function will return the default value. Since 2.26

getFlags
uint getFlags(string key)

Gets the value that is stored in settings for key and converts it to the flags value that it represents. In order to use this function the type of the value must be an array of strings and it must be marked in the schema file as an flags type. It is a programmer error to give a key that isn't contained in the schema for settings or is not marked as a flags type. If the value stored in the configuration database is not a valid value for the flags type then this function will return the default value. Since 2.26

getHasUnapplied
int getHasUnapplied()

Returns whether the GSettings object has any unapplied changes. This can only be the case if it is in 'delayed-apply' mode. Since 2.26

getInt
int getInt(string key)

Gets the value that is stored at key in settings. A convenience variant of g_settings_get() for 32-bit integers. It is a programmer error to give a key that isn't specified as having a int32 type in the schema for settings. Since 2.26

getMapped
void* getMapped(string key, GSettingsGetMapping mapping, void* userData)

Gets the value that is stored at key in settings, subject to application-level validation/mapping. You should use this function when the application needs to perform some processing on the value of the key (for example, parsing). The mapping function performs that processing. If the function indicates that the processing was unsuccessful (due to a parse error, for example) then the mapping is tried again with another value. This allows a robust 'fall back to defaults' behaviour to be implemented somewhat automatically. The first value that is tried is the user's setting for the key. If the mapping function fails to map this value, other values may be tried in an unspecified order (system or site defaults, translated schema default values, untranslated schema default values, etc). If the mapping function fails for all possible values, one additional attempt is made: the mapping function is called with a NULL value. If the mapping function still indicates failure at this point then the application will be aborted. The result parameter for the mapping function is pointed to a gpointer which is initially set to NULL. The same pointer is given to each invocation of mapping. The final value of that gpointer is what is returned by this function. NULL is valid; it is returned just as any other value would be.

getRange
Variant getRange(string key)

Queries the range of a key. This function will return a GVariant that fully describes the range of values that are valid for key. The type of GVariant returned is (sv). The string describes the type of range restriction in effect. The type and meaning of the value contained in the variant depends on the string. If the string is 'type' then the variant contains an empty array. The element type of that empty array is the expected type of value and all values of that type are valid. If the string is 'enum' then the variant contains an array enumerating the possible values. Each item in the array is a possible valid value and no other values are valid. If the string is 'flags' then the variant contains an array. Each item in the array is a value that may appear zero or one times in an array to be used as the value for this key. For example, if the variant contained the array ['x', 'y'] then the valid values for the key would be [], ['x'], ['y'], ['x', 'y'] and ['y', 'x']. Finally, if the string is 'range' then the variant contains a pair of like-typed values -- the minimum and maximum permissible values for this key. This information should not be used by normal programs. It is considered to be a hint for introspection purposes. Normal programs should already know what is permitted by their own schema. The format may change in any way in the future -- but particularly, new forms may be added to the possibilities described above. It is a programmer error to give a key that isn't contained in the schema for settings. You should free the returned value with g_variant_unref() when it is no longer needed. Since 2.28

getSettingsStruct
GSettings* getSettingsStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getString
string getString(string key)

Gets the value that is stored at key in settings. A convenience variant of g_settings_get() for strings. It is a programmer error to give a key that isn't specified as having a string type in the schema for settings. Since 2.26

getStruct
void* getStruct()

the main Gtk struct as a void*

getStrv
string[] getStrv(string key)

A convenience variant of g_settings_get() for string arrays. It is a programmer error to give a key that isn't specified as having an array of strings type in the schema for settings. Since 2.26

getValue
Variant getValue(string key)

Gets the value that is stored in settings for key. It is a programmer error to give a key that isn't contained in the schema for settings. Since 2.26

isWritable
int isWritable(string name)

Finds out if a key can be written or not Since 2.26

listChildren
string[] listChildren()

Gets the list of children on settings. The list is exactly the list of strings for which it is not an error to call g_settings_get_child(). For GSettings objects that are lists, this value can change at any time and you should connect to the "children-changed" signal to watch for those changes. Note that there is a race condition here: you may request a child after listing it only for it to have been destroyed in the meantime. For this reason, g_settings_get_child() may return NULL even for a child that was listed by this function. For GSettings objects that are not lists, you should probably not be calling this function from "normal" code (since you should already know what children are in your schema). This function may still be useful there for introspection reasons, however. You should free the return value with g_strfreev() when you are done with it.

listKeys
string[] listKeys()

Introspects the list of keys on settings. You should probably not be calling this function from "normal" code (since you should already know what keys are in your schema). This function is intended for introspection reasons. You should free the return value with g_strfreev() when you are done with it.

rangeCheck
int rangeCheck(string key, Variant value)

Checks if the given value is of the correct type and within the permitted range for key. This API is not intended to be used by normal programs -- they should already know what is permitted by their own schemas. This API is meant to be used by programs such as editors or commandline tools. It is a programmer error to give a key that isn't contained in the schema for settings. Since 2.28

reset
void reset(string key)

Resets key to its default value. This call resets the key, as much as possible, to its default value. That might the value specified in the schema or the one set by the administrator.

revert
void revert()

Reverts all non-applied changes to the settings. This function does nothing unless settings is in 'delay-apply' mode; see g_settings_delay(). In the normal case settings are always applied immediately. Change notifications will be emitted for affected keys.

setBoolean
int setBoolean(string key, int value)

Sets key in settings to value. A convenience variant of g_settings_set() for booleans. It is a programmer error to give a key that isn't specified as having a boolean type in the schema for settings. Since 2.26

setDouble
int setDouble(string key, double value)

Sets key in settings to value. A convenience variant of g_settings_set() for doubles. It is a programmer error to give a key that isn't specified as having a 'double' type in the schema for settings. Since 2.26

setEnum
int setEnum(string key, int value)

Looks up the enumerated type nick for value and writes it to key, within settings. It is a programmer error to give a key that isn't contained in the schema for settings or is not marked as an enumerated type, or for value not to be a valid value for the named type. After performing the write, accessing key directly with g_settings_get_string() will return the 'nick' associated with value.

setFlags
int setFlags(string key, uint value)

Looks up the flags type nicks for the bits specified by value, puts them in an array of strings and writes the array to key, withing settings. It is a programmer error to give a key that isn't contained in the schema for settings or is not marked as a flags type, or for value to contain any bits that are not value for the named type. After performing the write, accessing key directly with g_settings_get_strv() will return an array of 'nicks'; one for each bit in value.

setInt
int setInt(string key, int value)

Sets key in settings to value. A convenience variant of g_settings_set() for 32-bit integers. It is a programmer error to give a key that isn't specified as having a int32 type in the schema for settings. Since 2.26

setString
int setString(string key, string value)

Sets key in settings to value. A convenience variant of g_settings_set() for strings. It is a programmer error to give a key that isn't specified as having a string type in the schema for settings. Since 2.26

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
setStrv
int setStrv(string key, string[] value)

Sets key in settings to value. A convenience variant of g_settings_set() for string arrays. If value is NULL, then key is set to be the empty array. It is a programmer error to give a key that isn't specified as having an array of strings type in the schema for settings. Since 2.26

setValue
int setValue(string key, Variant value)

Sets key in settings to value. It is a programmer error to give a key that isn't contained in the schema for settings or for value to have the incorrect type, per the schema. If value is floating then this function consumes the reference. Since 2.26

Static functions

callBackChange
gboolean callBackChange(GSettings* settingsStruct, void* keys, gint nKeys, Settings _settings)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackChanged
void callBackChanged(GSettings* settingsStruct, gchar* key, Settings _settings)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackWritableChange
gboolean callBackWritableChange(GSettings* settingsStruct, guint key, Settings _settings)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackWritableChanged
void callBackWritableChanged(GSettings* settingsStruct, gchar* key, Settings _settings)
Undocumented in source. Be warned that the author may not have intended to support it.
listRelocatableSchemas
string[] listRelocatableSchemas()

Gets a list of the relocatable GSettings schemas installed on the system. These are schemas that do not provide their own path. It is usual to instantiate these schemas directly, but if you want to you can use g_settings_new_with_path() to specify the path. The output of this function, tTaken together with the output of g_settings_list_schemas() represents the complete list of all installed schemas. Since 2.28

listSchemas
string[] listSchemas()

Gets a list of the GSettings schemas installed on the system. The returned list is exactly the list of schemas for which you may call g_settings_new() without adverse effects. This function does not list the schemas that do not provide their own paths (ie: schemas for which you must use g_settings_new_with_path()). See g_settings_list_relocatable_schemas() for that. Since 2.26

sync
void sync()

Ensures that all pending operations for the given are complete for the default backend. Writes made to a GSettings are handled asynchronously. For this reason, it is very unlikely that the changes have it to disk by the time g_settings_set() returns. This call will block until all of the writes have made it to the backend. Since the mainloop is not running, no change notifications will be dispatched during this call (but some may be queued by the time the call is done).

unbind
void unbind(void* object, string property)

Removes an existing binding for property on object. Note that bindings are automatically removed when the object is finalized, so it is rarely necessary to call this function. Since 2.26

Variables

connectedSignals
int[string] connectedSignals;
gSettings
GSettings* gSettings;

the main Gtk struct

onChangeListeners
bool delegate(void*, gint, Settings)[] onChangeListeners;
Undocumented in source.
onChangedListeners
void delegate(string, Settings)[] onChangedListeners;
Undocumented in source.
onWritableChangeListeners
bool delegate(guint, Settings)[] onWritableChangeListeners;
Undocumented in source.
onWritableChangedListeners
void delegate(string, Settings)[] onWritableChangedListeners;
Undocumented in source.

Inherited Members

From ObjectG

gObject
GObject* gObject;

the main Gtk struct

getObjectGStruct
GObject* getObjectGStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

isGcRoot
bool isGcRoot;
Undocumented in source.
destroyNotify
void destroyNotify(ObjectG obj)
Undocumented in source. Be warned that the author may not have intended to support it.
toggleNotify
void toggleNotify(ObjectG obj, GObject* object, int isLastRef)
Undocumented in source. Be warned that the author may not have intended to support it.
~this
~this()
Undocumented in source.
getDObject
RT getDObject(U obj)

Gets a D Object from the objects table of associations.

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
setProperty
void setProperty(string propertyName, int value)
setProperty
void setProperty(string propertyName, string value)
setProperty
void setProperty(string propertyName, long value)
setProperty
void setProperty(string propertyName, ulong value)
unref
void unref()
Undocumented in source. Be warned that the author may not have intended to support it.
doref
ObjectG doref()
Undocumented in source. Be warned that the author may not have intended to support it.
connectedSignals
int[string] connectedSignals;
onNotifyListeners
void delegate(ParamSpec, ObjectG)[] onNotifyListeners;
Undocumented in source.
addOnNotify
void addOnNotify(void delegate(ParamSpec, ObjectG) dlg, ConnectFlags connectFlags)

The notify signal is emitted on an object when one of its properties has been changed. Note that getting this signal doesn't guarantee that the value of the property has actually changed, it may also be emitted when the setter for the property is called to reinstate the previous value. This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the It is important to note that you must use canonical parameter names as detail strings for the notify signal. See Also GParamSpecObject, g_param_spec_object()

callBackNotify
void callBackNotify(GObject* gobjectStruct, GParamSpec* pspec, ObjectG _objectG)
Undocumented in source. Be warned that the author may not have intended to support it.
classInstallProperty
void classInstallProperty(GObjectClass* oclass, uint propertyId, ParamSpec pspec)

Installs a new property. This is usually done in the class initializer. Note that it is possible to redefine a property in a derived class, by installing a property with the same name. This can be useful at times, e.g. to change the range of allowed values or the default value.

classInstallProperties
void classInstallProperties(GObjectClass* oclass, ParamSpec[] pspecs)

Installs new properties from an array of GParamSpecs. This is usually done in the class initializer. The property id of each property is the index of each GParamSpec in the pspecs array. The property id of 0 is treated specially by GObject and it should not be used to store a GParamSpec. This function should be used if you plan to use a static array of GParamSpecs and g_object_notify_by_pspec(). For instance, this Since 2.26

classFindProperty
ParamSpec classFindProperty(GObjectClass* oclass, string propertyName)

Looks up the GParamSpec for a property of a class.

classListProperties
ParamSpec[] classListProperties(GObjectClass* oclass)

Get an array of GParamSpec* for all properties of a class.

classOverrideProperty
void classOverrideProperty(GObjectClass* oclass, uint propertyId, string name)

Registers property_id as referring to a property with the name name in a parent class or in an interface implemented by oclass. This allows this class to override a property implementation in a parent class or to provide the implementation of a property from an interface. Note Internally, overriding is implemented by creating a property of type GParamSpecOverride; generally operations that query the properties of the object class, such as g_object_class_find_property() or g_object_class_list_properties() will return the overridden property. However, in one case, the construct_properties argument of the constructor virtual function, the GParamSpecOverride is passed instead, so that the param_id field of the GParamSpec will be correct. For virtually all uses, this makes no difference. If you need to get the overridden property, you can call g_param_spec_get_redirect_target(). Since 2.4

interfaceInstallProperty
void interfaceInstallProperty(void* iface, ParamSpec pspec)

Add a property to an interface; this is only useful for interfaces that are added to GObject-derived types. Adding a property to an interface forces all objects classes with that interface to have a compatible property. The compatible property could be a newly created GParamSpec, but normally g_object_class_override_property() will be used so that the object class only needs to provide an implementation and inherits the property description, default value, bounds, and so forth from the interface property. This function is meant to be called from the interface's default vtable initialization function (the class_init member of GTypeInfo.) It must not be called after after class_init has been called for any object types implementing this interface. Since 2.4

interfaceFindProperty
ParamSpec interfaceFindProperty(void* iface, string propertyName)

Find the GParamSpec with the given name for an interface. Generally, the interface vtable passed in as g_iface will be the default vtable from g_type_default_interface_ref(), or, if you know the interface has already been loaded, g_type_default_interface_peek(). Since 2.4

interfaceListProperties
ParamSpec[] interfaceListProperties(void* iface)

Lists the properties of an interface.Generally, the interface vtable passed in as g_iface will be the default vtable from g_type_default_interface_ref(), or, if you know the interface has already been loaded, g_type_default_interface_peek(). Since 2.4

doref
void* doref(void* object)

Increases the reference count of object.

unref
void unref(void* object)

Decreases the reference count of object. When its reference count drops to 0, the object is finalized (i.e. its memory is freed).

refSink
void* refSink(void* object)

Increase the reference count of object, and possibly remove the floating reference, if object has a floating reference. In other words, if the object is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference by clearing the floating flag while leaving the reference count unchanged. If the object is not floating, then this call adds a new normal reference increasing the reference count by one. Since 2.10

clearObject
void clearObject(ObjectG objectPtr)

Clears a reference to a GObject. object_ptr must not be NULL. If the reference is NULL then this function does nothing. Otherwise, the reference count of the object is decreased and the pointer is set to NULL. This function is threadsafe and modifies the pointer atomically, using memory barriers where needed. A macro is also included that allows this function to be used without pointer casts. Since 2.28

isFloating
int isFloating(void* object)

Checks whether object has a floating reference. Since 2.10

forceFloating
void forceFloating()

This function is intended for GObject implementations to re-enforce a floating object reference. Doing this is seldomly required: all GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling g_object_ref_sink(). Since 2.10

weakRef
void weakRef(GWeakNotify notify, void* data)

Adds a weak reference callback to an object. Weak references are used for notification when an object is finalized. They are called "weak references" because they allow you to safely hold a pointer to an object without calling g_object_ref() (g_object_ref() adds a strong reference, that is, forces the object to stay alive).

weakUnref
void weakUnref(GWeakNotify notify, void* data)

Removes a weak reference callback to an object.

addWeakPointer
void addWeakPointer(void** weakPointerLocation)

Adds a weak reference from weak_pointer to object to indicate that the pointer located at weak_pointer_location is only valid during the lifetime of object. When the object is finalized, weak_pointer will be set to NULL.

removeWeakPointer
void removeWeakPointer(void** weakPointerLocation)

Removes a weak reference from object that was previously added using g_object_add_weak_pointer(). The weak_pointer_location has to match the one used with g_object_add_weak_pointer().

addToggleRef
void addToggleRef(GToggleNotify notify, void* data)

Increases the reference count of the object by one and sets a callback to be called when all other references to the object are dropped, or when this is already the last reference to the object and another reference is established. This functionality is intended for binding object to a proxy object managed by another memory manager. This is done with two paired references: the strong reference added by g_object_add_toggle_ref() and a reverse reference to the proxy object which is either a strong reference or weak reference. The setup is that when there are no other references to object, only a weak reference is held in the reverse direction from object to the proxy object, but when there are other references held to object, a strong reference is held. The notify callback is called when the reference from object to the proxy object should be toggled from strong to weak (is_last_ref true) or weak to strong (is_last_ref false). Since a (normal) reference must be held to the object before calling g_object_toggle_ref(), the initial state of the reverse link is always strong. Multiple toggle references may be added to the same gobject, however if there are multiple toggle references to an object, none of them will ever be notified until all but one are removed. For this reason, you should only ever use a toggle reference if there is important state in the proxy object. Since 2.8

removeToggleRef
void removeToggleRef(GToggleNotify notify, void* data)

Removes a reference added with g_object_add_toggle_ref(). The reference count of the object is decreased by one. Since 2.8

notify
void notify(string propertyName)

Emits a "notify" signal for the property property_name on object. When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.

notifyByPspec
void notifyByPspec(ParamSpec pspec)

Emits a "notify" signal for the property specified by pspec on object. This function omits the property name lookup, hence it is faster than g_object_notify(). One way to avoid using g_object_notify() from within the class that registered the properties, and using g_object_notify_by_pspec() instead, is to store the GParamSpec used with Since 2.26

freezeNotify
void freezeNotify()

Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. This is necessary for accessors that modify multiple properties to prevent premature notification while the object is still being modified.

thawNotify
void thawNotify()

Reverts the effect of a previous call to g_object_freeze_notify(). The freeze count is decreased on object and when it reaches zero, all queued "notify" signals are emitted. It is an error to call this function when the freeze count is zero.

getData
void* getData(string key)

Gets a named field from the objects table of associations (see g_object_set_data()).

setData
void setData(string key, void* data)

Each object carries around a table of associations from strings to pointers. This function lets you set an association. If the object already had an association with that name, the old association will be destroyed.

setDataFull
void setDataFull(string key, void* data, GDestroyNotify destroy)

Like g_object_set_data() except it adds notification for when the association is destroyed, either by setting it to a different value or when the object is destroyed. Note that the destroy callback is not called if data is NULL.

stealData
void* stealData(string key)

Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

getQdata
void* getQdata(GQuark quark)

This function gets back user data pointers stored via g_object_set_qdata().

setQdata
void setQdata(GQuark quark, void* data)

This sets an opaque, named pointer on an object. The name is specified through a GQuark (retrived e.g. via g_quark_from_static_string()), and the pointer can be gotten back from the object with g_object_get_qdata() until the object is finalized. Setting a previously set user data pointer, overrides (frees) the old pointer set, using NULL as pointer essentially removes the data stored.

setQdataFull
void setQdataFull(GQuark quark, void* data, GDestroyNotify destroy)

This function works like g_object_set_qdata(), but in addition, a void (*destroy) (gpointer) function may be specified which is called with data as argument when the object is finalized, or the data is being overwritten by a call to g_object_set_qdata() with the same quark.

stealQdata
void* stealQdata(GQuark quark)

This function gets back user data pointers stored via g_object_set_qdata() and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update

setProperty
void setProperty(string propertyName, Value value)

Sets a property on an object.

getProperty
void getProperty(string propertyName, Value value)

Gets a property of an object. value must have been initialized to the expected type of the property (or a type to which the expected type can be transformed) using g_value_init(). In general, a copy is made of the property contents and the caller is responsible for freeing the memory by calling g_value_unset(). Note that g_object_get_property() is really intended for language bindings, g_object_get() is much more convenient for C programming.

setValist
void setValist(string firstPropertyName, void* varArgs)

Sets properties on an object.

getValist
void getValist(string firstPropertyName, void* varArgs)

Gets properties of an object. In general, a copy is made of the property contents and the caller is responsible for freeing the memory in the appropriate manner for the type, for instance by calling g_free() or g_object_unref(). See g_object_get().

watchClosure
void watchClosure(Closure closure)

This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling g_closure_invalidate() on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, g_object_ref() and g_object_unref() are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

runDispose
void runDispose()

Releases all references to other objects. This can be used to break reference cycles. This functions should only be called from object system implementations.

Meta