1
From 22aff5e2a8c8faa8608cd38951665ccb175d6953 Mon Sep 17 00:00:00 2001
2
From: Tomas Bzatek <tbzatek@redhat.com>
3
Date: Fri, 19 Nov 2010 13:26:14 +0000
4
Subject: Port background handling to GSettings and new gnome-bg API
6
See bug 632566 for details.
8
diff --git a/src/gs-manager.c b/src/gs-manager.c
9
index a6b2404..0f0d42c 100644
10
--- a/src/gs-manager.c
11
+++ b/src/gs-manager.c
16
-#include <gconf/gconf-engine.h>
17
-#include <gconf/gconf-client.h>
19
#define GNOME_DESKTOP_USE_UNSTABLE_API
20
-#include <libgnomeui/gnome-bg.h>
21
+#include <libgnome-desktop/gnome-bg.h>
23
#include "gs-prefs.h" /* for GSSaverMode */
25
@@ -54,9 +51,8 @@ struct GSManagerPrivate
28
GSThemeManager *theme_manager;
29
- GConfClient *client;
30
+ GSettings *settings;
36
@@ -949,61 +945,46 @@ on_bg_changed (GnomeBG *bg,
37
gs_debug ("background changed");
41
-gconf_changed_callback (GConfClient *client,
47
+background_settings_change_event_cb (GSettings *settings,
53
+ /* FIXME: since we bind user settings instead of system ones,
54
+ * watching for changes is no longer valid.
56
gnome_bg_load_from_preferences (manager->priv->bg,
57
- manager->priv->client);
59
+ manager->priv->settings);
63
-watch_bg_preferences (GSManager *manager)
65
- g_assert (manager->priv->bg_notify_id == 0);
67
- gconf_client_add_dir (manager->priv->client,
69
- GCONF_CLIENT_PRELOAD_NONE,
71
- manager->priv->bg_notify_id = gconf_client_notify_add (manager->priv->client,
73
- (GConfClientNotifyFunc)gconf_changed_callback,
81
-get_gconf_client (void)
83
+get_system_settings (void)
85
- GConfClient *client;
88
- GConfEngine *engine;
89
+ GSettings *settings;
95
+ /* FIXME: we need to bind system settings instead of user but
96
+ * that's currently impossible, not implemented yet.
97
+ * Hence, reset to system default values.
99
+ /* TODO: Ideally we would like to bind some other key, screensaver-specific. */
100
+ settings = g_settings_new ("org.gnome.desktop.background");
102
- addresses = g_slist_prepend (addresses, "xml:merged:" SYSCONFDIR "/gconf/gconf.xml.mandatory");
103
- addresses = g_slist_prepend (addresses, "xml:merged:" SYSCONFDIR "/gconf/gconf.xml.system");
104
- addresses = g_slist_prepend (addresses, "xml:merged:" SYSCONFDIR "/gconf/gconf.xml.defaults");
105
- addresses = g_slist_reverse (addresses);
106
+ g_settings_delay (settings);
109
- engine = gconf_engine_get_for_addresses (addresses, &error);
110
- if (engine == NULL) {
111
- gs_debug ("Unable to get gconf engine for addresses: %s", error->message);
112
- g_error_free (error);
114
- client = gconf_client_get_for_engine (engine);
115
+ keys = g_settings_list_keys (settings);
116
+ for (k = keys; *k; k++) {
117
+ g_settings_reset (settings, *k);
121
- g_slist_free (addresses);
128
@@ -1015,18 +996,20 @@ gs_manager_init (GSManager *manager)
129
manager->priv->grab = gs_grab_new ();
130
manager->priv->theme_manager = gs_theme_manager_new ();
132
- manager->priv->client = get_gconf_client ();
133
- if (manager->priv->client != NULL) {
134
- manager->priv->bg = gnome_bg_new ();
135
+ manager->priv->settings = get_system_settings ();
136
+ manager->priv->bg = gnome_bg_new ();
138
- g_signal_connect (manager->priv->bg,
140
- G_CALLBACK (on_bg_changed),
142
- watch_bg_preferences (manager);
143
+ g_signal_connect (manager->priv->bg,
145
+ G_CALLBACK (on_bg_changed),
147
+ g_signal_connect (manager->priv->settings,
149
+ G_CALLBACK (background_settings_change_event_cb),
152
- gnome_bg_load_from_preferences (manager->priv->bg, manager->priv->client);
154
+ gnome_bg_load_from_preferences (manager->priv->bg,
155
+ manager->priv->settings);
159
@@ -1600,19 +1583,12 @@ gs_manager_finalize (GObject *object)
161
g_return_if_fail (manager->priv != NULL);
163
- if (manager->priv->bg_notify_id != 0) {
164
- gconf_client_remove_dir (manager->priv->client,
167
- gconf_client_notify_remove (manager->priv->client,
168
- manager->priv->bg_notify_id);
169
- manager->priv->bg_notify_id = 0;
171
if (manager->priv->bg != NULL) {
172
g_object_unref (manager->priv->bg);
174
- if (manager->priv->client != NULL) {
175
- g_object_unref (manager->priv->client);
176
+ if (manager->priv->settings != NULL) {
177
+ g_settings_revert (manager->priv->settings);
178
+ g_object_unref (manager->priv->settings);
181
free_themes (manager);