[glib/wip/settings-backend: 9/14] GSettingsBackend: remove 'write_tree' vfunc



commit 3ea81c6adb6fe25ca2f80730a889ef5358813a36
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Dec 30 00:50:51 2011 -0500

    GSettingsBackend: remove 'write_tree' vfunc
    
    This was only used by the (now removed) delayed settings backend.

 gio/gkeyfilesettingsbackend.c  |   54 ------------------------------------
 gio/gmemorysettingsbackend.c   |   27 ------------------
 gio/gnullsettingsbackend.c     |   20 -------------
 gio/gregistrysettingsbackend.c |   29 -------------------
 gio/gsettingsbackend.c         |   60 ----------------------------------------
 gio/gsettingsbackend.h         |    5 +--
 gio/gsettingsbackendinternal.h |    4 --
 7 files changed, 1 insertions(+), 198 deletions(-)
---
diff --git a/gio/gkeyfilesettingsbackend.c b/gio/gkeyfilesettingsbackend.c
index 6601eba..77c25d1 100644
--- a/gio/gkeyfilesettingsbackend.c
+++ b/gio/gkeyfilesettingsbackend.c
@@ -262,59 +262,6 @@ g_keyfile_settings_backend_read (GSettingsBackend   *backend,
   return get_from_keyfile (kfsb, expected_type, key);
 }
 
