[glib/wip/settings-backend: 6/7] GSettingsBackend: add vfuncs 'apply' and 'revert'
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/settings-backend: 6/7] GSettingsBackend: add vfuncs 'apply' and 'revert'
- Date: Fri, 30 Dec 2011 00:29:30 +0000 (UTC)
commit 4f771072ed07b27d60896797e54cab54970514ee
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Dec 29 15:16:50 2011 -0500
GSettingsBackend: add vfuncs 'apply' and 'revert'
Remove this API from GDelayedSettingsBackend.
gio/gdelayedsettingsbackend.c | 14 ++++++++++----
gio/gdelayedsettingsbackend.h | 4 ----
gio/gsettings.c | 37 ++++++++++++++-----------------------
gio/gsettingsbackend.c | 21 +++++++++++++++++++++
gio/gsettingsbackend.h | 5 ++++-
gio/gsettingsbackendinternal.h | 4 ++++
6 files changed, 53 insertions(+), 32 deletions(-)
---
diff --git a/gio/gdelayedsettingsbackend.c b/gio/gdelayedsettingsbackend.c
index 464b9e5..b0639a9 100644
--- a/gio/gdelayedsettingsbackend.c
+++ b/gio/gdelayedsettingsbackend.c
@@ -165,9 +165,11 @@ g_delayed_settings_backend_get_permission (GSettingsBackend *backend,
/* method calls */
-void
-g_delayed_settings_backend_apply (GDelayedSettingsBackend *delayed)
+static void
+g_delayed_settings_backend_apply (GSettingsBackend *backend)
{
+ GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
+
if (g_tree_nnodes (delayed->priv->delayed) > 0)
{
gboolean success;
@@ -190,9 +192,11 @@ g_delayed_settings_backend_apply (GDelayedSettingsBackend *delayed)
}
}
-void
-g_delayed_settings_backend_revert (GDelayedSettingsBackend *delayed)
+static void
+g_delayed_settings_backend_revert (GSettingsBackend *backend)
{
+ GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
+
if (g_tree_nnodes (delayed->priv->delayed) > 0)
{
GTree *tmp;
@@ -249,6 +253,8 @@ g_delayed_settings_backend_class_init (GDelayedSettingsBackendClass *class)
backend_class->subscribe = g_delayed_settings_backend_subscribe;
backend_class->unsubscribe = g_delayed_settings_backend_unsubscribe;
backend_class->get_permission = g_delayed_settings_backend_get_permission;
+ backend_class->apply = g_delayed_settings_backend_apply;
+ backend_class->revert = g_delayed_settings_backend_revert;
object_class->finalize = g_delayed_settings_backend_finalize;
}
diff --git a/gio/gdelayedsettingsbackend.h b/gio/gdelayedsettingsbackend.h
index b11cae6..aa7d4fa 100644
--- a/gio/gdelayedsettingsbackend.h
+++ b/gio/gdelayedsettingsbackend.h
@@ -60,9 +60,5 @@ G_GNUC_INTERNAL
GType g_delayed_settings_backend_get_type (void);
G_GNUC_INTERNAL
GDelayedSettingsBackend * g_delayed_settings_backend_new (GSettingsBackend *backend);
-G_GNUC_INTERNAL
-void g_delayed_settings_backend_revert (GDelayedSettingsBackend *delayed);
-G_GNUC_INTERNAL
-void g_delayed_settings_backend_apply (GDelayedSettingsBackend *delayed);
#endif /* __G_DELAYED_SETTINGS_BACKEND_H__ */
diff --git a/gio/gsettings.c b/gio/gsettings.c
index d5db03c..ff8c02b 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -231,7 +231,7 @@ struct _GSettingsPrivate
GSettingsSchema *schema;
gchar *path;
- GDelayedSettingsBackend *delayed;
+ gboolean delayed_apply;
};
enum
@@ -597,7 +597,7 @@ g_settings_get_property (GObject *object,
break;
case PROP_DELAY_APPLY:
- g_value_set_boolean (value, settings->priv->delayed != NULL);
+ g_value_set_boolean (value, settings->priv->delayed_apply);
break;
default:
@@ -1939,21 +1939,24 @@ g_settings_set_strv (GSettings *settings,
void
g_settings_delay (GSettings *settings)
{
+ GDelayedSettingsBackend *delayed;
+
g_return_if_fail (G_IS_SETTINGS (settings));
- if (settings->priv->delayed)
+ if (settings->priv->delayed_apply)
return;
- settings->priv->delayed = g_delayed_settings_backend_new (settings->priv->backend);
+ delayed = g_delayed_settings_backend_new (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 (settings->priv->delayed);
- g_signal_connect_object (settings->priv->backend, "event", G_CALLBACK (g_settings_got_event), settings, 0);
-
- g_signal_connect_object (settings->priv->delayed, "notify::has-unapplied",
+ settings->priv->backend = G_SETTINGS_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);
- g_object_notify (G_OBJECT (settings), "delay-apply");
+
+ settings->priv->delayed_apply = TRUE;
}
/**
@@ -1968,13 +1971,7 @@ g_settings_delay (GSettings *settings)
void
g_settings_apply (GSettings *settings)
{
- if (settings->priv->delayed)
- {
- GDelayedSettingsBackend *delayed;
-
- delayed = G_DELAYED_SETTINGS_BACKEND (settings->priv->backend);
- g_delayed_settings_backend_apply (delayed);
- }
+ g_settings_backend_apply (settings->priv->backend);
}
/**
@@ -1991,13 +1988,7 @@ g_settings_apply (GSettings *settings)
void
g_settings_revert (GSettings *settings)
{
- if (settings->priv->delayed)
- {
- GDelayedSettingsBackend *delayed;
-
- delayed = G_DELAYED_SETTINGS_BACKEND (settings->priv->backend);
- g_delayed_settings_backend_revert (delayed);
- }
+ g_settings_backend_revert (settings->priv->backend);
}
/**
diff --git a/gio/gsettingsbackend.c b/gio/gsettingsbackend.c
index 55ede78..9bc77c5 100644
--- a/gio/gsettingsbackend.c
+++ b/gio/gsettingsbackend.c
@@ -703,6 +703,11 @@ ignore_subscription (GSettingsBackend *backend,
}
static void
+ignore_apply (GSettingsBackend *backend)
+{
+}
+
+static void
g_settings_backend_init (GSettingsBackend *backend)
{
backend->priv = G_TYPE_INSTANCE_GET_PRIVATE (backend,
@@ -717,6 +722,8 @@ g_settings_backend_class_init (GSettingsBackendClass *class)
class->subscribe = ignore_subscription;
class->unsubscribe = ignore_subscription;
+ class->apply = ignore_apply;
+ class->revert = ignore_apply;
gobject_class->get_property = g_settings_backend_get_property;
@@ -858,3 +865,17 @@ g_settings_backend_set_has_unapplied (GSettingsBackend *backend,
g_object_notify_by_pspec (G_OBJECT (backend), g_settings_backend_pspecs[PROP_HAS_UNAPPLIED]);
}
}
+
+void
+g_settings_backend_apply (GSettingsBackend *backend)
+{
+ G_SETTINGS_BACKEND_GET_CLASS (backend)
+ ->apply (backend);
+}
+
+void
+g_settings_backend_revert (GSettingsBackend *backend)
+{
+ G_SETTINGS_BACKEND_GET_CLASS (backend)
+ ->revert (backend);
+}
diff --git a/gio/gsettingsbackend.h b/gio/gsettingsbackend.h
index 3a6c19f..24653aa 100644
--- a/gio/gsettingsbackend.h
+++ b/gio/gsettingsbackend.h
@@ -93,7 +93,10 @@ struct _GSettingsBackendClass
GPermission * (*get_permission) (GSettingsBackend *backend,
const gchar *path);
- gpointer padding[24];
+ void (*apply) (GSettingsBackend *backend);
+ void (*revert) (GSettingsBackend *backend);
+
+ gpointer padding[22];
};
struct _GSettingsBackend
diff --git a/gio/gsettingsbackendinternal.h b/gio/gsettingsbackendinternal.h
index 1e927bd..4b5b85d 100644
--- a/gio/gsettingsbackendinternal.h
+++ b/gio/gsettingsbackendinternal.h
@@ -73,6 +73,10 @@ GPermission * g_settings_backend_get_permission (GSettin
G_GNUC_INTERNAL
gboolean g_settings_backend_get_has_unapplied (GSettingsBackend *backend);
G_GNUC_INTERNAL
+void g_settings_backend_apply (GSettingsBackend *backend);
+G_GNUC_INTERNAL
+void g_settings_backend_revert (GSettingsBackend *backend);
+G_GNUC_INTERNAL
void g_settings_backend_sync_default (void);
G_GNUC_INTERNAL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]