Gio.SettingsBackend

g GObject.Object GObject.Object Gio.SettingsBackend Gio.SettingsBackend GObject.Object->Gio.SettingsBackend

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

flatten_tree (tree)

class

get_default ()

changed (key, origin_tag)

changed_tree (tree, origin_tag)

keys_changed (path, items, origin_tag)

path_changed (path, origin_tag)

path_writable_changed (path)

writable_changed (key)

Virtual Methods

Inherited:

GObject.Object (7)

do_get_writable (key)

do_read (key, expected_type, default_value)

do_read_user_value (key, expected_type)

do_reset (key, origin_tag)

do_subscribe (name)

do_sync ()

do_unsubscribe (name)

do_write (key, value, origin_tag)

do_write_tree (tree, origin_tag)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Gio.SettingsBackend(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

Gio.SettingsBackendClass

The Gio.SettingsBackend interface defines a generic interface for non-strictly-typed data that is stored in a hierarchy. To implement an alternative storage backend for Gio.Settings, you need to implement the Gio.SettingsBackend interface and then make it implement the extension point Gio.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 Gio.SettingsBackend functions accept or return a GLib.Tree. These trees always have strings as keys and GLib.Variant as values. g_settings_backend_create_tree() is a convenience function to create suitable trees.

The Gio.SettingsBackend 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.

classmethod flatten_tree(tree)[source]
Parameters:

tree (GLib.Tree) – a GLib.Tree containing the changes

Returns:

path:

the location to save the path

keys:

the location to save the relative keys

values:

the location to save the values, or None

Return type:

(path: str, keys: [str], values: [GLib.Variant])

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 GLib.free(). You should not attempt to free or unref the contents of keys or values.

New in version 2.26.

classmethod get_default()[source]
Returns:

the default Gio.SettingsBackend, which will be a dummy (memory) settings backend if no other settings backend is available.

Return type:

Gio.SettingsBackend

Returns the default Gio.SettingsBackend. 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.

New in version 2.28.

changed(key, origin_tag)[source]
Parameters:
  • key (str) – the name of the key

  • origin_tag (object or None) – the 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.

New in version 2.26.

changed_tree(tree, origin_tag)[source]
Parameters:

This call is a convenience wrapper. It gets the list of changes from tree, computes the longest common prefix and calls Gio.SettingsBackend.changed().

New in version 2.26.

keys_changed(path, items, origin_tag)[source]
Parameters:
  • path (str) – the path containing the changes

  • items ([str]) – the None-terminated list of changed keys

  • origin_tag (object or None) – the 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 contatenation of path with each item in items may have changed.

The same rules for when notifications must occur apply as per Gio.SettingsBackend.changed(). These two calls can be used interchangeably if exactly one item has changed (although in that case Gio.SettingsBackend.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.

New in version 2.26.

path_changed(path, origin_tag)[source]
Parameters:
  • path (str) – the path containing the changes

  • origin_tag (object or None) – the 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 Gio.SettingsBackend.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.

New in version 2.26.

path_writable_changed(path)[source]
Parameters:

path (str) – the name of the path

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

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

New in version 2.26.

writable_changed(key)[source]
Parameters:

key (str) – the name of the key

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

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

New in version 2.26.

do_get_writable(key) virtual
Parameters:

key (str) –

Return type:

bool

do_read(key, expected_type, default_value) virtual
Parameters:
Return type:

GLib.Variant

do_read_user_value(key, expected_type) virtual
Parameters:
Return type:

GLib.Variant

do_reset(key, origin_tag) virtual
Parameters:
do_subscribe(name) virtual
Parameters:

name (str) –

do_sync() virtual
do_unsubscribe(name) virtual
Parameters:

name (str) –

do_write(key, value, origin_tag) virtual
Parameters:
Return type:

bool

do_write_tree(tree, origin_tag) virtual
Parameters:
Return type:

bool