-typedef struct
-{
-  GKeyfileSettingsBackend *kfsb;
-  gboolean failed;
-} WriteManyData;
-
-static gboolean
-g_keyfile_settings_backend_write_one (gpointer key,
-                                      gpointer value,
-                                      gpointer user_data)
-{
-  WriteManyData *data = user_data;
-  gboolean success;
-
-  success = set_to_keyfile (data->kfsb, key, value);
-  g_assert (success);
-
-  return FALSE;
-}
-
-static gboolean
-g_keyfile_settings_backend_check_one (gpointer key,
-                                      gpointer value,
-                                      gpointer user_data)
-{
-  WriteManyData *data = user_data;
-
-  return data->failed = !path_is_valid (data->kfsb, key);
-}
-
-static gboolean
-g_keyfile_settings_backend_write_tree (GSettingsBackend *backend,
-                                       GTree            *tree,
-                                       gpointer          origin_tag)
-{
-  WriteManyData data = { G_KEYFILE_SETTINGS_BACKEND (backend) };
-
-  if (!data.kfsb->writable)
-    return FALSE;
-
-  g_tree_foreach (tree, g_keyfile_settings_backend_check_one, &data);
-
-  if (data.failed)
-    return FALSE;
-
-  g_tree_foreach (tree, g_keyfile_settings_backend_write_one, &data);
-  g_keyfile_settings_backend_keyfile_write (data.kfsb);
-
-  g_settings_backend_changed_tree (backend, tree, origin_tag);
-
-  return TRUE;
-}
-
 static gboolean
 g_keyfile_settings_backend_write (GSettingsBackend *backend,
                                   const gchar      *key,
@@ -532,7 +479,6 @@ g_keyfile_settings_backend_class_init (GKeyfileSettingsBackendClass *class)
 
   class->read = g_keyfile_settings_backend_read;
   class->write = g_keyfile_settings_backend_write;
-  class->write_tree = g_keyfile_settings_backend_write_tree;
   class->reset = g_keyfile_settings_backend_reset;
   class->get_writable = g_keyfile_settings_backend_get_writable;
   class->get_permission = g_keyfile_settings_backend_get_permission;
diff --git a/gio/gmemorysettingsbackend.c b/gio/gmemorysettingsbackend.c
index 14e3fcd..4b577f0 100644
--- a/gio/gmemorysettingsbackend.c
+++ b/gio/gmemorysettingsbackend.c
@@ -87,32 +87,6 @@ g_memory_settings_backend_write (GSettingsBackend *backend,
   return TRUE;
 }
 
-static gboolean
-g_memory_settings_backend_write_one (gpointer key,
-                                     gpointer value,
-                                     gpointer data)
-{
-  GMemorySettingsBackend *memory = data;
-
-  if (value != NULL)
-    g_hash_table_insert (memory->table, g_strdup (key), g_variant_ref (value));
-  else
-    g_hash_table_remove (memory->table, key);
-
-  return FALSE;
-}
-
-static gboolean
-g_memory_settings_backend_write_tree (GSettingsBackend *backend,
-                                      GTree            *tree,
-                                      gpointer          origin_tag)
-{
-  g_tree_foreach (tree, g_memory_settings_backend_write_one, backend);
-  g_settings_backend_changed_tree (backend, tree, origin_tag);
-
-  return TRUE;
-}
-
 static void
 g_memory_settings_backend_reset (GSettingsBackend *backend,
                                  const gchar      *key,
@@ -167,7 +141,6 @@ g_memory_settings_backend_class_init (GMemorySettingsBackendClass *class)
 
   backend_class->read = g_memory_settings_backend_read;
   backend_class->write = g_memory_settings_backend_write;
-  backend_class->write_tree = g_memory_settings_backend_write_tree;
   backend_class->reset = g_memory_settings_backend_reset;
   backend_class->get_writable = g_memory_settings_backend_get_writable;
   backend_class->get_permission = g_memory_settings_backend_get_permission;
diff --git a/gio/gnullsettingsbackend.c b/gio/gnullsettingsbackend.c
index 523f074..d49d45d 100644
--- a/gio/gnullsettingsbackend.c
+++ b/gio/gnullsettingsbackend.c
@@ -61,25 +61,6 @@ g_null_settings_backend_write (GSettingsBackend *backend,
   return FALSE;
 }
 
-static gboolean
-g_null_settings_backend_write_one (gpointer key,
-                                   gpointer value,
-                                   gpointer data)
-{
-  if (value)
-    g_variant_unref (g_variant_ref_sink (value));
-  return FALSE;
-}
-
-static gboolean
-g_null_settings_backend_write_tree (GSettingsBackend *backend,
-                                    GTree            *tree,
-                                    gpointer          origin_tag)
-{
-  g_tree_foreach (tree, g_null_settings_backend_write_one, backend);
-  return FALSE;
-}
-
 static void
 g_null_settings_backend_reset (GSettingsBackend *backend,
                                const gchar      *key,
@@ -113,7 +94,6 @@ g_null_settings_backend_class_init (GNullSettingsBackendClass *class)
 
   backend_class->read = g_null_settings_backend_read;
   backend_class->write = g_null_settings_backend_write;
-  backend_class->write_tree = g_null_settings_backend_write_tree;
   backend_class->reset = g_null_settings_backend_reset;
   backend_class->get_writable = g_null_settings_backend_get_writable;
   backend_class->get_permission = g_null_settings_backend_get_permission;
diff --git a/gio/gregistrysettingsbackend.c b/gio/gregistrysettingsbackend.c
index c3e5b08..6b4ddca 100644
--- a/gio/gregistrysettingsbackend.c
+++ b/gio/gregistrysettingsbackend.c
@@ -1032,34 +1032,6 @@ g_registry_backend_write (GSettingsBackend *backend,
   return TRUE;
 }
 
-static gboolean
-g_registry_backend_write_tree (GSettingsBackend *backend,
-                               GTree            *values,
-                               gpointer          origin_tag)
-{
-  GRegistryBackend *self = G_REGISTRY_BACKEND (backend);
-  LONG result;
-  HKEY hroot;
-  RegistryWrite action;
-
-  result = RegCreateKeyExA (HKEY_CURRENT_USER, self->base_path, 0, NULL, 0,
-                            KEY_WRITE, NULL, &hroot, NULL);
-  if (result != ERROR_SUCCESS) {
-    trace ("Error opening/creating key %s.\n", self->base_path);
-    return FALSE;
-  }
-
-  action.self =  self;
-  action.hroot = hroot;
-  g_tree_foreach (values, (GTraverseFunc)g_registry_backend_write_one,
-                  &action);
-
-  g_settings_backend_changed_tree (backend, values, origin_tag);
-  RegCloseKey (hroot);
-
-  return TRUE;
-}
-
 static void
 g_registry_backend_reset (GSettingsBackend *backend,
                           const gchar      *key_name,
@@ -1948,7 +1920,6 @@ g_registry_backend_class_init (GRegistryBackendClass *class)
 
   backend_class->read = g_registry_backend_read;
   backend_class->write = g_registry_backend_write;
-  backend_class->write_tree = g_registry_backend_write_tree;
   backend_class->reset = g_registry_backend_reset;
   backend_class->get_writable = g_registry_backend_get_writable;
   backend_class->get_permission = g_registry_backend_get_permission;
diff --git a/gio/gsettingsbackend.c b/gio/gsettingsbackend.c
index fa4e302..26c9c95 100644
--- a/gio/gsettingsbackend.c
+++ b/gio/gsettingsbackend.c
@@ -86,11 +86,6 @@ static gboolean g_settings_has_backend;
  * 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 #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.
- *
  * <note><para>
  * The #GSettingsBackend API is exported to allow third-party
  * implementations, but does not carry the same stability guarantees
@@ -591,38 +586,6 @@ g_settings_backend_write (GSettingsBackend *backend,
 }
 
 /*< private >
- * g_settings_backend_write_keys:
- * @backend: a #GSettingsBackend implementation
- * @values: a #GTree containing key-value pairs to write
- * @origin_tag: the origin tag
- *
- * Writes one or more keys.  This call will never block.
- *
- * The key of each item in the tree is the key name to write to and the
- * value is a #GVariant to write.  The proper type of #GTree for this
- * call can be created with g_settings_backend_create_tree().  This call
- * might take a reference to the tree; you must not modified the #GTree
- * after passing it to this call.
- *
- * This call does not fail.  During this call a #GSettingsBackend::changed
- * signal will be emitted if any keys have been changed.  The new values of
- * all updated keys will be visible to any signal callbacks.
- *
- * One possible method that an implementation might deal with failures is
- * to emit a second "changed" signal (either during this call, or later)
- * to indicate that the affected keys have suddenly "changed back" to their
- * old values.
- */
-gboolean
-g_settings_backend_write_tree (GSettingsBackend *backend,
-                               GTree            *tree,
-                               gpointer          origin_tag)
-{
-  return G_SETTINGS_BACKEND_GET_CLASS (backend)
-    ->write_tree (backend, tree, origin_tag);
-}
-
-/*< private >
  * g_settings_backend_reset:
  * @backend: a #GSettingsBackend implementation
  * @key: the name of a key
@@ -752,29 +715,6 @@ g_settings_backend_class_init (GSettingsBackendClass *class)
   g_type_class_add_private (class, sizeof (GSettingsBackendPrivate));
 }
 
-static void
-g_settings_backend_variant_unref0 (gpointer data)
-{
-  if (data != NULL)
-    g_variant_unref (data);
-}
-
-/*< private >
- * g_settings_backend_create_tree:
- *
- * 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 strcmp(), g_free() and g_variant_unref().
- *
- * Returns: a new #GTree
- */
-GTree *
-g_settings_backend_create_tree (void)
-{
-  return g_tree_new_full ((GCompareDataFunc) strcmp, NULL,
-                          g_free, g_settings_backend_variant_unref0);
-}
-
 static gboolean
 g_settings_backend_verify (gpointer impl)
 {
diff --git a/gio/gsettingsbackend.h b/gio/gsettingsbackend.h
index f0da557..c3d0eb3 100644
--- a/gio/gsettingsbackend.h
+++ b/gio/gsettingsbackend.h
@@ -77,9 +77,6 @@ struct _GSettingsBackendClass
                                          const gchar         *key,
                                          GVariant            *value,
                                          gpointer             origin_tag);
-  gboolean           (* write_tree)     (GSettingsBackend    *backend,
-                                         GTree               *tree,
-                                         gpointer             origin_tag);
   void               (* reset)          (GSettingsBackend    *backend,
                                          const gchar         *key,
                                          gpointer             origin_tag);
@@ -97,7 +94,7 @@ struct _GSettingsBackendClass
   void               (* apply)          (GSettingsBackend    *backend);
   void               (* revert)         (GSettingsBackend    *backend);
 
-  gpointer padding[21];
+  gpointer padding[18];
 };
 
 struct _GSettingsBackend
diff --git a/gio/gsettingsbackendinternal.h b/gio/gsettingsbackendinternal.h
index ac3ea3c..aea3cb2 100644
--- a/gio/gsettingsbackendinternal.h
+++ b/gio/gsettingsbackendinternal.h
@@ -51,10 +51,6 @@ gboolean                g_settings_backend_write                        (GSettin
                                                                          GVariant             *value,
                                                                          gpointer              origin_tag);
 G_GNUC_INTERNAL
-gboolean                g_settings_backend_write_tree                   (GSettingsBackend     *backend,
-                                                                         GTree                *tree,
-                                                                         gpointer              origin_tag);
-G_GNUC_INTERNAL
 void                    g_settings_backend_reset                        (GSettingsBackend     *backend,
                                                                          const gchar          *key,
                                                                          gpointer              origin_tag);



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