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
g_settings_set_double
g_settings_get_boolean
g_settings_set_boolean
+g_settings_sync
#endif
#endif
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);
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"
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:
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"
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__ */