Class SettingsBackend
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
SettingsBackend.SettingsBackend$Impl
GSettingsBackend interface defines a generic interface for
non-strictly-typed data that is stored in a hierarchy. To implement
an alternative storage backend for Settings, 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
GLib.Tree. These trees always have strings as keys and
GLib.Variant 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSettingsBackend.Builder<B extends SettingsBackend.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classThe SettingsBackend$Impl type represents a native instance of the abstract SettingsBackend class.static classClass structure forGSettingsBackend.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new SettingsBackend.SettingsBackend(MemorySegment address) Create a SettingsBackend proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected SettingsBackendasParent()Returns this instance as if it were its parent type.voidchanged(String key, @Nullable MemorySegment originTag) Signals that a single key has possibly changed.voidchangedTree(Tree tree, @Nullable MemorySegment originTag) This call is a convenience wrapper.static voidflattenTree(Tree tree, Out<String> path, @Nullable Out<String[]> keys, @Nullable Out<Variant[]> 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.static SettingsBackendReturns the defaultGSettingsBackend.static MemoryLayoutThe memory layout of the native struct.protected PermissiongetPermission(String path) virtual method to get permission of a keystatic @Nullable TypegetType()Get the GType of the SettingsBackend classprotected booleangetWritable(String key) virtual method to get if a key is writablevoidkeysChanged(String path, @Nullable String @Nullable [] items, @Nullable MemorySegment originTag) Signals that a list of keys have possibly changed.voidpathChanged(String path, @Nullable MemorySegment originTag) Signals that all keys below a given path may have possibly changed.voidpathWritableChanged(String path) Signals that the writability of all keys below a given path may have changed.protected Variantread(String key, VariantType expectedType, boolean defaultValue) virtual method to read a key's valueprotected VariantreadUserValue(String key, VariantType expectedType) virtual method to read user's key valueprotected voidreset(String key, @Nullable MemorySegment originTag) virtual method to reset stateprotected voidvirtual method to subscribe to key changesprotected voidsync()virtual method to sync stateprotected voidunsubscribe(String name) virtual method to unsubscribe to key changesvoidwritableChanged(String key) Signals that the writability of a single key has possibly changed.protected booleanwrite(String key, Variant value, @Nullable MemorySegment originTag) virtual method to change key's valueprotected booleanwriteTree(Tree tree, @Nullable MemorySegment originTag) virtual method to change a tree of keysMethods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, builder, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
SettingsBackend
Create a SettingsBackend proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
SettingsBackend
public SettingsBackend()Creates a new SettingsBackend.
-
-
Method Details
-
getType
Get the GType of the SettingsBackend class- Returns:
- the GType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
flattenTree
public static void flattenTree(Tree tree, Out<String> path, @Nullable Out<String[]> keys, @Nullable Out<Variant[]> 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,keysandvaluesusing g_free(). You should not attempt to free or unref the contents ofkeysorvalues.- Parameters:
tree- aGTreecontaining the changespath- the location to save the pathkeys- the location to save the relative keysvalues- the location to save the values, ornull- Since:
- 2.26
-
getDefault
Returns the defaultGSettingsBackend. It is possible to override the default by setting theGSETTINGS_BACKENDenvironment variable to the name of a settings backend.The user gets a reference to the backend.
- Returns:
- the default
GSettingsBackend, which will be a dummy (memory) settings backend if no other settings backend is available. - Since:
- 2.28
-
changed
Signals that a single key has possibly changed. Backend implementations should call this if a key has possibly changed its value.keymust 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
originTagmust be set to the same value that was passed to that call.- Parameters:
key- the name of the keyoriginTag- the origin tag- Since:
- 2.26
-
changedTree
This call is a convenience wrapper. It gets the list of changes fromtree,computes the longest common prefix and calls g_settings_backend_changed().- Parameters:
tree- aGTreecontaining the changesoriginTag- the origin tag- Since:
- 2.26
-
keysChanged
public void keysChanged(String path, @Nullable String @Nullable [] items, @Nullable MemorySegment originTag) Signals that a list of keys have possibly changed. Backend implementations should call this if keys have possibly changed their values.pathmust be a valid path (ie starting and ending with a slash and not containing '//'). Each string initemsmust form a valid key name whenpathis 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
pathwith each item initemsmay have changed.The same rules for when notifications must occur apply as per g_settings_backend_changed(). These two calls can be used interchangeably if exactly one item has changed (although in that case g_settings_backend_changed() is definitely preferred).
For efficiency reasons, the implementation should strive for
pathto be as long as possible (ie: the longest common prefix of all of the keys that were changed) but this is not strictly required.- Parameters:
path- the path containing the changesitems- thenull-terminated list of changed keysoriginTag- the origin tag- Since:
- 2.26
-
pathChanged
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.pathmust 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
pathmay have changed.The same rules for when notifications must occur apply as per g_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
pathto 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.- Parameters:
path- the path containing the changesoriginTag- the origin tag- Since:
- 2.26
-
pathWritableChanged
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.
- Parameters:
path- the name of the path- Since:
- 2.26
-
writableChanged
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.
- Parameters:
key- the name of the key- Since:
- 2.26
-
getPermission
virtual method to get permission of a key -
getWritable
virtual method to get if a key is writable -
read
virtual method to read a key's value -
readUserValue
virtual method to read user's key value -
reset
virtual method to reset state -
subscribe
virtual method to subscribe to key changes -
sync
protected void sync()virtual method to sync state -
unsubscribe
virtual method to unsubscribe to key changes -
write
virtual method to change key's value -
writeTree
virtual method to change a tree of keys
-