Do a pass over the backend docs

This commit is contained in:
Matthias Clasen
2010-04-13 10:51:26 -04:00
parent 520ec5f1a9
commit b333be6f5c

View File

@@ -27,8 +27,8 @@ static guint changed_signal;
* SECTION:gsettingsbackend * SECTION:gsettingsbackend
* @short_description: an interface for settings backend implementations * @short_description: an interface for settings backend implementations
* *
* The #GSettingsBackend inteface defines a generic interface for * The #GSettingsBackend interface defines a generic interface for
* non-strictly-typed data backend in a hierarchy. * non-strictly-typed data that is stored in a hierarchy.
* *
* The interface defines methods for reading and writing values, a * The interface defines methods for reading and writing values, a
* method for determining if writing of certain values will fail * method for determining if writing of certain values will fail
@@ -37,14 +37,20 @@ static guint changed_signal;
* The semantics of the interface are very precisely defined and * The semantics of the interface are very precisely defined and
* implementations must carefully adhere to the expectations of * implementations must carefully adhere to the expectations of
* callers that are documented on each of the interface methods. * 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.
* g_settings_backend_create_tree() is a convenience function to create
* suitable trees.
**/ **/
/** /**
* g_settings_backend_changed: * g_settings_backend_changed:
* @backend: a #GSettingsBackend implementation * @backend: a #GSettingsBackend implementation
* @prefix: the longest common prefix * @prefix: a common prefix of the changed keys
* @items: the NULL-terminated list of changed keys * @items: the list of changed keys
* @n_items: the number of items in @items * @n_items: the number of items in @items. May be -1 if @items is
* %NULL-terminated
* @origin_tag: the origin tag * @origin_tag: the origin tag
* *
* Emits the changed signal on @backend. This function should only be * Emits the changed signal on @backend. This function should only be
@@ -71,7 +77,9 @@ static guint changed_signal;
* In the case that this call is in response to a call to * 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 * g_settings_backend_write() then @origin_tag must be set to the same
* value that was passed to that call. * value that was passed to that call.
**/ *
* Since: 2.26
*/
void void
g_settings_backend_changed (GSettingsBackend *backend, g_settings_backend_changed (GSettingsBackend *backend,
const gchar *prefix, const gchar *prefix,
@@ -99,13 +107,15 @@ g_settings_backend_append_to_list (gpointer key,
/** /**
* g_settings_backend_changed_tree: * g_settings_backend_changed_tree:
* @backend: a #GSettingsBackend implementation * @backend: a #GSettingsBackend implementation
* @prefix: the longest common prefix * @prefix: a common prefix of the changed keys
* @tree: a #GTree * @tree: a #GTree containing the changes
* @origin_tag: the origin tag * @origin_tag: the origin tag
* *
* This call is a convenience wrapper around * This call is a convenience wrapper around
* g_settings_backend_changed(). It gets the list of changes from * g_settings_backend_changed(). It gets the list of changes from
* @tree. * @tree.
*
* Since: 2.26
**/ **/
void void
g_settings_backend_changed_tree (GSettingsBackend *backend, g_settings_backend_changed_tree (GSettingsBackend *backend,
@@ -135,18 +145,20 @@ g_settings_backend_changed_tree (GSettingsBackend *backend,
* @backend: a #GSettingsBackend implementation * @backend: a #GSettingsBackend implementation
* @key: the key to read * @key: the key to read
* @expected_type: a #GVariantType hint * @expected_type: a #GVariantType hint
* @returns: the values that was read, or %NULL * @returns: the value that was read, or %NULL
* *
* Reads a keys. This call will never block. * Reads a key. This call will never block.
* *
* If the key exists, it will be returned. If the key does not exist, * If the key exists, the value associated with it will be returned.
* %NULL will be returned. * If the key does not exist, %NULL will be returned.
* *
* If @expected_type is given, it serves as a type hint to the backend. * If @expected_type is given, it serves as a type hint to the backend.
* If you expect a key of a certain type then you should give * If you expect a key of a certain type then you should give
* @expected_type to increase your chances of getting it. Some backends * @expected_type to increase your chances of getting it. Some backends
* may ignore this argument and return values of a different type; it is * may ignore this argument and return values of a different type; it is
* mostly used by backends that don't store strong type information. * mostly used by backends that don't store strong type information.
*
* Since: 2.26
**/ **/
GVariant * GVariant *
g_settings_backend_read (GSettingsBackend *backend, g_settings_backend_read (GSettingsBackend *backend,
@@ -161,7 +173,7 @@ g_settings_backend_read (GSettingsBackend *backend,
* g_settings_backend_write: * g_settings_backend_write:
* @backend: a #GSettingsBackend implementation * @backend: a #GSettingsBackend implementation
* @prefix: the longest common prefix * @prefix: the longest common prefix
* @values: a #GTree containing values to write * @values: a #GTree containing key-value pairs to write
* @origin_tag: the origin tag * @origin_tag: the origin tag
* *
* Writes one or more keys. This call will never block. * Writes one or more keys. This call will never block.
@@ -173,14 +185,16 @@ g_settings_backend_read (GSettingsBackend *backend,
* contains exactly one item, with a key of "". @prefix need not be the * contains exactly one item, with a key of "". @prefix need not be the
* largest possible prefix. * largest possible prefix.
* *
* This call does not fail. During this call a "changed" signal will be * This call does not fail. During this call a #GSettingsBackend::changed
* emitted if any keys have been changed. The new values of all updated * signal will be emitted if any keys have been changed. The new values of
* keys will be visible to any signal callbacks. * all updated keys will be visible to any signal callbacks.
* *
* One possible method that an implementation might deal with failures * One possible method that an implementation might deal with failures is
* is to emit a second "backend-changed" signal (either during this * to emit a second "changed" signal (either during this call, or later)
* call, or later) to indicate that the affected keys have suddenly * to indicate that the affected keys have suddenly "changed back" to their
* "changed back" to their old values. * old values.
*
* Since: 2.26
**/ **/
void void
g_settings_backend_write (GSettingsBackend *backend, g_settings_backend_write (GSettingsBackend *backend,
@@ -198,12 +212,14 @@ g_settings_backend_write (GSettingsBackend *backend,
* @name: the name of a key, relative to the root of the backend * @name: the name of a key, relative to the root of the backend
* @returns: %TRUE if the key is writable * @returns: %TRUE if the key is writable
* *
* Ensures that a key is available for writing to. This is the * Finds out if a key is available for writing to. This is the
* interface through which 'lockdown' is implemented. Locked down * interface through which 'lockdown' is implemented. Locked down
* keys will have %FALSE returned by this call. * keys will have %FALSE returned by this call.
* *
* You should not write to locked-down keys, but if you do, the * You should not write to locked-down keys, but if you do, the
* implementation will deal with it. * implementation will deal with it.
*
* Since: 2.26
**/ **/
gboolean gboolean
g_settings_backend_get_writable (GSettingsBackend *backend, g_settings_backend_get_writable (GSettingsBackend *backend,
@@ -214,12 +230,14 @@ g_settings_backend_get_writable (GSettingsBackend *backend,
} }
/** /**
* g_settings_backend_subscribe: * g_settings_backend_unsubscribe:
* @backend: a #GSettingsBackend * @backend: a #GSettingsBackend
* @name: a key or path to subscribe to * @name: a key or path to subscribe to
* *
* Reverses the effect of a previous call to * Reverses the effect of a previous call to
* g_settings_backend_subscribe(). * g_settings_backend_subscribe().
*
* Since: 2.26
**/ **/
void void
g_settings_backend_unsubscribe (GSettingsBackend *backend, g_settings_backend_unsubscribe (GSettingsBackend *backend,
@@ -235,6 +253,8 @@ g_settings_backend_unsubscribe (GSettingsBackend *backend,
* @name: a key or path to subscribe to * @name: a key or path to subscribe to
* *
* Requests that change signals be emitted for events on @name. * Requests that change signals be emitted for events on @name.
*
* Since: 2.26
**/ **/
void void
g_settings_backend_subscribe (GSettingsBackend *backend, g_settings_backend_subscribe (GSettingsBackend *backend,
@@ -247,6 +267,27 @@ g_settings_backend_subscribe (GSettingsBackend *backend,
static void static void
g_settings_backend_class_init (GSettingsBackendClass *class) g_settings_backend_class_init (GSettingsBackendClass *class)
{ {
/**
* GSettingsBackend::changed:
* @backend: the object on which the signal was emitted
* @prefix: a common prefix of the changed keys
* @items: the list of changed keys
* @n_items: the number of items in @items. May be -1 if @items is
* %NULL-terminated
* @origin_tag: the origin tag
*
* The "changed" signal gets emitted when one or more keys change
* in the #GSettingsBackend store. The new values of all updated
* keys will be visible to any signal callbacks.
*
* The list of changed keys, relative to the root of the settings store,
* is @prefix prepended to each of the @items. It must either be the
* case that @prefix is equal to "" or ends in "/" or that @items
* contains exactly one item: "". @prefix need not be the largest
* possible prefix.
*
* Since: 2.26
*/
changed_signal = changed_signal =
g_signal_new ("changed", G_TYPE_SETTINGS_BACKEND, g_signal_new ("changed", G_TYPE_SETTINGS_BACKEND,
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
@@ -264,7 +305,9 @@ g_settings_backend_class_init (GSettingsBackendClass *class)
* *
* This is a convenience function for creating a tree that is compatible * This is a convenience function for creating a tree that is compatible
* with g_settings_backend_write(). It merely calls g_tree_new_full() * with g_settings_backend_write(). It merely calls g_tree_new_full()
* with strcmp() g_free() and g_variant_unref(). * with strcmp(), g_free() and g_variant_unref().
*
* Since: 2.26
**/ **/
GTree * GTree *
g_settings_backend_create_tree (void) g_settings_backend_create_tree (void)
@@ -314,9 +357,13 @@ get_default_backend (gpointer user_data)
* g_settings_backend_get_default: * g_settings_backend_get_default:
* @returns: the default #GSettingsBackend * @returns: the default #GSettingsBackend
* *
* Returns the default #GSettingsBackend. * Returns the default #GSettingsBackend. It is possible to override
* the default by setting the <envvar>GSETTINGS_BACKEND</envvar>
* environment variable to the name of a settings backend.
* *
* The user does not own the return value and it must not be freed. * The user does not own the return value and it must not be freed.
*
* Since: 2.26
**/ **/
GSettingsBackend * GSettingsBackend *
g_settings_backend_get_default (void) g_settings_backend_get_default (void)