[glib/wip/settings-backend: 7/14] GSettingsBackend: add 'delay' vfunc



commit c16ab82d7be30a0877cb75545f184268b5baf6ca
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Dec 29 15:24:16 2011 -0500

    GSettingsBackend: add 'delay' vfunc
    
    This vfunc gets a delayed settings backend appropriate for use with this
    type of GSettingsBackend.

 gio/gdelayedsettingsbackend.c  |    4 +-
 gio/gdelayedsettingsbackend.h  |    2 +-
 gio/gio.symbols                |    2 +-
 gio/gsettings.c                |    8 ++---
 gio/gsettingsbackend.c         |   15 +++++++++
 gio/gsettingsbackend.h         |   65 ++++++++++++++++++++-------------------
 gio/gsettingsbackendinternal.h |    2 +
 7 files changed, 57 insertions(+), 41 deletions(-)
---
diff --git a/gio/gdelayedsettingsbackend.c b/gio/gdelayedsettingsbackend.c
index b0639a9..d176ae8 100644
--- a/gio/gdelayedsettingsbackend.c
+++ b/gio/gdelayedsettingsbackend.c
@@ -270,7 +270,7 @@ g_delayed_settings_backend_init (GDelayedSettingsBackend *delayed)
   g_mutex_init (&delayed->priv->lock);
 }
 
-GDelayedSettingsBackend *
+GSettingsBackend *
 g_delayed_settings_backend_new (GSettingsBackend *backend)
 {
   GDelayedSettingsBackend *delayed;
@@ -280,5 +280,5 @@ g_delayed_settings_backend_new (GSettingsBackend *backend)
 
   g_signal_connect_object (delayed->priv->backend, "event", G_CALLBACK (g_delayed_settings_got_event), delayed, 0);
 
-  return delayed;
+  return G_SETTINGS_BACKEND (delayed);
 }
diff --git a/gio/gdelayedsettingsbackend.h b/gio/gdelayedsettingsbackend.h
index aa7d4fa..984a42d 100644
--- a/gio/gdelayedsettingsbackend.h
+++ b/gio/gdelayedsettingsbackend.h
@@ -59,6 +59,6 @@ struct _GDelayedSettingsBackend
 G_GNUC_INTERNAL
 GType                           g_delayed_settings_backend_get_type     (void);
 G_GNUC_INTERNAL
-GDelayedSettingsBackend *       g_delayed_settings_backend_new          (GSettingsBackend        *backend);
+GSettingsBackend *              g_delayed_settings_backend_new          (GSettingsBackend        *backend);
 
 #endif  /* __G_DELAYED_SETTINGS_BACKEND_H__ */
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 9907f04..814efa3 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -1132,7 +1132,7 @@ g_file_descriptor_based_get_type
 g_file_descriptor_based_get_fd
 #endif
 g_settings_backend_get_type
-g_settings_backend_report_event
+g_settings_backend_event
 g_settings_backend_set_has_unapplied
 g_settings_backend_changed
 g_settings_backend_flatten_tree
diff --git a/gio/gsettings.c b/gio/gsettings.c
index d445d01..f549c7b 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -27,7 +27,6 @@
 
 #include "gsettings.h"
 
-#include "gdelayedsettingsbackend.h"
 #include "gsettingsbackendinternal.h"
 #include "gsettings-mapping.h"
 #include "gsettingsschema-internal.h"
