mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Add g_settings_sync() and use it
This commit is contained in:
parent
7c36619d26
commit
a8b5353b14
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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:
|
||||
|
@ -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"
|
||||
|
@ -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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user