[glib] Bug 621266 - GSettings "context" clarification



commit 6c3ae976e61a9c680c7e18ff89d41d0808a066c4
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Jun 17 14:05:40 2010 -0400

    Bug 621266  - GSettings "context" clarification
    
    Remove the concept of "context" in favour of dealing with
    GSettingsBackend directly.

 gio/gio.symbols                |    9 +--
 gio/gkeyfilesettingsbackend.c  |   39 +--------
 gio/gsettings.c                |   80 +++++++---------
 gio/gsettings.h                |   11 +--
 gio/gsettingsbackend.c         |  192 +++++++++-------------------------------
 gio/gsettingsbackend.h         |   23 ++---
 gio/gsettingsbackendinternal.h |   30 +++----
 gio/tests/Makefile.am          |   11 ++-
 gio/tests/gsettings.c          |    9 +-
 9 files changed, 120 insertions(+), 284 deletions(-)
---
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 4ced155..6fd070c 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -1420,12 +1420,7 @@ g_file_descriptor_based_get_fd
 #endif
 
 #if IN_HEADER(__G_SETTINGS_BACKEND_H__)
-#if IN_FILE(__G_KEYFILE_SETTINGS_BACKEND_C__)
-g_settings_backend_setup_keyfile
-#endif
-
 #if IN_FILE(__G_SETTINGS_BACKEND_C__)
-g_settings_backend_setup
 g_settings_backend_get_type
 g_settings_backend_changed
 g_settings_backend_flatten_tree
@@ -1451,8 +1446,8 @@ g_settings_get_type
 g_settings_get_value
 g_settings_is_writable
 g_settings_new
-g_settings_new_with_context
-g_settings_new_with_context_and_path
+g_settings_new_with_backend
+g_settings_new_with_backend_and_path
 g_settings_new_with_path
 g_settings_revert
 g_settings_set
diff --git a/gio/gkeyfilesettingsbackend.c b/gio/gkeyfilesettingsbackend.c
index b3d0dcd..8d4ae1b 100644
--- a/gio/gkeyfilesettingsbackend.c
+++ b/gio/gkeyfilesettingsbackend.c
@@ -515,7 +515,7 @@ g_keyfile_settings_backend_class_init (GKeyfileSettingsBackendClass *class)
   g_type_class_add_private (class, sizeof (GKeyfileSettingsBackendPrivate));
 }
 
-static GKeyfileSettingsBackend *
+GSettingsBackend *
 g_keyfile_settings_backend_new (const gchar *filename)
 {
   GKeyfileSettingsBackend *kf_backend;
@@ -536,42 +536,7 @@ g_keyfile_settings_backend_new (const gchar *filename)
 
   g_keyfile_settings_backend_keyfile_reload (kf_backend);
 
-  return kf_backend;
-}
-
-/**
- * g_settings_backend_setup_keyfile:
- * @context: a context string (not %NULL or "")
- * @filename: a filename
- *
- * Sets up a keyfile for use with #GSettings.
- *
- * If you create a #GSettings with its context property set to @context
- * then the settings will be stored in the keyfile at @filename.  See
- * g_settings_new_with_context().
- *
- * The keyfile must be setup before any settings objects are created
- * for the named context.
- *
- * It is not possible to specify a keyfile for the default context.
- *
- * If the path leading up to @filename does not exist, it will be
- * recursively created with user-only permissions.  If the keyfile is
- * not writable, any #GSettings objects created using @context will
- * return %FALSE for any calls to g_settings_is_writable() and any
- * attempts to write will fail.
- *
- * Since: 2.26
- */
-void
-g_settings_backend_setup_keyfile (const gchar *context,
-                                  const gchar *filename)
-{
-  GKeyfileSettingsBackend *kf_backend;
-
-  kf_backend = g_keyfile_settings_backend_new (filename);
-  g_settings_backend_setup (context, G_SETTINGS_BACKEND (kf_backend));
-  g_object_unref (kf_backend);
+  return G_SETTINGS_BACKEND (kf_backend);
 }
 
 #define __G_KEYFILE_SETTINGS_BACKEND_C__
