SettingsSchemaSource

The GSettingsSchemaSource and GSettingsSchema APIs provide a mechanism for advanced control over the loading of schemas and a mechanism for introspecting their content.

Plugin loading systems that wish to provide plugins a way to access settings face the problem of how to make the schemas for these settings visible to GSettings. Typically, a plugin will want to ship the schema along with itself and it won't be installed into the standard system directories for schemas.

GSettingsSchemaSource provides a mechanism for dealing with this by allowing the creation of a new 'schema source' from which schemas can be acquired. This schema source can then become part of the metadata associated with the plugin and queried whenever the plugin requires access to some settings.

Consider the following example:

The code above shows how hooks should be added to the code that initialises (or enables) the plugin to create the schema source and how an API can be added to the plugin system to provide a convenient way for the plugin to access its settings, using the schemas that it ships.

From the standpoint of the plugin, it would need to ensure that it ships a gschemas.compiled file as part of itself, and then simply do the following:

It's also possible that the plugin system expects the schema source files (ie: .gschema.xml files) instead of a gschemas.compiled file. In that case, the plugin loading system must compile the schemas for itself before attempting to create the settings source.

Constructors

this
this(GSettingsSchemaSource* gSettingsSchemaSource)

Sets our main struct and passes it to the parent class

this
this(string directory, SettingsSchemaSource parent, int trusted)

Attempts to create a new schema source corresponding to the contents of the given directory. This function is not required for normal uses of GSettings but it may be useful to authors of plugin management systems. The directory should contain a file called gschemas.compiled as produced by glib-compile-schemas. If trusted is TRUE then gschemas.compiled is trusted not to be corrupted. This assumption has a performance advantage, but can result in crashes or inconsistent behaviour in the case of a corrupted file. Generally, you should set trusted to TRUE for files installed by the system and to FALSE for files in the home directory. If parent is non-NULL then there are two effects. First, if g_settings_schema_source_lookup() is called with the recursive flag set to TRUE and the schema can not be found in the source, the lookup will recurse to the parent. Second, any references to other schemas specified within this source (ie: child or extends) references may be resolved from the parent. For this second reason, except in very unusual situations, the parent should probably be given as the default schema source, as returned by g_settings_schema_source_get_default(). Since 2.32

Destructor

~this
~this()
Undocumented in source.

Members

Functions

doref
SettingsSchemaSource doref()

Increase the reference count of source, returning a new reference. Since 2.32

getSettingsSchemaSourceStruct
GSettingsSchemaSource* getSettingsSchemaSourceStruct()
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*

lookup
SettingsSchema lookup(string schemaId, int recursive)

Looks up a schema with the identifier schema_id in source. This function is not required for normal uses of GSettings but it may be useful to authors of plugin management systems or to those who want to introspect the content of schemas. If the schema isn't found directly in source and recursive is TRUE then the parent sources will also be checked. If the schema isn't found, NULL is returned. Since 2.32

unref
void unref()

Decrease the reference count of source, possibly freeing it. Since 2.32

Static functions

getDefault
SettingsSchemaSource getDefault()

Gets the default system schema source. This function is not required for normal uses of GSettings but it may be useful to authors of plugin management systems or to those who want to introspect the content of schemas. If no schemas are installed, NULL will be returned. The returned source may actually consist of multiple schema sources from different directories, depending on which directories were given in XDG_DATA_DIRS and GSETTINGS_SCHEMA_DIR. For this reason, all lookups performed against the default source should probably be done recursively. Since 2.32

Variables

gSettingsSchemaSource
GSettingsSchemaSource* gSettingsSchemaSource;

the main Gtk struct

Meta