Sets our main struct and passes it to the parent class
Creates a new GSettings object with the schema specified by schema_id. 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
Creates a new GSettings object with the relocatable schema specified by schema_id and a given 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
Creates a new GSettings object with the schema specified by schema_id and a given GSettingsBackend. Creating a GSettings object with a 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
Creates a new GSettings object with the schema specified by schema_id and a given GSettingsBackend and path. This is a mix of g_settings_new_with_backend() and g_settings_new_with_path(). Since 2.26
Creates a new GSettings object with a given schema, backend and path. It should be extremely rare that you ever want to use this function. It is made available for advanced use-cases (such as plugin systems that want to provide access to schemas loaded from custom locations, etc). At the most basic level, a GSettings object is a pure composition of 4 things: a GSettingsSchema, a GSettingsBackend, a path within that backend, and a GMainContext to which signals are dispatched. This constructor therefore gives you full control over constructing GSettings instances. The first 4 parameters are given directly as schema, backend and path, and the main context is taken from the thread-default (as per g_settings_new()). If backend is NULL then the default backend is used. If path is NULL then the path from the schema is used. It is an error f path is NULL and the schema has no path of its own or if path is non-NULL and not equal to the path that the schema does have. Since 2.32
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 suppressed. TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further.
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.
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 suppressed. TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further.
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.
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.
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
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
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
Creates a GAction corresponding to a given GSettings key. The action has the same name as the key. The value of the key becomes the state of the action and the action is enabled when the key is writable. Changing the state of the action results in the key being written to. Changes to the value or writability of the key cause appropriate change notifications to be emitted for the action. For boolean-valued keys, action activations take no parameter and result in the toggling of the value. For all other types, activations take the new value for the key (which must have the correct type). Since 2.32
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
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
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
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
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
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
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
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
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.
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
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
the main Gtk struct as a void*
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
Gets the value that is stored at key in settings. A convenience variant of g_settings_get() for 32-bit unsigned integers. It is a programmer error to give a key that isn't specified as having a uint32 type in the schema for settings. Since 2.30
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
Finds out if a key can be written or not Since 2.26
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.
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.
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
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.
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.
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
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
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.
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, 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 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.
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
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
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
Sets key in settings to value. A convenience variant of g_settings_set() for 32-bit unsigned integers. It is a programmer error to give a key that isn't specified as having a uint32 type in the schema for settings. Since 2.30
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
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, taken together with the output of g_settings_list_schemas() represents the complete list of all installed schemas. Since 2.28
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
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).
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
the main Gtk struct
the main Gtk struct
the main Gtk struct as a void*
Gets a D Object from the objects table of associations.
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.
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.
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
Looks up the GParamSpec for a property of a class.
Get an array of GParamSpec* for all properties of a class.
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
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
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
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
Increases the reference count of object.
Decreases the reference count of object. When its reference count drops to 0, the object is finalized (i.e. its memory is freed).
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
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
Checks whether object has a floating reference. Since 2.10
This function is intended for GObject implementations to re-enforce a floating object reference. Doing this is seldom 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
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). Note that the weak references created by this method are not thread-safe: they cannot safely be used in one thread if the object's last g_object_unref() might happen in another thread. Use GWeakRef if thread-safety is required.
Removes a weak reference callback to an object.
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. Note that as with g_object_weak_ref(), the weak references created by this method are not thread-safe: they cannot safely be used in one thread if the object's last g_object_unref() might happen in another thread. Use GWeakRef if thread-safety is required.
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().
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_add_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
Removes a reference added with g_object_add_toggle_ref(). The reference count of the object is decreased by one. Since 2.8
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.
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
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. Duplicate notifications are squashed so that at most one "notify" signal is emitted for each property modified while the object is frozen. This is necessary for accessors that modify multiple properties to prevent premature notification while the object is still being modified.
Reverts the effect of a previous call to g_object_freeze_notify(). The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted. Duplicate notifications for each property are squashed so that at most one "notify" signal is emitted for each property. It is an error to call this function when the freeze count is zero.
Gets a named field from the objects table of associations (see g_object_set_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.
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.
Remove a specified datum from the object's data associations, without invoking the association's destroy handler.
This is a variant of g_object_get_data() which returns a 'duplicate' of the value. dup_func defines the meaning of 'duplicate' in this context, it could e.g. take a reference on a ref-counted object. If the key is not set on the object then dup_func will be called with a NULL argument. Note that dup_func is called while user data of object is locked. This function can be useful to avoid races when multiple threads are using object data on the same key on the same object. Since 2.34
Compares the user data for the key key on object with oldval, and if they are the same, replaces oldval with newval. This is like a typical atomic compare-and-exchange operation, for user data on an object. If the previous value was replaced then ownership of the old value (oldval) is passed to the caller, including the registered destroy notify for it (passed out in old_destroy). Its up to the caller to free this as he wishes, which may or may not include using old_destroy as sometimes replacement should not destroy the object in the normal way. Return: TRUE if the existing value for key was replaced by newval, FALSE otherwise. Since 2.34
This function gets back user data pointers stored via g_object_set_qdata().
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.
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.
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
This is a variant of g_object_get_qdata() which returns a 'duplicate' of the value. dup_func defines the meaning of 'duplicate' in this context, it could e.g. take a reference on a ref-counted object. If the quark is not set on the object then dup_func will be called with a NULL argument. Note that dup_func is called while user data of object is locked. This function can be useful to avoid races when multiple threads are using object data on the same key on the same object. Since 2.34
Compares the user data for the key quark on object with oldval, and if they are the same, replaces oldval with newval. This is like a typical atomic compare-and-exchange operation, for user data on an object. If the previous value was replaced then ownership of the old value (oldval) is passed to the caller, including the registered destroy notify for it (passed out in old_destroy). Its up to the caller to free this as he wishes, which may or may not include using old_destroy as sometimes replacement should not destroy the object in the normal way. Return: TRUE if the existing value for quark was replaced by newval, FALSE otherwise. Since 2.34
Sets a property on an object.
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.
Sets properties on an object.
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().
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.
Releases all references to other objects. This can be used to break reference cycles. This functions should only be called from object system implementations.
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 setting 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.
Paths must start with and end with a forward slash character ('/') and must not contain two sequential slash characters. Paths should be chosen based on a domain name associated with the program or library to which the settings belong. Examples of paths are "/org/gtk/settings/file-chooser/" and "/ca/desrt/dconf-editor/". Paths should not start with "/apps/", "/desktop/" or "/system/" as they often did in GConf.
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.
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 16, “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.