diff --git a/gio/gsettings.c b/gio/gsettings.c
index eda09e2..e4c5757 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -236,7 +236,6 @@ struct _GSettingsPrivate
   GSettingsBackend *backend;
   GSettingsSchema *schema;
   gchar *schema_name;
-  gchar *context;
   gchar *path;
 
   GDelayedSettingsBackend *delayed;
@@ -245,9 +244,8 @@ struct _GSettingsPrivate
 enum
 {
   PROP_0,
-  PROP_BACKEND,
   PROP_SCHEMA,
-  PROP_CONTEXT,
+  PROP_BACKEND,
   PROP_PATH,
   PROP_HAS_UNAPPLIED,
 };
@@ -446,8 +444,8 @@ g_settings_set_property (GObject      *object,
       settings->priv->path = g_value_dup_string (value);
       break;
 
-    case PROP_CONTEXT:
-      settings->priv->context = g_value_dup_string (value);
+    case PROP_BACKEND:
+      settings->priv->backend = g_value_dup_object (value);
       break;
 
     default:
@@ -501,7 +499,9 @@ g_settings_constructed (GObject *object)
       settings->priv->path = g_strdup (schema_path);
     }
 
-  settings->priv->backend = g_settings_backend_get_with_context (settings->priv->context);
+  if (settings->priv->backend == NULL)
+    settings->priv->backend = g_settings_backend_get_default ();
+
   g_settings_backend_watch (settings->priv->backend, G_OBJECT (settings),
                             settings->priv->main_context,
                             settings_backend_changed,
@@ -524,7 +524,6 @@ g_settings_finalize (GObject *object)
   g_object_unref (settings->priv->backend);
   g_object_unref (settings->priv->schema);
   g_free (settings->priv->schema_name);
-  g_free (settings->priv->context);
   g_free (settings->priv->path);
 }
 
@@ -668,11 +667,11 @@ g_settings_class_init (GSettingsClass *class)
    *
    * The name of the context that the settings are stored in.
    */
