GSettings: Modify backend API

This commit is contained in:
Ryan Lortie
2010-04-15 18:21:49 -04:00
parent 18ba085d0a
commit c2675af4d7
3 changed files with 50 additions and 29 deletions

View File

@@ -24,6 +24,7 @@
#include "config.h" #include "config.h"
#include "gsettingsbackendinternal.h" #include "gsettingsbackendinternal.h"
#include "gnullsettingsbackend.h"
#include "giomodule-priv.h" #include "giomodule-priv.h"
#include "gio-marshal.h" #include "gio-marshal.h"
@@ -509,13 +510,13 @@ g_settings_backend_read (GSettingsBackend *backend,
* to indicate that the affected keys have suddenly "changed back" to their * to indicate that the affected keys have suddenly "changed back" to their
* old values. * old values.
*/ */
void gboolean
g_settings_backend_write (GSettingsBackend *backend, g_settings_backend_write (GSettingsBackend *backend,
const gchar *key, const gchar *key,
GVariant *value, GVariant *value,
gpointer origin_tag) gpointer origin_tag)
{ {
G_SETTINGS_BACKEND_GET_CLASS (backend) return G_SETTINGS_BACKEND_GET_CLASS (backend)
->write (backend, key, value, origin_tag); ->write (backend, key, value, origin_tag);
} }
@@ -542,41 +543,56 @@ g_settings_backend_write (GSettingsBackend *backend,
* to indicate that the affected keys have suddenly "changed back" to their * to indicate that the affected keys have suddenly "changed back" to their
* old values. * old values.
*/ */
void gboolean
g_settings_backend_write_keys (GSettingsBackend *backend, g_settings_backend_write_keys (GSettingsBackend *backend,
GTree *tree, GTree *tree,
gpointer origin_tag) gpointer origin_tag)
{ {
G_SETTINGS_BACKEND_GET_CLASS (backend) return G_SETTINGS_BACKEND_GET_CLASS (backend)
->write_keys (backend, tree, origin_tag); ->write_keys (backend, tree, origin_tag);
} }
/*< private > /*< private >
* g_settings_backend_reset: * g_settings_backend_reset:
* @backend: a #GSettingsBackend implementation * @backend: a #GSettingsBackend implementation
* @name: the name of a key or path * @key: the name of a key
* @origin_tag: the origin tag * @origin_tag: the origin tag
* *
* "Resets" the named key or path. For a key this means that it is * "Resets" the named key to its "default" value (ie: after system-wide
* reverted to its "default" value (ie: after system-wide defaults, * defaults, mandatory keys, etc. have been taken into account) or possibly
* mandatory keys, etc. have been taken into account) or possibly unsets * unsets it.
* it.
*
* For paths, it means that every key under the path is reset.
*/ */
void void
g_settings_backend_reset (GSettingsBackend *backend, g_settings_backend_reset (GSettingsBackend *backend,
const gchar *name, const gchar *key,
gpointer origin_tag) gpointer origin_tag)
{ {
G_SETTINGS_BACKEND_GET_CLASS (backend) G_SETTINGS_BACKEND_GET_CLASS (backend)
->reset (backend, name, origin_tag); ->reset (backend, key, origin_tag);
}
/*< private >
* g_settings_backend_reset_path:
* @backend: a #GSettingsBackend implementation
* @name: the name of a key or path
* @origin_tag: the origin tag
*
* "Resets" the named path. This means that every key under the path is
* reset.
*/
void
g_settings_backend_reset_path (GSettingsBackend *backend,
const gchar *path,
gpointer origin_tag)
{
G_SETTINGS_BACKEND_GET_CLASS (backend)
->reset_path (backend, path, origin_tag);
} }
/*< private > /*< private >
* g_settings_backend_get_writable: * g_settings_backend_get_writable:
* @backend: a #GSettingsBackend implementation * @backend: a #GSettingsBackend implementation
* @name: the name of a key * @key: the name of a key
* @returns: %TRUE if the key is writable * @returns: %TRUE if the key is writable
* *
* Finds out if a key is available for writing to. This is the * Finds out if a key is available for writing to. This is the
@@ -588,10 +604,10 @@ g_settings_backend_reset (GSettingsBackend *backend,
*/ */
gboolean gboolean
g_settings_backend_get_writable (GSettingsBackend *backend, g_settings_backend_get_writable (GSettingsBackend *backend,
const gchar *name) const gchar *key)
{ {
return G_SETTINGS_BACKEND_GET_CLASS (backend) return G_SETTINGS_BACKEND_GET_CLASS (backend)
->get_writable (backend, name); ->get_writable (backend, key);
} }
/*< private > /*< private >
@@ -783,7 +799,7 @@ get_default_backend (const gchar *context)
class = g_io_extension_ref_class (extension); class = g_io_extension_ref_class (extension);
backend_class = G_SETTINGS_BACKEND_CLASS (class); backend_class = G_SETTINGS_BACKEND_CLASS (class);
if (backend_class->supports_context != NULL && if (backend_class->supports_context == NULL ||
!backend_class->supports_context (context)) !backend_class->supports_context (context))
{ {
g_type_class_unref (class); g_type_class_unref (class);
@@ -838,9 +854,7 @@ g_settings_backend_get_with_context (const gchar *context)
backend = get_default_backend (context); backend = get_default_backend (context);
if (!backend) if (!backend)
{ backend = g_null_settings_backend_new ();
/* FIXME: create an instance of the const backend */
}
g_hash_table_insert (backends, g_strdup (context), backend); g_hash_table_insert (backends, g_strdup (context), backend);
} }