@@ -1962,19 +1961,18 @@ g_settings_set_strv (GSettings           *settings,
 void
 g_settings_delay (GSettings *settings)
 {
-  GDelayedSettingsBackend *delayed;
+  GSettingsBackend *delayed;
 
   g_return_if_fail (G_IS_SETTINGS (settings));
 
   if (settings->priv->delayed_apply)
     return;
 
-  delayed = g_delayed_settings_backend_new (settings->priv->backend);
-
+  delayed = g_settings_backend_delay (settings->priv->backend);
   g_signal_handlers_disconnect_by_func (settings->priv->backend, g_settings_got_event, settings);
   g_object_unref (settings->priv->backend);
 
-  settings->priv->backend = G_SETTINGS_BACKEND (delayed);
+  settings->priv->backend = delayed;
   g_signal_connect_object (delayed, "event", G_CALLBACK (g_settings_got_event), settings, 0);
   g_signal_connect_object (delayed, "notify::has-unapplied",
                            G_CALLBACK (g_settings_got_has_unapplied_notify), settings, 0);
diff --git a/gio/gsettingsbackend.c b/gio/gsettingsbackend.c
index 04dc2ea..7bee343 100644
--- a/gio/gsettingsbackend.c
+++ b/gio/gsettingsbackend.c
@@ -24,6 +24,7 @@
 #include "config.h"
 
 #include "gsettingsbackendinternal.h"
+#include "gdelayedsettingsbackend.h"
 #include "gsimplepermission.h"
 #include "giomodule-priv.h"
 
@@ -708,6 +709,12 @@ ignore_subscription (GSettingsBackend *backend,
 {
 }
 
+static GSettingsBackend *
+g_settings_backend_real_delay (GSettingsBackend *backend)
+{
+  return g_delayed_settings_backend_new (backend);
+}
+
 static void
 ignore_apply (GSettingsBackend *backend)
 {
@@ -728,6 +735,7 @@ g_settings_backend_class_init (GSettingsBackendClass *class)
 
   class->subscribe = ignore_subscription;
   class->unsubscribe = ignore_subscription;
+  class->delay = g_settings_backend_real_delay;
   class->apply = ignore_apply;
   class->revert = ignore_apply;
 
@@ -854,6 +862,13 @@ g_settings_backend_sync_default (void)
     }
 }
 
+GSettingsBackend *
+g_settings_backend_delay (GSettingsBackend *backend)
+{
+  return G_SETTINGS_BACKEND_GET_CLASS (backend)
+    ->delay (backend);
+}
+
 gboolean
 g_settings_backend_get_has_unapplied (GSettingsBackend *backend)
 {
diff --git a/gio/gsettingsbackend.h b/gio/gsettingsbackend.h
index 24653aa..f0da557 100644
--- a/gio/gsettingsbackend.h
+++ b/gio/gsettingsbackend.h
@@ -65,38 +65,39 @@ struct _GSettingsBackendClass
 {
   GObjectClass parent_class;
 
-  GVariant *    (*read)             (GSettingsBackend    *backend,
-                                     const gchar         *key,
-                                     const GVariantType  *expected_type,
-                                     gboolean             default_value);
-
-  gboolean      (*get_writable)     (GSettingsBackend    *backend,
-                                     const gchar         *key);
-
-  gboolean      (*write)            (GSettingsBackend    *backend,
-                                     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);
-
-  void          (*subscribe)        (GSettingsBackend    *backend,
-                                     const gchar         *name);
-  void          (*unsubscribe)      (GSettingsBackend    *backend,
-                                     const gchar         *name);
-  void          (*sync)             (GSettingsBackend    *backend);
-
-  GPermission * (*get_permission)   (GSettingsBackend    *backend,
-                                     const gchar         *path);
-
-  void          (*apply)            (GSettingsBackend    *backend);
-  void          (*revert)           (GSettingsBackend    *backend);
-
-  gpointer padding[22];
+  GVariant *         (* read)           (GSettingsBackend    *backend,
+                                         const gchar         *key,
+                                         const GVariantType  *expected_type,
+                                         gboolean             default_value);
+
+  gboolean           (* get_writable)   (GSettingsBackend    *backend,
+                                         const gchar         *key);
+
+  gboolean           (* write)          (GSettingsBackend    *backend,
+                                         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);
+
+  void               (* subscribe)      (GSettingsBackend    *backend,
+                                         const gchar         *name);
+  void               (* unsubscribe)    (GSettingsBackend    *backend,
+                                         const gchar         *name);
+  void               (* sync)           (GSettingsBackend    *backend);
+
+  GPermission *      (* get_permission) (GSettingsBackend    *backend,
+                                         const gchar         *path);
+
+  GSettingsBackend * (* delay)          (GSettingsBackend    *backend);
+  void               (* apply)          (GSettingsBackend    *backend);
+  void               (* revert)         (GSettingsBackend    *backend);
+
+  gpointer padding[21];
 };
 
 struct _GSettingsBackend
diff --git a/gio/gsettingsbackendinternal.h b/gio/gsettingsbackendinternal.h
index 32b98c2..ac3ea3c 100644
--- a/gio/gsettingsbackendinternal.h
+++ b/gio/gsettingsbackendinternal.h
@@ -71,6 +71,8 @@ G_GNUC_INTERNAL
 GPermission *           g_settings_backend_get_permission               (GSettingsBackend     *backend,
                                                                          const gchar          *path);
 G_GNUC_INTERNAL
+GSettingsBackend *      g_settings_backend_delay                        (GSettingsBackend     *backend);
+G_GNUC_INTERNAL
 gboolean                g_settings_backend_get_has_unapplied            (GSettingsBackend     *backend);
 G_GNUC_INTERNAL
 void                    g_settings_backend_apply                        (GSettingsBackend     *backend);



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