summaryrefslogtreecommitdiff
path: root/src/gs-manager.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-11-03 03:52:31 -0700
committerStefano Karapetsas <[email protected]>2012-11-03 03:52:31 -0700
commit2256a902e87b28697407c304bcb96ab1aeb3f669 (patch)
tree723fbf30b7e26a55d01463c0f703bab2c8ee0b88 /src/gs-manager.c
parentce7da346624297407644a1be28f75de0856e1f49 (diff)
parent8d80642d5cd6ce3522029525505abc991087f258 (diff)
downloadmate-screensaver-2256a902e87b28697407c304bcb96ab1aeb3f669.tar.bz2
mate-screensaver-2256a902e87b28697407c304bcb96ab1aeb3f669.tar.xz
Merge pull request #8 from NiceandGently/master
gsettings migration
Diffstat (limited to 'src/gs-manager.c')
-rw-r--r--src/gs-manager.c122
1 files changed, 47 insertions, 75 deletions
diff --git a/src/gs-manager.c b/src/gs-manager.c
index 3deca22..d5758d9 100644
--- a/src/gs-manager.c
+++ b/src/gs-manager.c
@@ -26,8 +26,7 @@
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
-#include <mateconf/mateconf-engine.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#define MATE_DESKTOP_USE_UNSTABLE_API
#include <libmateui/mate-bg.h>
@@ -54,9 +53,8 @@ struct GSManagerPrivate
GHashTable *jobs;
GSThemeManager *theme_manager;
- MateConfClient *client;
+ GSettings *settings;
MateBG *bg;
- guint bg_notify_id;
/* Policy */
glong lock_timeout;
@@ -1034,64 +1032,46 @@ on_bg_changed (MateBG *bg,
gs_debug ("background changed");
}
-static void
-mateconf_changed_callback (MateConfClient *client,
- guint cnxn_id,
- MateConfEntry *entry,
- GSManager *manager)
-{
- mate_bg_load_from_preferences (manager->priv->bg,
- manager->priv->client);
-}
-
-static void
-watch_bg_preferences (GSManager *manager)
+static gboolean
+background_settings_change_event_cb (GSettings *settings,
+ gpointer keys,
+ gint n_keys,
+ GSManager *manager)
{
- g_assert (manager->priv->bg_notify_id == 0);
+#if 0
+ /* FIXME: since we bind user settings instead of system ones,
+ * watching for changes is no longer valid.
+ */
+ mate_bg_load_from_preferences (manager->priv->bg,
+ manager->priv->settings);
+#endif
- mateconf_client_add_dir (manager->priv->client,
- MATE_BG_KEY_DIR,
- MATECONF_CLIENT_PRELOAD_NONE,
- NULL);
- manager->priv->bg_notify_id = mateconf_client_notify_add (manager->priv->client,
- MATE_BG_KEY_DIR,
- (MateConfClientNotifyFunc)mateconf_changed_callback,
- manager,
- NULL,
- NULL);
+ return FALSE;
}
-static MateConfClient *
-get_mateconf_client (void)
+static GSettings *
+get_system_settings (void)
{
- MateConfClient *client;
- GSList *addresses;
- GError *error;
- MateConfEngine *engine;
+ GSettings *settings;
+ gchar **keys;
+ gchar **k;
- client = NULL;
- addresses = NULL;
+ /* FIXME: we need to bind system settings instead of user but
+ * that's currently impossible, not implemented yet.
+ * Hence, reset to system default values.
+ */
+ /* TODO: Ideally we would like to bind some other key, screensaver-specific. */
+ settings = g_settings_new ("org.mate.desktop.background");
- addresses = g_slist_prepend (addresses, "xml:merged:" SYSCONFDIR "/mateconf/mateconf.xml.mandatory");
- addresses = g_slist_prepend (addresses, "xml:merged:" SYSCONFDIR "/mateconf/mateconf.xml.system");
- addresses = g_slist_prepend (addresses, "xml:merged:" SYSCONFDIR "/mateconf/mateconf.xml.defaults");
- addresses = g_slist_reverse (addresses);
+ g_settings_delay (settings);
- error = NULL;
- engine = mateconf_engine_get_for_addresses (addresses, &error);
- if (engine == NULL)
- {
- gs_debug ("Unable to get mateconf engine for addresses: %s", error->message);
- g_error_free (error);
+ keys = g_settings_list_keys (settings);
+ for (k = keys; *k; k++) {
+ g_settings_reset (settings, *k);
}
- else
- {
- client = mateconf_client_get_for_engine (engine);
- }
-
- g_slist_free (addresses);
+ g_strfreev (keys);
- return client;
+ return settings;
}
static void
@@ -1103,19 +1083,20 @@ gs_manager_init (GSManager *manager)
manager->priv->grab = gs_grab_new ();
manager->priv->theme_manager = gs_theme_manager_new ();
- manager->priv->client = get_mateconf_client ();
- if (manager->priv->client != NULL)
- {
- manager->priv->bg = mate_bg_new ();
+ manager->priv->settings = get_system_settings ();
+ manager->priv->bg = mate_bg_new ();
- g_signal_connect (manager->priv->bg,
- "changed",
- G_CALLBACK (on_bg_changed),
- manager);
- watch_bg_preferences (manager);
+ g_signal_connect (manager->priv->bg,
+ "changed",
+ G_CALLBACK (on_bg_changed),
+ manager);
+ g_signal_connect (manager->priv->settings,
+ "change-event",
+ G_CALLBACK (background_settings_change_event_cb),
+ manager);
- mate_bg_load_from_preferences (manager->priv->bg, manager->priv->client);
- }
+ mate_bg_load_from_preferences (manager->priv->bg,
+ manager->priv->settings);
}
static void
@@ -1726,22 +1707,13 @@ gs_manager_finalize (GObject *object)
g_return_if_fail (manager->priv != NULL);
- if (manager->priv->bg_notify_id != 0)
- {
- mateconf_client_remove_dir (manager->priv->client,
- MATE_BG_KEY_DIR,
- NULL);
- mateconf_client_notify_remove (manager->priv->client,
- manager->priv->bg_notify_id);
- manager->priv->bg_notify_id = 0;
- }
if (manager->priv->bg != NULL)
{
g_object_unref (manager->priv->bg);
}
- if (manager->priv->client != NULL)
- {
- g_object_unref (manager->priv->client);
+ if (manager->priv->settings != NULL) {
+ g_settings_revert (manager->priv->settings);
+ g_object_unref (manager->priv->settings);
}
free_themes (manager);