View File

@@ -70,18 +70,21 @@ struct _GSettingsBackendClass
GVariant * (*read) (GSettingsBackend *backend, GVariant * (*read) (GSettingsBackend *backend,
const gchar *key, const gchar *key,
const GVariantType *expected_type); const GVariantType *expected_type);
void (*write) (GSettingsBackend *backend, gboolean (*write) (GSettingsBackend *backend,
const gchar *key, const gchar *key,
GVariant *value, GVariant *value,
gpointer origin_tag); gpointer origin_tag);
void (*write_keys) (GSettingsBackend *backend, gboolean (*write_keys) (GSettingsBackend *backend,
GTree *tree, GTree *tree,
gpointer origin_tag); gpointer origin_tag);
void (*reset) (GSettingsBackend *backend, void (*reset) (GSettingsBackend *backend,
const gchar *name, const gchar *key,
gpointer origin_tag);
void (*reset_path) (GSettingsBackend *backend,
const gchar *path,
gpointer origin_tag); gpointer origin_tag);
gboolean (*get_writable) (GSettingsBackend *backend, gboolean (*get_writable) (GSettingsBackend *backend,
const gchar *name); const gchar *key);
void (*subscribe) (GSettingsBackend *backend, void (*subscribe) (GSettingsBackend *backend,
const gchar *name); const gchar *name);
void (*unsubscribe) (GSettingsBackend *backend, void (*unsubscribe) (GSettingsBackend *backend,

View File

@@ -71,23 +71,27 @@ GVariant * g_settings_backend_read (GSettin
const gchar *key, const gchar *key,
const GVariantType *expected_type); const GVariantType *expected_type);
G_GNUC_INTERNAL G_GNUC_INTERNAL
void g_settings_backend_write (GSettingsBackend *backend, gboolean g_settings_backend_write (GSettingsBackend *backend,
const gchar *key, const gchar *key,
GVariant *value, GVariant *value,
gpointer origin_tag); gpointer origin_tag);
G_GNUC_INTERNAL G_GNUC_INTERNAL
void g_settings_backend_write_keys (GSettingsBackend *backend, gboolean g_settings_backend_write_keys (GSettingsBackend *backend,
GTree *tree, GTree *tree,
gpointer origin_tag); gpointer origin_tag);
G_GNUC_INTERNAL G_GNUC_INTERNAL
void g_settings_backend_reset (GSettingsBackend *backend, void g_settings_backend_reset (GSettingsBackend *backend,
const gchar *name, const gchar *key,
gpointer origin_tag);
G_GNUC_INTERNAL
void g_settings_backend_reset_path (GSettingsBackend *backend,
const gchar *path,
gpointer origin_tag); gpointer origin_tag);
G_GNUC_INTERNAL G_GNUC_INTERNAL
gboolean g_settings_backend_get_writable (GSettingsBackend *backend, gboolean g_settings_backend_get_writable (GSettingsBackend *backend,
const char *name); const char *key);
G_GNUC_INTERNAL G_GNUC_INTERNAL
void g_settings_backend_unsubscribe (GSettingsBackend *backend, void g_settings_backend_unsubscribe (GSettingsBackend *backend,
const char *name); const char *name);