[glib] GSettings: Modify backend API
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GSettings: Modify backend API
- Date: Thu, 15 Apr 2010 22:25:46 +0000 (UTC)
commit c2675af4d7d54676745d2c36821ce085cce12111
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Apr 15 18:21:49 2010 -0400
GSettings: Modify backend API
gio/gsettingsbackend.c | 54 +++++++++++++++++++++++++--------------
gio/gsettingsbackend.h | 11 +++++---
gio/gsettingsbackendinternal.h | 14 ++++++---
3 files changed, 50 insertions(+), 29 deletions(-)
---
diff --git a/gio/gsettingsbackend.c b/gio/gsettingsbackend.c
index e818daf..9828929 100644
--- a/gio/gsettingsbackend.c
+++ b/gio/gsettingsbackend.c
@@ -24,6 +24,7 @@
#include "config.h"
#include "gsettingsbackendinternal.h"
+#include "gnullsettingsbackend.h"
#include "giomodule-priv.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
* old values.
*/
-void
+gboolean
g_settings_backend_write (GSettingsBackend *backend,
const gchar *key,
GVariant *value,
gpointer origin_tag)
{
- G_SETTINGS_BACKEND_GET_CLASS (backend)
+ return G_SETTINGS_BACKEND_GET_CLASS (backend)
->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
* old values.
*/
-void
+gboolean
g_settings_backend_write_keys (GSettingsBackend *backend,
GTree *tree,
gpointer origin_tag)
{
- G_SETTINGS_BACKEND_GET_CLASS (backend)
+ return G_SETTINGS_BACKEND_GET_CLASS (backend)
->write_keys (backend, tree, origin_tag);
}
/*< private >
* g_settings_backend_reset:
* @backend: a #GSettingsBackend implementation
- * @name: the name of a key or path
+ * @key: the name of a key
* @origin_tag: the origin tag
*
- * "Resets" the named key or path. For a key this means that it is
- * reverted to its "default" value (ie: after system-wide defaults,
- * mandatory keys, etc. have been taken into account) or possibly unsets
- * it.
- *
- * For paths, it means that every key under the path is reset.
+ * "Resets" the named key to its "default" value (ie: after system-wide
+ * defaults, mandatory keys, etc. have been taken into account) or possibly
+ * unsets it.
*/
void
g_settings_backend_reset (GSettingsBackend *backend,
- const gchar *name,
+ const gchar *key,
gpointer origin_tag)
{
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 >
* g_settings_backend_get_writable:
* @backend: a #GSettingsBackend implementation
- * @name: the name of a key
+ * @key: the name of a key
* @returns: %TRUE if the key is writable
*
* Finds out if a key is available for writing to. This is the
@@ -588,10 +604,10 @@ g_settings_backend_reset (GSettingsBackend *backend,
*/
gboolean
g_settings_backend_get_writable (GSettingsBackend *backend,
- const gchar *name)
+ const gchar *key)
{
return G_SETTINGS_BACKEND_GET_CLASS (backend)
- ->get_writable (backend, name);
+ ->get_writable (backend, key);
}
/*< private >
@@ -783,7 +799,7 @@ get_default_backend (const gchar *context)
class = g_io_extension_ref_class (extension);
backend_class = G_SETTINGS_BACKEND_CLASS (class);
- if (backend_class->supports_context != NULL &&
+ if (backend_class->supports_context == NULL ||
!backend_class->supports_context (context))
{
g_type_class_unref (class);
@@ -838,9 +854,7 @@ g_settings_backend_get_with_context (const gchar *context)
backend = get_default_backend (context);
if (!backend)
- {
- /* FIXME: create an instance of the const backend */
- }
+ backend = g_null_settings_backend_new ();
g_hash_table_insert (backends, g_strdup (context), backend);
}
diff --git a/gio/gsettingsbackend.h b/gio/gsettingsbackend.h
index ecdf51b..04848a5 100644
--- a/gio/gsettingsbackend.h
+++ b/gio/gsettingsbackend.h
@@ -70,18 +70,21 @@ struct _GSettingsBackendClass
GVariant * (*read) (GSettingsBackend *backend,
const gchar *key,
const GVariantType *expected_type);
- void (*write) (GSettingsBackend *backend,
+ gboolean (*write) (GSettingsBackend *backend,
const gchar *key,
GVariant *value,
gpointer origin_tag);
- void (*write_keys) (GSettingsBackend *backend,
+ gboolean (*write_keys) (GSettingsBackend *backend,
GTree *tree,
gpointer origin_tag);
void (*reset) (GSettingsBackend *backend,
- const gchar *name,
+ const gchar *key,
+ gpointer origin_tag);
+ void (*reset_path) (GSettingsBackend *backend,
+ const gchar *path,
gpointer origin_tag);
gboolean (*get_writable) (GSettingsBackend *backend,
- const gchar *name);
+ const gchar *key);
void (*subscribe) (GSettingsBackend *backend,
const gchar *name);
void (*unsubscribe) (GSettingsBackend *backend,
diff --git a/gio/gsettingsbackendinternal.h b/gio/gsettingsbackendinternal.h
index 3e4c5e9..83425e0 100644
--- a/gio/gsettingsbackendinternal.h
+++ b/gio/gsettingsbackendinternal.h
@@ -71,24 +71,28 @@ GVariant * g_settings_backend_read (GSettin
const gchar *key,
const GVariantType *expected_type);
G_GNUC_INTERNAL
-void g_settings_backend_write (GSettingsBackend *backend,
+gboolean g_settings_backend_write (GSettingsBackend *backend,
const gchar *key,
GVariant *value,
gpointer origin_tag);
G_GNUC_INTERNAL
-void g_settings_backend_write_keys (GSettingsBackend *backend,
+gboolean g_settings_backend_write_keys (GSettingsBackend *backend,
GTree *tree,
gpointer origin_tag);
G_GNUC_INTERNAL
void g_settings_backend_reset (GSettingsBackend *backend,
- const gchar *name,
+ const gchar *key,
gpointer origin_tag);
G_GNUC_INTERNAL
-gboolean g_settings_backend_get_writable (GSettingsBackend *backend,
- const char *name);
+void g_settings_backend_reset_path (GSettingsBackend *backend,
+ const gchar *path,
+ gpointer origin_tag);
G_GNUC_INTERNAL
+gboolean g_settings_backend_get_writable (GSettingsBackend *backend,
+ const char *key);
+G_GNUC_INTERNAL
void g_settings_backend_unsubscribe (GSettingsBackend *backend,
const char *name);
G_GNUC_INTERNAL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]