1.70 <GSettingsBackend>

Class: <GSettingsBackend>

It derives from <GObject>.

The <GSettingsBackend> interface defines a generic interface for non-strictly-typed data that is stored in a hierarchy. To implement an alternative storage backend for <GSettings>, you need to implement the <GSettingsBackend> interface and then make it implement the extension point G_SETTINGS_BACKEND_EXTENSION_POINT_NAME.

The interface defines methods for reading and writing values, a method for determining if writing of certain values will fail (lockdown) and a change notification mechanism.

The semantics of the interface are very precisely defined and implementations must carefully adhere to the expectations of callers that are documented on each of the interface methods.

Some of the <GSettingsBackend> functions accept or return a <GTree>. These trees always have strings as keys and <GVariant> as values.

The <GSettingsBackend> API is exported to allow third-party implementations, but does not carry the same stability guarantees as the public GIO API. For this reason, you have to define the C preprocessor symbol G_SETTINGS_ENABLE_BACKEND before including gio/gsettingsbackend.h.

Fields

parent-instance

Procedures

Method: settings-backend:changed self key [origin-tag]
Method: changed self key [origin-tag]

Signals that a single key has possibly changed. Backend implementations should call this if a key has possibly changed its value.

key must be a valid key (ie starting with a slash, not containing ’//’, and not ending with a slash).

The implementation must call this function during any call to g_settings_backend_write(), before the call returns (except in the case that no keys are actually changed and it cares to detect this fact). It may not rely on the existence of a mainloop for dispatching the signal later.

The implementation may call this function at any other time it likes in response to other events (such as changes occurring outside of the program). These calls may originate from a mainloop or may originate in response to any other action (including from calls to g_settings_backend_write()).

In the case that this call is in response to a call to g_settings_backend_write() then origin-tag must be set to the same value that was passed to that call.

self

Passed: a <GSettingsBackend>.

a <GSettingsBackend> implementation

key

Passed: a string.

the name of the key

origin-tag

Passed, or left out: a foreign pointer, or a bytevector, or #f.

the origin tag

Method: settings-backend:changed-tree self tree [origin-tag]
Method: changed-tree self tree [origin-tag]

This call is a convenience wrapper. It gets the list of changes from tree, computes the longest common prefix and calls settings-backend:changed.

self

Passed: a <GSettingsBackend>.

a <GSettingsBackend> implementation

tree

Passed: a <GTree>.

a <GTree> containing the changes

origin-tag

Passed, or left out: a foreign pointer, or a bytevector, or #f.

the origin tag

Procedure: settings-backend:flatten-tree tree ⇒ path keys values

Calculate the longest common prefix of all keys in a tree and write out an array of the key names relative to that prefix and, optionally, the value to store at each of those keys.

You must free the value returned in path, keys and values using byte-array:free. You should not attempt to free or unref the contents of keys or values.

tree

Passed: a <GTree>.

a <GTree> containing the changes

path

Returned: a string.

the location to save the path

keys

Returned: a vector, each a string.

the location to save the relative keys

values

Returned: a vector, each a <GVariant>.

the location to save the values, or #f

Procedure: settings-backend:get-default ⇒ %return

Returns the default <GSettingsBackend>. It is possible to override the default by setting the GSETTINGS_BACKEND environment variable to the name of a settings backend.

The user gets a reference to the backend.

%return

Returned: a <GSettingsBackend>.

the default <GSettingsBackend>, which will be a dummy (memory) settings backend if no other settings backend is available.

Method: settings-backend:keys-changed self path items [origin-tag]
Method: keys-changed self path items [origin-tag]

Signals that a list of keys have possibly changed. Backend implementations should call this if keys have possibly changed their values.

path must be a valid path (ie starting and ending with a slash and not containing ’//’). Each string in items must form a valid key name when path is prefixed to it (ie: each item must not start or end with ’/’ and must not contain ’//’).

The meaning of this signal is that any of the key names resulting from the concatenation of path with each item in items may have changed.

The same rules for when notifications must occur apply as per settings-backend:changed. These two calls can be used interchangeably if exactly one item has changed (although in that case settings-backend:changed is definitely preferred).

For efficiency reasons, the implementation should strive for path to be as long as possible (ie: the longest common prefix of all of the keys that were changed) but this is not strictly required.

self

Passed: a <GSettingsBackend>.

a <GSettingsBackend> implementation

path

Passed: a string.

the path containing the changes

items

Passed: a list or vector, each a string.

the #f-terminated list of changed keys

origin-tag

Passed, or left out: a foreign pointer, or a bytevector, or #f.

the origin tag

Method: settings-backend:path-changed self path [origin-tag]
Method: path-changed self path [origin-tag]

Signals that all keys below a given path may have possibly changed. Backend implementations should call this if an entire path of keys have possibly changed their values.

path must be a valid path (ie starting and ending with a slash and not containing ’//’).

The meaning of this signal is that any of the key which has a name starting with path may have changed.

The same rules for when notifications must occur apply as per settings-backend:changed. This call might be an appropriate reasponse to a ’reset’ call but implementations are also free to explicitly list the keys that were affected by that call if they can easily do so.

For efficiency reasons, the implementation should strive for path to be as long as possible (ie: the longest common prefix of all of the keys that were changed) but this is not strictly required. As an example, if this function is called with the path of "/" then every single key in the application will be notified of a possible change.

self

Passed: a <GSettingsBackend>.

a <GSettingsBackend> implementation

path

Passed: a string.

the path containing the changes

origin-tag

Passed, or left out: a foreign pointer, or a bytevector, or #f.

the origin tag

Method: settings-backend:path-writable-changed self path
Method: path-writable-changed self path

Signals that the writability of all keys below a given path may have changed.

Since GSettings performs no locking operations for itself, this call will always be made in response to external events.

self

Passed: a <GSettingsBackend>.

a <GSettingsBackend> implementation

path

Passed: a string.

the name of the path

Method: settings-backend:writable-changed self key
Method: writable-changed self key

Signals that the writability of a single key has possibly changed.

Since GSettings performs no locking operations for itself, this call will always be made in response to external events.

self

Passed: a <GSettingsBackend>.

a <GSettingsBackend> implementation

key

Passed: a string.

the name of the key

Virtual methods

Virtual method: settings-backend:do-get-writable implementor self key ⇒ %return

virtual method to get if a key is writable

To override it in a new class, give register-type #:vfuncs `((get-writable . ,procedure)). The procedure is called as (procedure self key) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GSettingsBackend>, or a class that derives from it, or its GType number.

self

Passed: a <GSettingsBackend>.

key

Passed: a string.

%return

Returned: a boolean.

Virtual method: settings-backend:do-read implementor self key expected-type default-value ⇒ %return

virtual method to read a key’s value

To override it in a new class, give register-type #:vfuncs `((read . ,procedure)). The procedure is called as (procedure self key expected-type default-value) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GSettingsBackend>, or a class that derives from it, or its GType number.

self

Passed: a <GSettingsBackend>.

key

Passed: a string.

expected-type

Passed: a <GVariantType>.

default-value

Passed: a boolean.

%return

Returned: a <GVariant>.

Virtual method: settings-backend:do-read-user-value implementor self key expected-type ⇒ %return

virtual method to read user’s key value

To override it in a new class, give register-type #:vfuncs `((read-user-value . ,procedure)). The procedure is called as (procedure self key expected-type) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GSettingsBackend>, or a class that derives from it, or its GType number.

self

Passed: a <GSettingsBackend>.

key

Passed: a string.

expected-type

Passed: a <GVariantType>.

%return

Returned: a <GVariant>.

Virtual method: settings-backend:do-reset implementor self key [origin-tag]

virtual method to reset state

To override it in a new class, give register-type #:vfuncs `((reset . ,procedure)). The procedure is called as (procedure self key origin-tag).

implementor

Passed: the class whose implementation to call: <GSettingsBackend>, or a class that derives from it, or its GType number.

self

Passed: a <GSettingsBackend>.

key

Passed: a string.

origin-tag

Passed, or left out: a foreign pointer, or a bytevector, or #f.

Virtual method: settings-backend:do-subscribe implementor self name

virtual method to subscribe to key changes

To override it in a new class, give register-type #:vfuncs `((subscribe . ,procedure)). The procedure is called as (procedure self name).

implementor

Passed: the class whose implementation to call: <GSettingsBackend>, or a class that derives from it, or its GType number.

self

Passed: a <GSettingsBackend>.

name

Passed: a string.

Virtual method: settings-backend:do-sync implementor self

virtual method to sync state

To override it in a new class, give register-type #:vfuncs `((sync . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GSettingsBackend>, or a class that derives from it, or its GType number.

self

Passed: a <GSettingsBackend>.

Virtual method: settings-backend:do-unsubscribe implementor self name

virtual method to unsubscribe to key changes

To override it in a new class, give register-type #:vfuncs `((unsubscribe . ,procedure)). The procedure is called as (procedure self name).

implementor

Passed: the class whose implementation to call: <GSettingsBackend>, or a class that derives from it, or its GType number.

self

Passed: a <GSettingsBackend>.

name

Passed: a string.

Virtual method: settings-backend:do-write implementor self key value [origin-tag] ⇒ %return

virtual method to change key’s value

To override it in a new class, give register-type #:vfuncs `((write . ,procedure)). The procedure is called as (procedure self key value origin-tag) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GSettingsBackend>, or a class that derives from it, or its GType number.

self

Passed: a <GSettingsBackend>.

key

Passed: a string.

value

Passed: a <GVariant>.

origin-tag

Passed, or left out: a foreign pointer, or a bytevector, or #f.

%return

Returned: a boolean.

Virtual method: settings-backend:do-write-tree implementor self tree [origin-tag] ⇒ %return

virtual method to change a tree of keys

To override it in a new class, give register-type #:vfuncs `((write-tree . ,procedure)). The procedure is called as (procedure self tree origin-tag) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GSettingsBackend>, or a class that derives from it, or its GType number.

self

Passed: a <GSettingsBackend>.

tree

Passed: a <GTree>.

origin-tag

Passed, or left out: a foreign pointer, or a bytevector, or #f.

%return

Returned: a boolean.