[glib] Add g_settings_sync() and use it
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add g_settings_sync() and use it
- Date: Fri, 11 Jun 2010 02:40:10 +0000 (UTC)
commit a8b5353b1480edbb6a28afe39056bf6a64a1e42d
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Jun 10 22:30:44 2010 -0400
Add g_settings_sync() and use it
docs/reference/gio/gio-sections.txt | 1 +
gio/gio.symbols | 1 +
gio/gsettings-tool.c | 19 +------------------
gio/gsettings.c | 28 ++++++++++++++++++++++++++++
gio/gsettings.h | 1 +
gio/gsettingsbackend.c | 15 +++++++++++++++
gio/gsettingsbackendinternal.h | 2 ++
7 files changed, 49 insertions(+), 18 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index e5531bb..b09f267 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -2135,6 +2135,7 @@ g_settings_new_with_path
g_settings_new_with_context
g_settings_new_with_context_and_path
g_settings_supports_context
+g_settings_sync
g_settings_get_value
g_settings_set_value
g_settings_is_writable
diff --git a/gio/gio.symbols b/gio/gio.symbols
index ab63d7f..3f61cff 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -1467,6 +1467,7 @@ g_settings_get_double
g_settings_set_double
g_settings_get_boolean
g_settings_set_boolean
+g_settings_sync
#endif
#endif
diff --git a/gio/gsettings-tool.c b/gio/gsettings-tool.c
index c9eedfd..c7df959 100644
--- a/gio/gsettings-tool.c
+++ b/gio/gsettings-tool.c
@@ -213,26 +213,9 @@ handle_set (gint *argc,
goto out;
}
+ g_settings_sync (NULL);
ret = 0;
- /* XXX: workaround for now
- *
- * if we exit() so quickly, GDBus may not have had a chance to
- * actually send the message (since we're using it async).
- *
- * GDBusConnection has no API to sync or wait for messages to be sent,
- * so we send a meaningless message and wait for the reply to ensure
- * that all messages that came before must have been sent.
- */
- {
- GDBusConnection *session;
-
- session = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
- g_dbus_connection_call_sync (session, "org.gtk.DoesNotExist", "/",
- "org.gtk.DoesNotExist", "Workaround",
- g_variant_new ("()"), NULL, 0, -1, NULL, NULL);
- }
-
out:
g_option_context_free (context);
diff --git a/gio/gsettings.c b/gio/gsettings.c
index 01db482..7b829f7 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -1860,5 +1860,33 @@ g_settings_set_strv (GSettings *settings,
return g_settings_set_value (settings, key, array);
}
+/**
+ * g_settings_sync:
+ * @context: the context to sync, or %NULL
+ *
+ * Ensures that all pending operations for the given context are
+ * complete.
+ *
+ * Writes made to a #GSettings are handled asynchronously. For this
+ * reason, it is very unlikely that the changes have it to disk by the
+ * time g_settings_set() returns.
+ *
+ * This call will block until all of the writes have made it to the
+ * backend. Since the mainloop is not running, no change notifications
+ * will be dispatched during this call (but some may be queued by the
+ * time the call is done).
+ **/
+void
+g_settings_sync (const gchar *context)
+{
+ GSettingsBackend *backend;
+
+ if (context == NULL)
+ context = "";
+
+ backend = g_settings_backend_get_with_context (context);
+ g_settings_backend_sync (backend);
+}
+
#define __G_SETTINGS_C__
#include "gioaliasdef.c"
diff --git a/gio/gsettings.h b/gio/gsettings.h
index 4b108b2..d766bd0 100644
--- a/gio/gsettings.h
+++ b/gio/gsettings.h
@@ -132,6 +132,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);
/**
* GSettingsBindSetMapping:
diff --git a/gio/gsettingsbackend.c b/gio/gsettingsbackend.c
index dca68bf..dd22593 100644
--- a/gio/gsettingsbackend.c
+++ b/gio/gsettingsbackend.c
@@ -1219,5 +1219,20 @@ g_settings_backend_setup (const gchar *context,
g_object_ref (backend));
}
+/*< private >
+ * g_settings_backend_sync:
+ * @backend: a #GSettingsBackend
+ *
+ * Syncs the backend.
+ */
+void
+g_settings_backend_sync (GSettingsBackend *backend)
+{
+ GSettingsBackendClass *class = G_SETTINGS_BACKEND_GET_CLASS (backend);
+
+ if (class->sync)
+ class->sync (backend);
+}
+
#define __G_SETTINGS_BACKEND_C__
#include "gioaliasdef.c"
diff --git a/gio/gsettingsbackendinternal.h b/gio/gsettingsbackendinternal.h
index 007bfd1..5297e53 100644
--- a/gio/gsettingsbackendinternal.h
+++ b/gio/gsettingsbackendinternal.h
@@ -103,5 +103,7 @@ GPermission * g_settings_backend_get_permission (GSettin
const gchar *path);
G_GNUC_INTERNAL
GMainContext * g_settings_backend_get_active_context (void);
+G_GNUC_INTERNAL
+void g_settings_backend_sync (GSettingsBackend *backend);
#endif /* __G_SETTINGS_BACKEND_INTERNAL_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]