-  g_object_class_install_property (object_class, PROP_CONTEXT,
-    g_param_spec_string ("context",
-                         P_("Context name"),
-                         P_("The name of the context for this settings object"),
-                         "", G_PARAM_CONSTRUCT_ONLY |
+  g_object_class_install_property (object_class, PROP_BACKEND,
+    g_param_spec_object ("backend",
+                         P_("GSettingsBackend"),
+                         P_("The GSettingsBackend for this settings object"),
+                         G_TYPE_SETTINGS_BACKEND, G_PARAM_CONSTRUCT_ONLY |
                          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   /**
@@ -773,66 +772,63 @@ g_settings_new_with_path (const gchar *schema,
 }
 
 /**
- * g_settings_new_with_context:
+ * g_settings_new_with_backend:
  * @schema: the name of the schema
- * @context: the context to use
+ * @backend: the #GSettingsBackend to use
  * @returns: a new #GSettings object
  *
- * Creates a new #GSettings object with a given schema and context.
+ * Creates a new #GSettings object with a given schema and backend.
  *
- * Creating settings objects with a context allow accessing settings
+ * Creating settings objects with an different backend allows accessing settings
  * from a database other than the usual one.  For example, it may make
- * sense to specify "defaults" in order to get a settings object that
- * modifies the system default settings instead of the settings for this
- * user.
- *
- * It is a programmer error to call this function for an unsupported
- * context.  Use g_settings_supports_context() to determine if a context
- * is supported if you are unsure.
+ * sense to pass a backend corresponding to teh "defaults" settings database on
+ * the system to get a settings object that modifies the system default
+ * settings instead of the settings for this user.
  *
  * Since: 2.26
  */
 GSettings *
-g_settings_new_with_context (const gchar *schema,
-                             const gchar *context)
+g_settings_new_with_backend (const gchar      *schema,
+                             GSettingsBackend *backend)
 {
   g_return_val_if_fail (schema != NULL, NULL);
-  g_return_val_if_fail (context != NULL, NULL);
+  g_return_val_if_fail (G_IS_SETTINGS_BACKEND (backend), NULL);
 
   return g_object_new (G_TYPE_SETTINGS,
                        "schema", schema,
-                       "context", context,
+                       "backend", backend,
                        NULL);
 }
 
 /**
- * g_settings_new_with_context_and_path:
+ * g_settings_new_with_backend_and_path:
  * @schema: the name of the schema
+ * @backend: the #GSettingsBackend to use
  * @path: the path to use
  * @returns: a new #GSettings object
  *
- * Creates a new #GSettings object with a given schema, context and
+ * Creates a new #GSettings object with a given schema, backend and
  * path.
  *
- * This is a mix of g_settings_new_with_context() and
+ * This is a mix of g_settings_new_with_backend() and
  * g_settings_new_with_path().
  *
  * Since: 2.26
  */
 GSettings *
-g_settings_new_with_context_and_path (const gchar *schema,
-                                      const gchar *context,
-                                      const gchar *path)
+g_settings_new_with_backend_and_path (const gchar      *schema,
+                                      GSettingsBackend *backend,
+                                      const gchar      *path)
 {
   g_return_val_if_fail (schema != NULL, NULL);
-  g_return_val_if_fail (context != NULL, NULL);
+  g_return_val_if_fail (G_IS_SETTINGS_BACKEND (backend), NULL);
   g_return_val_if_fail (path != NULL, NULL);
 
   return g_object_new (G_TYPE_SETTINGS,
                        "schema", schema,
-                        "context", context,
-                        "path", path,
-                        NULL);
+                       "backend", backend,
+                       "path", path,
+                       NULL);
 }
 
 /* Internal read/write utilities, enum conversion, validation {{{1 */
@@ -1784,15 +1780,9 @@ g_settings_get_has_unapplied (GSettings *settings)
  * time the call is done).
  **/
 void
-g_settings_sync (const gchar *context)
+g_settings_sync (void)
 {
-  GSettingsBackend *backend;
-
-  if (context == NULL)
-    context = "";
-
-  backend = g_settings_backend_get_with_context (context);
-  g_settings_backend_sync (backend);
+  g_settings_backend_sync_default ();
 }
 
 /**
diff --git a/gio/gsettings.h b/gio/gsettings.h
index 07c0391..290f02a 100644
--- a/gio/gsettings.h
+++ b/gio/gsettings.h
@@ -73,11 +73,10 @@ GType                   g_settings_get_type                             (void);
 GSettings *             g_settings_new                                  (const gchar        *schema);
 GSettings *             g_settings_new_with_path                        (const gchar        *schema,
                                                                          const gchar        *path);
-gboolean                g_settings_supports_context                     (const gchar        *context);
-GSettings *             g_settings_new_with_context                     (const gchar        *schema,
-                                                                         const gchar        *context);
-GSettings *             g_settings_new_with_context_and_path            (const gchar        *schema,
-                                                                         const gchar        *context,
+GSettings *             g_settings_new_with_backend                     (const gchar        *schema,
+                                                                         GSettingsBackend   *backend);
+GSettings *             g_settings_new_with_backend_and_path            (const gchar        *schema,
+                                                                         GSettingsBackend   *backend,
                                                                          const gchar        *path);
 
 gboolean                g_settings_set_value                            (GSettings          *settings,
@@ -135,7 +134,7 @@ void                    g_settings_delay                                (GSettin
 void                    g_settings_apply                                (GSettings          *settings);
 void                    g_settings_revert                               (GSettings          *settings);
 gboolean                g_settings_get_has_unapplied                    (GSettings          *settings);
-void                    g_settings_sync                                 (const gchar        *context);
+void                    g_settings_sync                                 ();
 
 /**
  * GSettingsBindSetMapping:
diff --git a/gio/gsettingsbackend.c b/gio/gsettingsbackend.c
index 044ef48..343183e 100644
--- a/gio/gsettingsbackend.c
+++ b/gio/gsettingsbackend.c
@@ -1038,136 +1038,61 @@ g_settings_backend_create_tree (void)
                           g_free, (GDestroyNotify) g_variant_unref);
 }
 
-
-static gpointer
-get_default_backend (const gchar *context)
-{
-  GIOExtension *extension = NULL;
-  GIOExtensionPoint *point;
-  GList *extensions;
-  const gchar *env;
-  GType type;
-
-  _g_io_modules_ensure_loaded ();
-
-  point = g_io_extension_point_lookup (G_SETTINGS_BACKEND_EXTENSION_POINT_NAME);
-
-  if ((env = getenv ("GSETTINGS_BACKEND")))
-    {
-      extension = g_io_extension_point_get_extension_by_name (point, env);
-
-      if (extension == NULL)
-        g_warning ("Can't find GSettings backend '%s' given in "
-                   "GSETTINGS_BACKEND environment variable", env);
-    }
-
-  if (extension == NULL)
-    {
-      extensions = g_io_extension_point_get_extensions (point);
-
-      if (extensions == NULL)
-        g_error ("No GSettingsBackend implementations exist.");
-
-      extension = extensions->data;
-    }
-
-  if (context[0] != '\0') /* (context != "") */
-    {
-      GSettingsBackendClass *backend_class;
-      GTypeClass *class;
-
-      class = g_io_extension_ref_class (extension);
-      backend_class = G_SETTINGS_BACKEND_CLASS (class);
-
-      if (backend_class->supports_context == NULL ||
-          !backend_class->supports_context (context))
-        {
-          g_type_class_unref (class);
-          return NULL;
-        }
-
-      g_type_class_unref (class);
-    }
-
-  type = g_io_extension_get_type (extension);
-
-  return g_object_new (type, "context", context, NULL);
-}
-
-static GHashTable *g_settings_backends;
-
 /*< private >
- * g_settings_backend_get_with_context:
- * @context: a context that might be used by the backend to determine
- *     which storage to use, or %NULL to use the default storage
+ * g_settings_backend_get_default:
  * @returns: the default #GSettingsBackend
  *
  * Returns the default #GSettingsBackend. It is possible to override
  * the default by setting the <envar>GSETTINGS_BACKEND</envar>
  * environment variable to the name of a settings backend.
  *
- * The @context parameter can be used to indicate that a different
- * than the default storage is desired. E.g. the DConf backend lets
- * you use "user", "system", "defaults" and "login" as contexts.
- *
- * If @context is not supported by the implementation, this function
- * returns an instance of the #GSettingsMemoryBackend.
- * See g_settings_backend_supports_context(),
- *
- * The user does not own the return value and it must not be freed.
+ * The user gets a reference to the backend.
  */
 GSettingsBackend *
-g_settings_backend_get_with_context (const gchar *context)
+g_settings_backend_get_default (void)
 {
-  GSettingsBackend *backend;
-
-  g_return_val_if_fail (context != NULL, NULL);
+  static gsize backend;
 
-  _g_io_modules_ensure_extension_points_registered ();
-
-  if (g_settings_backends == NULL)
-    g_settings_backends = g_hash_table_new (g_str_hash, g_str_equal);
+  if (g_once_init_enter (&backend))
+    {
+      GSettingsBackend *instance;
+      GIOExtensionPoint *point;
+      GIOExtension *extension;
+      GType extension_type;
+      GList *extensions;
+      const gchar *env;
 
-  backend = g_hash_table_lookup (g_settings_backends, context);
+      _g_io_modules_ensure_loaded ();
 
-  if (!backend)
-    {
-      backend = get_default_backend (context);
+      point = g_io_extension_point_lookup (G_SETTINGS_BACKEND_EXTENSION_POINT_NAME);
+      extension = NULL;
 
-      if (!backend)
-        backend = g_null_settings_backend_new ();
+      if ((env = getenv ("GSETTINGS_BACKEND")))
+        {
+          extension = g_io_extension_point_get_extension_by_name (point, env);
 
-      g_hash_table_insert (g_settings_backends, g_strdup (context), backend);
-    }
+          if (extension == NULL)
+            g_warning ("Can't find GSettings backend '%s' given in "
+                       "GSETTINGS_BACKEND environment variable", env);
+        }
 
-  return g_object_ref (backend);
-}
+      if (extension == NULL)
+        {
+          extensions = g_io_extension_point_get_extensions (point);
 
-/*< private >
- * g_settings_backend_supports_context:
- * @context: a context string that might be passed to
- *     g_settings_backend_new_with_context()
- * @returns: #TRUE if @context is supported
- *
- * Determines if the given context is supported by the default
- * GSettingsBackend implementation.
- */
-gboolean
-g_settings_backend_supports_context (const gchar *context)
-{
-  GSettingsBackend *backend;
+          if (extensions == NULL)
+            g_error ("No GSettingsBackend implementations exist.");
 
-  g_return_val_if_fail (context != NULL, FALSE);
+          extension = extensions->data;
+        }
 
-  backend = get_default_backend (context);
+      extension_type = g_io_extension_get_type (extension);
+      instance = g_object_new (extension_type, NULL);
 
-  if (backend)
-    {
-      g_object_unref (backend);
-      return TRUE;
+      g_once_init_leave (&backend, (gsize) instance);
     }
 
-  return FALSE;
+  return g_object_ref ((void *) backend);
 }
 
 /*< private >
@@ -1194,54 +1119,19 @@ g_settings_backend_get_permission (GSettingsBackend *backend,
   return g_simple_permission_new (TRUE);
 }
 
-/**
- * g_settings_backend_setup:
- * @context: a context string (not %NULL or "")
- * @backend: a #GSettingsBackend
- *
- * Sets up @backend for use with #GSettings.
- *
- * If you create a #GSettings with its context property set to @context
- * then it will use the backend given to this function.  See
- * g_settings_new_with_context().
- *
- * The backend must be set up before any settings objects are created
- * for the named context.
- *
- * It is not possible to specify a backend for the default context.
- *
- * This function takes a reference on @backend and never releases it.
- *
- * Since: 2.26
- **/
-void
-g_settings_backend_setup (const gchar      *context,
-                          GSettingsBackend *backend)
-{
-  g_return_if_fail (context[0] != '\0');
-  g_return_if_fail (G_IS_SETTINGS_BACKEND (backend));
-
-  if (g_settings_backends == NULL)
-    g_settings_backends = g_hash_table_new (g_str_hash, g_str_equal);
-
-  if (g_hash_table_lookup (g_settings_backends, context))
-    g_error ("A GSettingsBackend already exists for context '%s'", context);
-
-  g_hash_table_insert (g_settings_backends,
-                       g_strdup (context),
-                       g_object_ref (backend));
-}
-
 /*< private >
- * g_settings_backend_sync:
- * @backend: a #GSettingsBackend
+ * g_settings_backend_sync_default:
  *
- * Syncs the backend.
+ * Syncs the default backend.
  */
 void
-g_settings_backend_sync (GSettingsBackend *backend)
+g_settings_backend_sync_default (void)
 {
-  GSettingsBackendClass *class = G_SETTINGS_BACKEND_GET_CLASS (backend);
+  GSettingsBackendClass *class;
+  GSettingsBackend *backend;
+
+  backend = g_settings_backend_get_default ();
+  class = G_SETTINGS_BACKEND_GET_CLASS (backend);
 
   if (class->sync)
     class->sync (backend);
diff --git a/gio/gsettingsbackend.h b/gio/gsettingsbackend.h
index 47456a3..ea1c1e1 100644
--- a/gio/gsettingsbackend.h
+++ b/gio/gsettingsbackend.h
@@ -111,36 +111,33 @@ struct _GSettingsBackend
   GSettingsBackendPrivate *priv;
 };
 
-GType                           g_settings_backend_get_type             (void);
+GType                   g_settings_backend_get_type                     (void);
 
-void                            g_settings_backend_setup                (const gchar         *context,
-                                                                         GSettingsBackend    *backend);
-void                            g_settings_backend_setup_keyfile        (const gchar         *context,
-                                                                         const gchar         *filename);
-
-void                            g_settings_backend_changed              (GSettingsBackend    *backend,
+void                    g_settings_backend_changed                      (GSettingsBackend    *backend,
                                                                          const gchar         *key,
                                                                          gpointer             origin_tag);
-void                            g_settings_backend_path_changed         (GSettingsBackend    *backend,
+void                    g_settings_backend_path_changed                 (GSettingsBackend    *backend,
                                                                          const gchar         *path,
                                                                          gpointer             origin_tag);
-void                            g_settings_backend_flatten_tree         (GTree               *tree,
+void                    g_settings_backend_flatten_tree                 (GTree               *tree,
                                                                          gchar              **path,
                                                                          const gchar       ***keys,
                                                                          GVariant          ***values);
-void                            g_settings_backend_keys_changed         (GSettingsBackend    *backend,
+void                    g_settings_backend_keys_changed                 (GSettingsBackend    *backend,
                                                                          const gchar         *path,
                                                                          gchar const * const *items,
                                                                          gpointer             origin_tag);
 
-void                            g_settings_backend_path_writable_changed(GSettingsBackend    *backend,
+void                    g_settings_backend_path_writable_changed        (GSettingsBackend    *backend,
                                                                          const gchar         *path);
-void                            g_settings_backend_writable_changed     (GSettingsBackend    *backend,
+void                    g_settings_backend_writable_changed             (GSettingsBackend    *backend,
                                                                          const gchar         *key);
-void                            g_settings_backend_changed_tree         (GSettingsBackend    *backend,
+void                    g_settings_backend_changed_tree                 (GSettingsBackend    *backend,
                                                                          GTree               *tree,
                                                                          gpointer             origin_tag);
 
+GSettingsBackend *      g_keyfile_settings_backend_new                  (const gchar         *filename);
+
 G_END_DECLS
 
 #endif /* __G_SETTINGS_BACKEND_H__ */
diff --git a/gio/gsettingsbackendinternal.h b/gio/gsettingsbackendinternal.h
index 5297e53..42338ce 100644
--- a/gio/gsettingsbackendinternal.h
+++ b/gio/gsettingsbackendinternal.h
@@ -60,50 +60,48 @@ void                    g_settings_backend_unwatch                      (GSettin
                                                                          GObject                              *target);
 
 G_GNUC_INTERNAL
-gboolean                        g_settings_backend_supports_context     (const gchar                          *context);
+GTree *                 g_settings_backend_create_tree                  (void);
 G_GNUC_INTERNAL
-GSettingsBackend *              g_settings_backend_get_with_context     (const gchar                          *context);
-G_GNUC_INTERNAL
-GTree *                         g_settings_backend_create_tree          (void);
-G_GNUC_INTERNAL
-GVariant *                      g_settings_backend_read                 (GSettingsBackend                     *backend,
+GVariant *              g_settings_backend_read                         (GSettingsBackend                     *backend,
                                                                          const gchar                          *key,
                                                                          const GVariantType                   *expected_type,
                                                                          gboolean                              default_value);
 G_GNUC_INTERNAL
-gboolean                        g_settings_backend_write                (GSettingsBackend                     *backend,
+gboolean                g_settings_backend_write                        (GSettingsBackend                     *backend,
                                                                          const gchar                          *key,
                                                                          GVariant                             *value,
                                                                          gpointer                              origin_tag);
 G_GNUC_INTERNAL
-gboolean                        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,
+void                    g_settings_backend_reset                        (GSettingsBackend                     *backend,
                                                                          const gchar                          *key,
                                                                          gpointer                              origin_tag);
 
 G_GNUC_INTERNAL
-void                            g_settings_backend_reset_path           (GSettingsBackend                     *backend,
+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,
+gboolean                g_settings_backend_get_writable                 (GSettingsBackend                     *backend,
                                                                          const char                           *key);
 G_GNUC_INTERNAL
-void                            g_settings_backend_unsubscribe          (GSettingsBackend                     *backend,
+void                    g_settings_backend_unsubscribe                  (GSettingsBackend                     *backend,
                                                                          const char                           *name);
 G_GNUC_INTERNAL
-void                            g_settings_backend_subscribe            (GSettingsBackend                     *backend,
+void                    g_settings_backend_subscribe                    (GSettingsBackend                     *backend,
                                                                          const char                           *name);
 G_GNUC_INTERNAL
-GPermission *                   g_settings_backend_get_permission       (GSettingsBackend                     *backend,
+GPermission *           g_settings_backend_get_permission               (GSettingsBackend                     *backend,
                                                                          const gchar                          *path);
 G_GNUC_INTERNAL
-GMainContext *                  g_settings_backend_get_active_context   (void);
+GMainContext *          g_settings_backend_get_active_context           (void);
+G_GNUC_INTERNAL
+GSettingsBackend *      g_settings_backend_get_default                  (void);
 G_GNUC_INTERNAL
-void                            g_settings_backend_sync                 (GSettingsBackend                     *backend);
+void                    g_settings_backend_sync_default                 (void);
 
 #endif  /* __G_SETTINGS_BACKEND_INTERNAL_H__ */
diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am
index ebe6f21..b55cb3b 100644
--- a/gio/tests/Makefile.am
+++ b/gio/tests/Makefile.am
@@ -344,9 +344,10 @@ else
   glib_compile_schemas=$(top_builddir)/gio/glib-compile-schemas
 endif
 
-DISTCLEANFILES =                                        \
-	applications/mimeinfo.cache                     \
-	de/LC_MESSAGES/test.mo                          \
-	test.mo                                         \
-	gsettings.store                                 \
+DISTCLEANFILES = \
+	applications/mimeinfo.cache	\
+	org.gtk.test.enums.xml		\
+	de/LC_MESSAGES/test.mo		\
+	test.mo				\
+	gsettings.store			\
 	gschemas.compiled
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index e18e217..46223b6 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -1120,15 +1120,16 @@ test_no_write_binding (void)
 static void
 test_keyfile (void)
 {
+  GSettingsBackend *kf_backend;
   GSettings *settings;
   GKeyFile *keyfile;
   gchar *str;
 
   g_remove ("gsettings.store");
 
-  g_settings_backend_setup_keyfile ("blah", "gsettings.store");
-
-  settings = g_settings_new_with_context ("org.gtk.test", "blah");
+  kf_backend = g_keyfile_settings_backend_new ("gsettings.store");
+  settings = g_settings_new_with_backend ("org.gtk.test", kf_backend);
+  g_object_unref (kf_backend);
 
   g_settings_set (settings, "greeting", "s", "see if this works");
 
@@ -1390,7 +1391,7 @@ main (int argc, char *argv[])
 
   result = g_test_run ();
 
-  g_settings_sync (NULL);
+  g_settings_sync ();
 
   return result;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]