Package ch.bailu.gtk.gio
Class SettingsSchema
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.gio.SettingsSchema
- All Implemented Interfaces:
PointerInterface
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.
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:
<!-- language="C" --> typedef struct { ... GSettingsSchemaSource *schema_source; ... } Plugin; Plugin * initialise_plugin (const gchar *dir) { Plugin *plugin; ... plugin->schema_source = g_settings_schema_source_new_from_directory (dir, g_settings_schema_source_get_default (), FALSE, NULL); ... return plugin; } ... GSettings * plugin_get_settings (Plugin *plugin, const gchar *schema_id) { GSettingsSchema *schema; if (schema_id == NULL) schema_id = plugin->identifier; schema = g_settings_schema_source_lookup (plugin->schema_source, schema_id, FALSE); if (schema == NULL) { ... disable the plugin or abort, etc ... } return g_settings_new_full (schema, NULL, NULL); }
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:
<!-- language="C" --> { GSettings *settings; gint some_value; settings = plugin_get_settings (self, NULL); some_value = g_settings_get_int (settings, "some-value"); ... }
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.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClassHandler
getId()
Get the ID of @schema.static int
Gets the key named @name from @schema.Gets the key named @name from @schema.static long
static TypeSystem.TypeSize
getPath()
Gets the path associated with @schema, or %NULL.static long
static TypeSystem.TypeSize
boolean
Checks if @schema has a key named @name.boolean
Checks if @schema has a key named @name.ref()
Increase the reference count of @schema, returning a new reference.void
unref()
Decrease the reference count of @schema, possibly freeing it.Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
SettingsSchema
-
-
Method Details
-
getClassHandler
-
getId
Get the ID of @schema.- Returns:
- the ID
-
getKey
Gets the key named @name from @schema.
It is a programmer error to request a key that does not exist. See
g_settings_schema_list_keys().- Parameters:
name
- the name of a key- Returns:
- the #GSettingsSchemaKey for @name
-
getKey
Gets the key named @name from @schema.
It is a programmer error to request a key that does not exist. See
g_settings_schema_list_keys().- Parameters:
name
- the name of a key- Returns:
- the #GSettingsSchemaKey for @name
-
getPath
Gets the path associated with @schema, or %NULL.
Schemas may be single-instance or relocatable. Single-instance
schemas correspond to exactly one set of keys in the backend
database: those located at the path returned by this function.
Relocatable schemas can be referenced by other schemas and can
therefore describe multiple sets of keys at different locations. For
relocatable schemas, this function will return %NULL.- Returns:
- the path of the schema, or %NULL
-
hasKey
Checks if @schema has a key named @name.- Parameters:
name
- the name of a key- Returns:
- %TRUE if such a key exists
-
hasKey
Checks if @schema has a key named @name.- Parameters:
name
- the name of a key- Returns:
- %TRUE if such a key exists
-
ref
Increase the reference count of @schema, returning a new reference.- Returns:
- a new reference to @schema
-
unref
public void unref()Decrease the reference count of @schema, possibly freeing it. -
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-