summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit <[email protected]>2012-11-03 01:12:52 +0100
committerraveit <[email protected]>2012-11-03 01:12:52 +0100
commit8d80642d5cd6ce3522029525505abc991087f258 (patch)
tree723fbf30b7e26a55d01463c0f703bab2c8ee0b88
parentce7da346624297407644a1be28f75de0856e1f49 (diff)
downloadmate-screensaver-8d80642d5cd6ce3522029525505abc991087f258.tar.bz2
mate-screensaver-8d80642d5cd6ce3522029525505abc991087f258.tar.xz
Port MATE Screensaver to GSettings
-rw-r--r--configure.ac16
-rw-r--r--data/Makefile.am34
-rw-r--r--data/org.mate.screensaver.gschema.migrate16
-rw-r--r--data/org.mate.screensaver.gschema.xml.in85
-rw-r--r--po/POTFILES.in3
-rw-r--r--src/gs-lock-plug.c12
-rw-r--r--src/gs-manager.c122
-rw-r--r--src/gs-prefs.c667
-rw-r--r--src/mate-screensaver-preferences.c340
9 files changed, 433 insertions, 862 deletions
diff --git a/configure.ac b/configure.ac
index e29c232..f1c7559 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,17 +35,21 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Name of default gettext
AM_GLIB_GNU_GETTEXT
+dnl
+dnl Enable gsettigns schema macros
+dnl
+
+GLIB_GSETTINGS
+
# Dependencies
DBUS_REQUIRED_VERSION=0.30
GLIB_REQUIRED_VERSION=2.15.0
-MATECONF_REQUIRED_VERSION=1.1.0
GDK_REQUIRED_VERSION=2.14.0
GTK_REQUIRED_VERSION=2.11.5
X11_REQUIRED_VERSION=1.0
LIBMATE_MENU_REQUIRED_VERSION=1.1.0
MATE_DESKTOP_REQUIRED_VERSION=1.1.0
-
LIBMATEKBDUI_REQUIRED_VERSION=1.1.0
AC_CHECK_HEADERS(unistd.h)
@@ -60,14 +64,14 @@ PKG_CHECK_MODULES(MATE_SCREENSAVER,
x11 >= $X11_REQUIRED_VERSION
gtk+-2.0 >= $GTK_REQUIRED_VERSION
dbus-glib-1 >= $DBUS_REQUIRED_VERSION
- mateconf-2.0 >= $MATECONF_REQUIRED_VERSION
+ gio-2.0 >= $GLIB_REQUIRED_VERSION
mate-desktop-2.0 >= $MATE_DESKTOP_REQUIRED_VERSION
libmate-menu >= $LIBMATE_MENU_REQUIRED_VERSION)
AC_SUBST(MATE_SCREENSAVER_CFLAGS)
AC_SUBST(MATE_SCREENSAVER_LIBS)
PKG_CHECK_MODULES(MATE_SCREENSAVER_DIALOG,
- mateconf-2.0 >= $MATECONF_REQUIRED_VERSION
+ gio-2.0 >= $GLIB_REQUIRED_VERSION
gthread-2.0
gtk+-2.0 >= $GTK_REQUIRED_VERSION)
AC_SUBST(MATE_SCREENSAVER_DIALOG_CFLAGS)
@@ -75,7 +79,6 @@ AC_SUBST(MATE_SCREENSAVER_DIALOG_LIBS)
PKG_CHECK_MODULES(MATE_SCREENSAVER_CAPPLET,
gio-2.0 >= $GLIB_REQUIRED_VERSION
- mateconf-2.0 >= $MATECONF_REQUIRED_VERSION
gtk+-2.0 >= $GTK_REQUIRED_VERSION
libmate-menu >= $LIBMATE_MENU_REQUIRED_VERSION)
AC_SUBST(MATE_SCREENSAVER_CAPPLET_CFLAGS)
@@ -93,9 +96,7 @@ ALL_X_LIBS="$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS"
SAVER_LIBS="$ALL_X_LIBS"
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
-AC_PATH_PROG(MATECONFTOOL, mateconftool-2)
-AM_MATECONF_SOURCE_2
MATE_COMPILE_WARNINGS(yes)
@@ -1074,6 +1075,7 @@ data/Makefile
data/mate-screensavers.menu
data/mate-screensaver.pc
data/org.mate.ScreenSaver.service
+data/org.mate.screensaver.gschema.xml
data/images/Makefile
data/images/cosmos/Makefile
savers/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index 1bae8e9..37e91de 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -9,12 +9,6 @@ man_MANS = \
mate-screensaver-preferences.1 \
$(NULL)
-@INTLTOOL_SCHEMAS_RULE@
-
-schemasdir = @MATECONF_SCHEMA_FILE_DIR@
-schemas_in_files = mate-screensaver.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
-
@INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications
@@ -46,8 +40,17 @@ pkgconfig_DATA = mate-screensaver.pc
dbussessionservicedir = $(DBUS_SESSION_SERVICE_DIR)
dbussessionservice_DATA = org.mate.ScreenSaver.service
+@GSETTINGS_RULES@
+@INTLTOOL_XML_NOMERGE_RULE@
+
+gsettings_SCHEMAS = org.mate.screensaver.gschema.xml
+
+migrationdir = $(datadir)/MateConf/gsettings
+dist_migration_DATA = org.mate.screensaver.gschema.migrate
+
+
EXTRA_DIST = \
- $(schemas_in_files) \
+ $(gsettings_SCHEMAS:.xml=.xml.in.in) \
$(desktop_in_files) \
$(directory_in_files) \
$(gtkbuilder_DATA) \
@@ -60,26 +63,15 @@ EXTRA_DIST = \
$(NULL)
DISTCLEANFILES = \
- $(schemas_DATA) \
+ $(gsettings_SCHEMAS)
$(desktop_DATA) \
$(directory_DATA) \
$(NULL)
MAINTAINERCLEANFILES = \
*~ \
- Makefile.in
-
-if MATECONF_SCHEMAS_INSTALL
-# don't do this if we are building in eg. rpm
-install-data-local: $(schemas_DATA)
- if test -z "$(DESTDIR)" ; then \
- for p in $(schemas_DATA) ; do \
- MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(top_builddir)/data/$$p ; \
- done \
- fi
-else
-install-data-local:
-endif
+ Makefile.in \
+ $(gsettings_SCHEMAS:.xml=.valid)
install-data-hook:
@system=`uname`; \
diff --git a/data/org.mate.screensaver.gschema.migrate b/data/org.mate.screensaver.gschema.migrate
new file mode 100644
index 0000000..27c7b2d
--- /dev/null
+++ b/data/org.mate.screensaver.gschema.migrate
@@ -0,0 +1,16 @@
+[org.mate.screensaver]
+idle-activation-enabled = /apps/mate-screensaver/idle_activation_enabled
+lock-enabled = /apps/mate-screensaver/lock_enabled
+mode = /apps/mate-screensaver/mode
+themes = /apps/mate-screensaver/themes
+idle-delay = /apps/mate-screensaver/idle_delay
+power-management-delay = /apps/mate-screensaver/power_management_delay
+cycle-delay = /apps/mate-screensaver/cycle_delay
+lock-delay = /apps/mate-screensaver/lock_delay
+embedded-keyboard-enabled = /apps/mate-screensaver/embedded_keyboard_enabled
+embedded-keyboard-command = /apps/mate-screensaver/embedded_keyboard_command
+logout-enabled = /apps/mate-screensaver/logout_enabled
+logout-delay = /apps/mate-screensaver/logout_delay
+logout-command = /apps/mate-screensaver/logout_command
+user-switch-enabled = /apps/mate-screensaver/user_switch_enabled
+status-message-enabled = /apps/mate-screensaver/status_message_enabled
diff --git a/data/org.mate.screensaver.gschema.xml.in b/data/org.mate.screensaver.gschema.xml.in
new file mode 100644
index 0000000..bafc579
--- /dev/null
+++ b/data/org.mate.screensaver.gschema.xml.in
@@ -0,0 +1,85 @@
+<schemalist>
+ <enum id="org.mate.screensaver.Mode">
+ <value nick="blank-only" value="0"/>
+ <value nick="random" value="1"/>
+ <value nick="single" value="2"/>
+ </enum>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.mate.screensaver" path="/org/mate-screensaver/">
+ <key name="idle-activation-enabled" type="b">
+ <default>true</default>
+ <summary>Activate when idle</summary>
+ <description>Set this to TRUE to activate the screensaver when the session is idle.</description>
+ </key>
+ <key name="lock-enabled" type="b">
+ <default>true</default>
+ <summary>Lock on activation</summary>
+ <description>Set this to TRUE to lock the screen when the screensaver goes active.</description>
+ </key>
+ <key name="mode" enum="org.mate.screensaver.Mode">
+ <default>'blank-only'</default>
+ <summary>Screensaver theme selection mode</summary>
+ <description>The selection mode used by screensaver. May be "blank-only" to enable the screensaver without using any theme on activation, "single" to enable screensaver using only one theme on activation (specified in "themes" key), and "random" to enable the screensaver using a random theme on activation.</description>
+ </key>
+ <key name="themes" type="as">
+ <default>[]</default>
+ <summary>Screensaver themes</summary>
+ <description>This key specifies the list of themes to be used by the screensaver. It's ignored when "mode" key is "blank-only", should provide the theme name when "mode" is "single", and should provide a list of themes when "mode" is "random".</description>
+ </key>
+ <key name="idle-delay" type="i">
+ <default>10</default>
+ <summary>Time before session is considered idle</summary>
+ <description>The number of minutes of inactivity before the session is considered idle.</description>
+ </key>
+ <key name="power-management-delay" type="i">
+ <default>30</default>
+ <summary>Time before power management baseline</summary>
+ <description>The number of seconds of inactivity before signalling to power management. This key is set and maintained by the session power management agent.</description>
+ </key>
+ <key name="cycle-delay" type="i">
+ <default>10</default>
+ <summary>Time before theme change</summary>
+ <description>The number of minutes to run before changing the screensaver theme.</description>
+ </key>
+ <key name="lock-delay" type="i">
+ <default>0</default>
+ <summary>Time before locking</summary>
+ <description>The number of minutes after screensaver activation before locking the screen.</description>
+ </key>
+ <key name="embedded-keyboard-enabled" type="b">
+ <default>false</default>
+ <summary>Allow embedding a keyboard into the window</summary>
+ <description>Set this to TRUE to allow embedding a keyboard into the window when trying to unlock. The "keyboard_command" key must be set with the appropriate command.</description>
+ </key>
+ <key name="embedded-keyboard-command" type="s">
+ <default>''</default>
+ <summary>Embedded keyboard command</summary>
+ <description>The command that will be run, if the "embedded_keyboard_enabled" key is set to TRUE, to embed a keyboard widget into the window. This command should implement an XEMBED plug interface and output a window XID on the standard output.</description>
+ </key>
+ <key name="logout-enabled" type="b">
+ <default>false</default>
+ <summary>Allow logout</summary>
+ <description>Set this to TRUE to offer an option in the unlock dialog to allow logging out after a delay. The delay is specified in the "logout_delay" key.</description>
+ </key>
+ <key name="logout-delay" type="i">
+ <default>120</default>
+ <summary>Time before logout option</summary>
+ <description>The number of minutes after the screensaver activation before a logout option will appear in the unlock dialog. This key has effect only if the "logout_enable" key is set to TRUE.</description>
+ </key>
+ <key name="logout-command" type="s">
+ <default>''</default>
+ <summary>Logout command</summary>
+ <description>The command to invoke when the logout button is clicked. This command should simply log the user out without any interaction. This key has effect only if the "logout_enable" key is set to TRUE.</description>
+ </key>
+ <key name="user-switch-enabled" type="b">
+ <default>true</default>
+ <summary>Allow user switching</summary>
+ <description>Set this to TRUE to offer an option in the unlock dialog to switch to a different user account.</description>
+ </key>
+ <key name="status-message-enabled" type="b">
+ <default>true</default>
+ <summary>Allow the session status message to be displayed</summary>
+ <description>Allow the session status message to be displayed when the screen is locked.</description>
+ </key>
+ </schema>
+</schemalist>
+
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b259d8a..40895dd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,9 +3,8 @@
data/mate-screensaver-preferences.desktop.in
[type: gettext/glade]data/mate-screensaver-preferences.ui
data/mate-screensaver.directory.in
-data/mate-screensaver.schemas.in
-[type: gettext/glade]data/lock-dialog-default.ui
data/images/cosmos/cosmos.xml.in.in
+data/org.gnome.screensaver.gschema.xml
savers/cosmos-slideshow.desktop.in.in
savers/footlogo-floaters.desktop.in.in
savers/personal-slideshow.desktop.in.in
diff --git a/src/gs-lock-plug.c b/src/gs-lock-plug.c
index 70cf1d7..554d257 100644
--- a/src/gs-lock-plug.c
+++ b/src/gs-lock-plug.c
@@ -37,7 +37,7 @@
#include <gdk/gdkx.h>
#include <X11/XKBlib.h>
#include <gtk/gtk.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#ifdef WITH_KBD_LAYOUT_INDICATOR
#include <libmatekbd/matekbd-indicator.h>
@@ -51,6 +51,8 @@
#include "gs-debug.h"
+#define GSETTINGS_SCHEMA "org.mate.ScreenSaver"
+
#define KEY_LOCK_DIALOG_THEME "/apps/mate-screensaver/lock_dialog_theme"
#define MDM_FLEXISERVER_COMMAND "mdmflexiserver"
@@ -1757,11 +1759,11 @@ static char *
get_dialog_theme_name (GSLockPlug *plug)
{
char *name;
- MateConfClient *client;
+ GSettings *settings;
- client = mateconf_client_get_default ();
- name = mateconf_client_get_string (client, KEY_LOCK_DIALOG_THEME, NULL);
- g_object_unref (client);
+ settings = g_settings_new (GSETTINGS_SCHEMA);
+ name = g_settings_get_string (settings, KEY_LOCK_DIALOG_THEME);
+ g_object_unref (settings);
return name;
}
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);
diff --git a/src/gs-prefs.c b/src/gs-prefs.c
index 0f9d14e..193600b 100644
--- a/src/gs-prefs.c
+++ b/src/gs-prefs.c
@@ -26,7 +26,7 @@
#include <glib.h>
#include <glib-object.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#include "gs-prefs.h"
@@ -34,33 +34,33 @@ static void gs_prefs_class_init (GSPrefsClass *klass);
static void gs_prefs_init (GSPrefs *prefs);
static void gs_prefs_finalize (GObject *object);
-#define MATE_LOCKDOWN_DIR "/desktop/mate/lockdown"
-#define KEY_LOCK_DISABLE MATE_LOCKDOWN_DIR "/disable_lock_screen"
-#define KEY_USER_SWITCH_DISABLE MATE_LOCKDOWN_DIR "/disable_user_switching"
-
-#define KEY_DIR "/apps/mate-screensaver"
-#define MATE_SESSION_DIR "/desktop/mate/session"
-#define KEY_IDLE_ACTIVATION_ENABLED KEY_DIR "/idle_activation_enabled"
-#define KEY_LOCK_ENABLED KEY_DIR "/lock_enabled"
-#define KEY_MODE KEY_DIR "/mode"
-#define KEY_ACTIVATE_DELAY MATE_SESSION_DIR "/idle_delay"
-#define KEY_POWER_DELAY KEY_DIR "/power_management_delay"
-#define KEY_LOCK_DELAY KEY_DIR "/lock_delay"
-#define KEY_CYCLE_DELAY KEY_DIR "/cycle_delay"
-#define KEY_THEMES KEY_DIR "/themes"
-#define KEY_USER_SWITCH_ENABLED KEY_DIR "/user_switch_enabled"
-#define KEY_LOGOUT_ENABLED KEY_DIR "/logout_enabled"
-#define KEY_LOGOUT_DELAY KEY_DIR "/logout_delay"
-#define KEY_LOGOUT_COMMAND KEY_DIR "/logout_command"
-#define KEY_KEYBOARD_ENABLED KEY_DIR "/embedded_keyboard_enabled"
-#define KEY_KEYBOARD_COMMAND KEY_DIR "/embedded_keyboard_command"
-#define KEY_STATUS_MESSAGE_ENABLED KEY_DIR "/status_message_enabled"
+#define LOCKDOWN_SETTINGS_SCHEMA "org.mate.desktop.lockdown"
+#define KEY_LOCK_DISABLE "disable-lock-screen"
+#define KEY_USER_SWITCH_DISABLE "disable-user-switching"
+
+#define GSETTINGS_SCHEMA "org.mate.screensaver"
+#define KEY_IDLE_ACTIVATION_ENABLED "idle-activation-enabled"
+#define KEY_LOCK_ENABLED "lock-enabled"
+#define KEY_MODE "mode"
+#define KEY_ACTIVATE_DELAY "idle-delay"
+#define KEY_POWER_DELAY "power-management-delay"
+#define KEY_LOCK_DELAY "lock-delay"
+#define KEY_CYCLE_DELAY "cycle-delay"
+#define KEY_THEMES "themes"
+#define KEY_USER_SWITCH_ENABLED "user-switch-enabled"
+#define KEY_LOGOUT_ENABLED "logout-enabled"
+#define KEY_LOGOUT_DELAY "logout-delay"
+#define KEY_LOGOUT_COMMAND "logout-command"
+#define KEY_KEYBOARD_ENABLED "embedded-keyboard-enabled"
+#define KEY_KEYBOARD_COMMAND "embedded-keyboard-command"
+#define KEY_STATUS_MESSAGE_ENABLED "status-message-enabled"
#define GS_PREFS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GS_TYPE_PREFS, GSPrefsPrivate))
struct GSPrefsPrivate
{
- MateConfClient *mateconf_client;
+ GSettings *settings;
+ GSettings *lockdown;
};
enum
@@ -74,14 +74,6 @@ enum
PROP_0
};
-static MateConfEnumStringPair mode_enum_map [] =
-{
- { GS_MODE_BLANK_ONLY, "blank-only" },
- { GS_MODE_RANDOM, "random" },
- { GS_MODE_SINGLE, "single" },
- { 0, NULL }
-};
-
static guint signals [LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (GSPrefs, gs_prefs, G_TYPE_OBJECT)
@@ -202,20 +194,16 @@ _gs_prefs_set_cycle_timeout (GSPrefs *prefs,
static void
_gs_prefs_set_mode (GSPrefs *prefs,
- const char *value)
+ gint mode)
{
- int mode;
-
- if (value && mateconf_string_to_enum (mode_enum_map, value, &mode))
- prefs->mode = mode;
- else
- prefs->mode = GS_MODE_BLANK_ONLY;
+ prefs->mode = mode;
}
static void
_gs_prefs_set_themes (GSPrefs *prefs,
- GSList *list)
+ gchar **values)
{
+ guint i;
if (prefs->themes)
{
g_slist_foreach (prefs->themes, (GFunc)g_free, NULL);
@@ -223,7 +211,9 @@ _gs_prefs_set_themes (GSPrefs *prefs,
}
/* take ownership of the list */
- prefs->themes = list;
+ prefs->themes = NULL;
+ for (i=0; values[i] != NULL; i++)
+ prefs->themes = g_slist_append (prefs->themes, g_strdup (values[i]));
}
static void
@@ -328,572 +318,214 @@ _gs_prefs_set_user_switch_enabled (GSPrefs *prefs,
}
static void
-key_error_and_free (const char *key,
- GError *error)
-{
- g_warning ("Error retrieving configuration key '%s': %s", key, error->message);
- g_error_free (error);
- error = NULL;
-}
-
-static void
-gs_prefs_load_from_mateconf (GSPrefs *prefs)
+gs_prefs_load_from_settings (GSPrefs *prefs)
{
glong value;
gboolean bvalue;
char *string;
- GSList *list;
- GError *error;
+ gchar **strv;
+ gint mode;
- error = NULL;
- bvalue = mateconf_client_get_bool (prefs->priv->mateconf_client, KEY_IDLE_ACTIVATION_ENABLED, &error);
- if (! error)
- {
- _gs_prefs_set_idle_activation_enabled (prefs, bvalue);
- }
- else
- {
- key_error_and_free (KEY_IDLE_ACTIVATION_ENABLED, error);
- }
+ bvalue = g_settings_get_boolean (prefs->priv->settings, KEY_IDLE_ACTIVATION_ENABLED);
+ _gs_prefs_set_idle_activation_enabled (prefs, bvalue);
- error = NULL;
- bvalue = mateconf_client_get_bool (prefs->priv->mateconf_client, KEY_LOCK_ENABLED, &error);
- if (! error)
- {
- _gs_prefs_set_lock_enabled (prefs, bvalue);
- }
- else
- {
- key_error_and_free (KEY_LOCK_ENABLED, error);
- }
+ bvalue = g_settings_get_boolean (prefs->priv->settings, KEY_LOCK_ENABLED);
+ _gs_prefs_set_lock_enabled (prefs, bvalue);
- error = NULL;
- bvalue = mateconf_client_get_bool (prefs->priv->mateconf_client, KEY_LOCK_DISABLE, &error);
- if (! error)
- {
- _gs_prefs_set_lock_disabled (prefs, bvalue);
- }
- else
- {
- key_error_and_free (KEY_LOCK_DISABLE, error);
- }
+ bvalue = g_settings_get_boolean (prefs->priv->lockdown, KEY_LOCK_DISABLE);
+ _gs_prefs_set_lock_disabled (prefs, bvalue);
- error = NULL;
- bvalue = mateconf_client_get_bool (prefs->priv->mateconf_client, KEY_USER_SWITCH_DISABLE, &error);
- if (! error)
- {
- _gs_prefs_set_user_switch_disabled (prefs, bvalue);
- }
- else
- {
- key_error_and_free (KEY_USER_SWITCH_DISABLE, error);
- }
+ bvalue = g_settings_get_boolean (prefs->priv->lockdown, KEY_USER_SWITCH_DISABLE);
+ _gs_prefs_set_user_switch_disabled (prefs, bvalue);
- error = NULL;
- value = mateconf_client_get_int (prefs->priv->mateconf_client, KEY_ACTIVATE_DELAY, &error);
- if (! error)
- {
- _gs_prefs_set_timeout (prefs, value);
- }
- else
- {
- key_error_and_free (KEY_ACTIVATE_DELAY, error);
- }
+ value = g_settings_get_int (prefs->priv->settings, KEY_ACTIVATE_DELAY);
+ _gs_prefs_set_timeout (prefs, value);
- error = NULL;
- value = mateconf_client_get_int (prefs->priv->mateconf_client, KEY_POWER_DELAY, &error);
- if (! error)
- {
- _gs_prefs_set_power_timeout (prefs, value);
- }
- else
- {
- key_error_and_free (KEY_POWER_DELAY, error);
- }
+ value = g_settings_get_int (prefs->priv->settings, KEY_POWER_DELAY);
+ _gs_prefs_set_power_timeout (prefs, value);
- error = NULL;
- value = mateconf_client_get_int (prefs->priv->mateconf_client, KEY_LOCK_DELAY, &error);
- if (! error)
- {
- _gs_prefs_set_lock_timeout (prefs, value);
- }
- else
- {
- key_error_and_free (KEY_LOCK_DELAY, error);
- }
+ value = g_settings_get_int (prefs->priv->settings, KEY_LOCK_DELAY);
+ _gs_prefs_set_lock_timeout (prefs, value);
- error = NULL;
- value = mateconf_client_get_int (prefs->priv->mateconf_client, KEY_CYCLE_DELAY, &error);
- if (! error)
- {
- _gs_prefs_set_cycle_timeout (prefs, value);
- }
- else
- {
- key_error_and_free (KEY_CYCLE_DELAY, error);
- }
+ value = g_settings_get_int (prefs->priv->settings, KEY_CYCLE_DELAY);
+ _gs_prefs_set_cycle_timeout (prefs, value);
- error = NULL;
- string = mateconf_client_get_string (prefs->priv->mateconf_client, KEY_MODE, &error);
- if (! error)
- {
- _gs_prefs_set_mode (prefs, string);
- }
- else
- {
- key_error_and_free (KEY_MODE, error);
- }
- g_free (string);
+ mode = g_settings_get_enum (prefs->priv->settings, KEY_MODE);
+ _gs_prefs_set_mode (prefs, mode);
- error = NULL;
- list = mateconf_client_get_list (prefs->priv->mateconf_client,
- KEY_THEMES,
- MATECONF_VALUE_STRING,
- &error);
- if (! error)
- {
- _gs_prefs_set_themes (prefs, list);
- }
- else
- {
- key_error_and_free (KEY_THEMES, error);
- }
+ strv = g_settings_get_strv (prefs->priv->settings, KEY_THEMES);
+ _gs_prefs_set_themes (prefs, strv);
+ g_strfreev (strv);
/* Embedded keyboard options */
- error = NULL;
- bvalue = mateconf_client_get_bool (prefs->priv->mateconf_client, KEY_KEYBOARD_ENABLED, &error);
- if (! error)
- {
- _gs_prefs_set_keyboard_enabled (prefs, bvalue);
- }
- else
- {
- key_error_and_free (KEY_KEYBOARD_ENABLED, error);
- }
+ bvalue = g_settings_get_boolean (prefs->priv->settings, KEY_KEYBOARD_ENABLED);
+ _gs_prefs_set_keyboard_enabled (prefs, bvalue);
- error = NULL;
- string = mateconf_client_get_string (prefs->priv->mateconf_client, KEY_KEYBOARD_COMMAND, &error);
- if (! error)
- {
- _gs_prefs_set_keyboard_command (prefs, string);
- }
- else
- {
- key_error_and_free (KEY_KEYBOARD_COMMAND, error);
- }
+ string = g_settings_get_string (prefs->priv->settings, KEY_KEYBOARD_COMMAND);
+ _gs_prefs_set_keyboard_command (prefs, string);
g_free (string);
- error = NULL;
- bvalue = mateconf_client_get_bool (prefs->priv->mateconf_client, KEY_STATUS_MESSAGE_ENABLED, &error);
- if (! error)
- {
- _gs_prefs_set_status_message_enabled (prefs, bvalue);
- }
- else
- {
- key_error_and_free (KEY_STATUS_MESSAGE_ENABLED, error);
- }
+ bvalue = g_settings_get_boolean (prefs->priv->settings, KEY_STATUS_MESSAGE_ENABLED);
+ _gs_prefs_set_status_message_enabled (prefs, bvalue);
/* Logout options */
- error = NULL;
- bvalue = mateconf_client_get_bool (prefs->priv->mateconf_client, KEY_LOGOUT_ENABLED, &error);
- if (! error)
- {
- _gs_prefs_set_logout_enabled (prefs, bvalue);
- }
- else
- {
- key_error_and_free (KEY_LOGOUT_ENABLED, error);
- }
+ bvalue = g_settings_get_boolean (prefs->priv->settings, KEY_LOGOUT_ENABLED);
+ _gs_prefs_set_logout_enabled (prefs, bvalue);
- error = NULL;
- string = mateconf_client_get_string (prefs->priv->mateconf_client, KEY_LOGOUT_COMMAND, &error);
- if (! error)
- {
- _gs_prefs_set_logout_command (prefs, string);
- }
- else
- {
- key_error_and_free (KEY_LOGOUT_COMMAND, error);
- }
+ string = g_settings_get_string (prefs->priv->settings, KEY_LOGOUT_COMMAND);
+ _gs_prefs_set_logout_command (prefs, string);
g_free (string);
- error = NULL;
- value = mateconf_client_get_int (prefs->priv->mateconf_client, KEY_LOGOUT_DELAY, &error);
- if (! error)
- {
- _gs_prefs_set_logout_timeout (prefs, value);
- }
- else
- {
- key_error_and_free (KEY_LOGOUT_DELAY, error);
- }
+ value = g_settings_get_int (prefs->priv->settings, KEY_LOGOUT_DELAY);
+ _gs_prefs_set_logout_timeout (prefs, value);
/* User switching options */
- error = NULL;
- bvalue = mateconf_client_get_bool (prefs->priv->mateconf_client, KEY_USER_SWITCH_ENABLED, &error);
- if (! error)
- {
- _gs_prefs_set_user_switch_enabled (prefs, bvalue);
- }
- else
- {
- key_error_and_free (KEY_USER_SWITCH_ENABLED, error);
- }
-}
-
-static void
-invalid_type_warning (const char *type)
-{
- g_warning ("Error retrieving configuration key '%s': Invalid type",
- type);
+ bvalue = g_settings_get_boolean (prefs->priv->settings, KEY_USER_SWITCH_ENABLED);
+ _gs_prefs_set_user_switch_enabled (prefs, bvalue);
}
static void
-key_changed_cb (MateConfClient *client,
- guint cnxn_id,
- MateConfEntry *entry,
- GSPrefs *prefs)
+key_changed_cb (GSettings *settings,
+ const gchar *key,
+ GSPrefs *prefs)
{
- gboolean changed = FALSE;
- const char *key;
- MateConfValue *value;
-
- key = mateconf_entry_get_key (entry);
-
- if (! g_str_has_prefix (key, KEY_DIR) && ! g_str_has_prefix (key, MATE_LOCKDOWN_DIR))
- return;
-
- value = mateconf_entry_get_value (entry);
-
if (strcmp (key, KEY_MODE) == 0)
{
+ gint mode;
- if (value->type == MATECONF_VALUE_STRING)
- {
- const char *str;
-
- str = mateconf_value_get_string (value);
- _gs_prefs_set_mode (prefs, str);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ mode = g_settings_get_enum (settings, key);
+ _gs_prefs_set_mode (prefs, mode);
}
else if (strcmp (key, KEY_THEMES) == 0)
{
- GSList *list = NULL;
-
- if (value == NULL
- || value->type != MATECONF_VALUE_LIST)
- {
- return;
- }
-
- list = mateconf_value_get_list (value);
-
- if (list
- && mateconf_value_get_list_type (value) == MATECONF_VALUE_STRING)
- {
- GSList *l;
- GSList *new_list;
-
- changed = TRUE;
-
- new_list = NULL;
- for (l = list; l; l = l->next)
- {
- char *s;
-
- s = mateconf_value_to_string (l->data);
-
- new_list = g_slist_prepend (new_list, g_strdup (s));
-
- g_free (s);
- }
+ gchar **strv = NULL;
- new_list = g_slist_reverse (new_list);
-
- _gs_prefs_set_themes (prefs, new_list);
-
- }
+ strv = g_settings_get_strv (settings, key);
+ _gs_prefs_set_themes (prefs, strv);
+ g_strfreev (strv);
}
else if (strcmp (key, KEY_ACTIVATE_DELAY) == 0)
{
+ int delay;
- if (value->type == MATECONF_VALUE_INT)
- {
- int delay;
-
- delay = mateconf_value_get_int (value);
- _gs_prefs_set_timeout (prefs, delay);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ delay = g_settings_get_int (settings, key);
+ _gs_prefs_set_timeout (prefs, delay);
}
else if (strcmp (key, KEY_POWER_DELAY) == 0)
{
+ int delay;
- if (value->type == MATECONF_VALUE_INT)
- {
- int delay;
-
- delay = mateconf_value_get_int (value);
- _gs_prefs_set_power_timeout (prefs, delay);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ delay = g_settings_get_int (settings, key);
+ _gs_prefs_set_power_timeout (prefs, delay);
}
else if (strcmp (key, KEY_LOCK_DELAY) == 0)
{
+ int delay;
- if (value->type == MATECONF_VALUE_INT)
- {
- int delay;
-
- delay = mateconf_value_get_int (value);
- _gs_prefs_set_lock_timeout (prefs, delay);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
-
+ delay = g_settings_get_int (settings, key);
+ _gs_prefs_set_lock_timeout (prefs, delay);
}
else if (strcmp (key, KEY_IDLE_ACTIVATION_ENABLED) == 0)
{
+ gboolean enabled;
- if (value->type == MATECONF_VALUE_BOOL)
- {
- gboolean enabled;
-
- enabled = mateconf_value_get_bool (value);
- _gs_prefs_set_idle_activation_enabled (prefs, enabled);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ enabled = g_settings_get_boolean (settings, key);
+ _gs_prefs_set_idle_activation_enabled (prefs, enabled);
}
else if (strcmp (key, KEY_LOCK_ENABLED) == 0)
{
+ gboolean enabled;
- if (value->type == MATECONF_VALUE_BOOL)
- {
- gboolean enabled;
-
- enabled = mateconf_value_get_bool (value);
- _gs_prefs_set_lock_enabled (prefs, enabled);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ enabled = g_settings_get_boolean (settings, key);
+ _gs_prefs_set_lock_enabled (prefs, enabled);
}
else if (strcmp (key, KEY_LOCK_DISABLE) == 0)
{
+ gboolean disabled;
- if (value->type == MATECONF_VALUE_BOOL)
- {
- gboolean disabled;
-
- disabled = mateconf_value_get_bool (value);
- _gs_prefs_set_lock_disabled (prefs, disabled);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ disabled = g_settings_get_boolean (settings, key);
+ _gs_prefs_set_lock_disabled (prefs, disabled);
}
else if (strcmp (key, KEY_USER_SWITCH_DISABLE) == 0)
{
+ gboolean disabled;
- if (value->type == MATECONF_VALUE_BOOL)
- {
- gboolean disabled;
-
- disabled = mateconf_value_get_bool (value);
- _gs_prefs_set_user_switch_disabled (prefs, disabled);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ disabled = g_settings_get_boolean (settings, key);
+ _gs_prefs_set_user_switch_disabled (prefs, disabled);
}
else if (strcmp (key, KEY_CYCLE_DELAY) == 0)
{
+ int delay;
- if (value->type == MATECONF_VALUE_INT)
- {
- int delay;
-
- delay = mateconf_value_get_int (value);
- _gs_prefs_set_cycle_timeout (prefs, delay);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ delay = g_settings_get_int (settings, key);
+ _gs_prefs_set_cycle_timeout (prefs, delay);
}
else if (strcmp (key, KEY_KEYBOARD_ENABLED) == 0)
{
+ gboolean enabled;
- if (value->type == MATECONF_VALUE_BOOL)
- {
- gboolean enabled;
-
- enabled = mateconf_value_get_bool (value);
- _gs_prefs_set_keyboard_enabled (prefs, enabled);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ enabled = g_settings_get_boolean (settings, key);
+ _gs_prefs_set_keyboard_enabled (prefs, enabled);
}
else if (strcmp (key, KEY_KEYBOARD_COMMAND) == 0)
{
+ const char *command;
- if (value->type == MATECONF_VALUE_STRING)
- {
- const char *command;
-
- command = mateconf_value_get_string (value);
- _gs_prefs_set_keyboard_command (prefs, command);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ command = g_settings_get_string (settings, key);
+ _gs_prefs_set_keyboard_command (prefs, command);
}
else if (strcmp (key, KEY_STATUS_MESSAGE_ENABLED) == 0)
{
+ gboolean enabled;
- if (value->type == MATECONF_VALUE_BOOL)
- {
- gboolean enabled;
-
- enabled = mateconf_value_get_bool (value);
- _gs_prefs_set_status_message_enabled (prefs, enabled);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ enabled = g_settings_get_boolean (settings, key);
+ _gs_prefs_set_status_message_enabled (prefs, enabled);
}
else if (strcmp (key, KEY_LOGOUT_ENABLED) == 0)
{
+ gboolean enabled;
- if (value->type == MATECONF_VALUE_BOOL)
- {
- gboolean enabled;
-
- enabled = mateconf_value_get_bool (value);
- _gs_prefs_set_logout_enabled (prefs, enabled);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ enabled = g_settings_get_boolean (settings, key);
+ _gs_prefs_set_logout_enabled (prefs, enabled);
}
else if (strcmp (key, KEY_LOGOUT_DELAY) == 0)
{
+ int delay;
- if (value->type == MATECONF_VALUE_INT)
- {
- int delay;
-
- delay = mateconf_value_get_int (value);
- _gs_prefs_set_logout_timeout (prefs, delay);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ delay = g_settings_get_int (settings, key);
+ _gs_prefs_set_logout_timeout (prefs, delay);
}
else if (strcmp (key, KEY_LOGOUT_COMMAND) == 0)
{
+ const char *command;
- if (value->type == MATECONF_VALUE_STRING)
- {
- const char *command;
-
- command = mateconf_value_get_string (value);
- _gs_prefs_set_logout_command (prefs, command);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ command = g_settings_get_string (settings, key);
+ _gs_prefs_set_logout_command (prefs, command);
}
else if (strcmp (key, KEY_USER_SWITCH_ENABLED) == 0)
{
+ gboolean enabled;
- if (value->type == MATECONF_VALUE_BOOL)
- {
- gboolean enabled;
-
- enabled = mateconf_value_get_bool (value);
- _gs_prefs_set_user_switch_enabled (prefs, enabled);
-
- changed = TRUE;
- }
- else
- {
- invalid_type_warning (key);
- }
+ enabled = g_settings_get_boolean (settings, key);
+ _gs_prefs_set_user_switch_enabled (prefs, enabled);
}
else
@@ -901,10 +533,7 @@ key_changed_cb (MateConfClient *client,
g_warning ("Config key not handled: %s", key);
}
- if (changed && prefs)
- {
- g_signal_emit (prefs, signals [CHANGED], 0);
- }
+ g_signal_emit (prefs, signals [CHANGED], 0);
}
static void
@@ -912,8 +541,16 @@ gs_prefs_init (GSPrefs *prefs)
{
prefs->priv = GS_PREFS_GET_PRIVATE (prefs);
- prefs->priv->mateconf_client = mateconf_client_get_default ();
-
+ prefs->priv->settings = g_settings_new (GSETTINGS_SCHEMA);
+ g_signal_connect (prefs->priv->settings,
+ "changed",
+ G_CALLBACK (key_changed_cb),
+ prefs);
+ prefs->priv->lockdown = g_settings_new (LOCKDOWN_SETTINGS_SCHEMA);
+ g_signal_connect (prefs->priv->lockdown,
+ "changed",
+ G_CALLBACK (key_changed_cb),
+ prefs);
prefs->idle_activation_enabled = TRUE;
prefs->lock_enabled = TRUE;
prefs->lock_disabled = FALSE;
@@ -928,30 +565,7 @@ gs_prefs_init (GSPrefs *prefs)
prefs->mode = GS_MODE_SINGLE;
- /* MateConf setup */
- mateconf_client_add_dir (prefs->priv->mateconf_client,
- KEY_DIR,
- MATECONF_CLIENT_PRELOAD_NONE, NULL);
- mateconf_client_add_dir (prefs->priv->mateconf_client,
- MATE_LOCKDOWN_DIR,
- MATECONF_CLIENT_PRELOAD_NONE, NULL);
- mateconf_client_add_dir (prefs->priv->mateconf_client,
- MATE_SESSION_DIR,
- MATECONF_CLIENT_PRELOAD_NONE, NULL);
-
-
- mateconf_client_notify_add (prefs->priv->mateconf_client,
- KEY_DIR,
- (MateConfClientNotifyFunc)key_changed_cb,
- prefs,
- NULL, NULL);
- mateconf_client_notify_add (prefs->priv->mateconf_client,
- MATE_LOCKDOWN_DIR,
- (MateConfClientNotifyFunc)key_changed_cb,
- prefs,
- NULL, NULL);
-
- gs_prefs_load_from_mateconf (prefs);
+ gs_prefs_load_from_settings (prefs);
}
static void
@@ -966,12 +580,17 @@ gs_prefs_finalize (GObject *object)
g_return_if_fail (prefs->priv != NULL);
- if (prefs->priv->mateconf_client)
+ if (prefs->priv->settings)
{
- g_object_unref (prefs->priv->mateconf_client);
- prefs->priv->mateconf_client = NULL;
+ g_object_unref (prefs->priv->settings);
+ prefs->priv->settings = NULL;
}
+ if (prefs->priv->lockdown) {
+ g_object_unref (prefs->priv->lockdown);
+ prefs->priv->lockdown = NULL;
+ }
+
if (prefs->themes)
{
g_slist_foreach (prefs->themes, (GFunc)g_free, NULL);
diff --git a/src/mate-screensaver-preferences.c b/src/mate-screensaver-preferences.c
index 5bcf5e5..546e028 100644
--- a/src/mate-screensaver-preferences.c
+++ b/src/mate-screensaver-preferences.c
@@ -33,7 +33,6 @@
#include <glib/gi18n.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-#include <mateconf/mateconf-client.h>
#include <gio/gio.h>
@@ -45,18 +44,17 @@
#define GTK_BUILDER_FILE "mate-screensaver-preferences.ui"
-#define MATE_LOCKDOWN_DIR "/desktop/mate/lockdown"
-#define KEY_LOCK_DISABLE MATE_LOCKDOWN_DIR "/disable_lock_screen"
+#define LOCKDOWN_SETTINGS_SCHEMA "org.mate.desktop.lockdown"
+#define KEY_LOCK_DISABLE "disable-lock-screen"
-#define KEY_DIR "/apps/mate-screensaver"
-#define MATE_SESSION_DIR "/desktop/mate/session"
-#define KEY_LOCK KEY_DIR "/lock_enabled"
-#define KEY_IDLE_ACTIVATION_ENABLED KEY_DIR "/idle_activation_enabled"
-#define KEY_MODE KEY_DIR "/mode"
-#define KEY_ACTIVATE_DELAY MATE_SESSION_DIR "/idle_delay"
-#define KEY_LOCK_DELAY KEY_DIR "/lock_delay"
-#define KEY_CYCLE_DELAY KEY_DIR "/cycle_delay"
-#define KEY_THEMES KEY_DIR "/themes"
+#define GSETTINGS_SCHEMA "org.mate.screensaver"
+#define KEY_LOCK "lock-enabled"
+#define KEY_IDLE_ACTIVATION_ENABLED "idle-activation-enabled"
+#define KEY_MODE "mode"
+#define KEY_ACTIVATE_DELAY "idle-delay"
+#define KEY_LOCK_DELAY "lock-delay"
+#define KEY_CYCLE_DELAY "cycle-delay"
+#define KEY_THEMES "themes"
#define GPM_COMMAND "mate-power-preferences"
@@ -67,14 +65,6 @@ enum
N_COLUMNS
};
-static MateConfEnumStringPair mode_enum_map [] =
-{
- { GS_MODE_BLANK_ONLY, "blank-only" },
- { GS_MODE_RANDOM, "random" },
- { GS_MODE_SINGLE, "single" },
- { 0, NULL }
-};
-
/* Drag and drop info */
enum
{
@@ -95,26 +85,25 @@ static GSJob *job = NULL;
static gint32
config_get_activate_delay (gboolean *is_writable)
{
- MateConfClient *client;
+ GSettings *settings;
gint32 delay;
- client = mateconf_client_get_default ();
+ settings = g_settings_new (GSETTINGS_SCHEMA);
if (is_writable)
{
- *is_writable = mateconf_client_key_is_writable (client,
- KEY_ACTIVATE_DELAY,
- NULL);
+ *is_writable = g_settings_is_writable (settings,
+ KEY_ACTIVATE_DELAY);
}
- delay = mateconf_client_get_int (client, KEY_ACTIVATE_DELAY, NULL);
+ delay = g_settings_get_int (settings, KEY_ACTIVATE_DELAY);
if (delay < 1)
{
delay = 1;
}
- g_object_unref (client);
+ g_object_unref (settings);
return delay;
}
@@ -122,43 +111,32 @@ config_get_activate_delay (gboolean *is_writable)
static void
config_set_activate_delay (gint32 timeout)
{
- MateConfClient *client;
+ GSettings *settings;
- client = mateconf_client_get_default ();
+ settings = g_settings_new (GSETTINGS_SCHEMA);
- mateconf_client_set_int (client, KEY_ACTIVATE_DELAY, timeout, NULL);
+ g_settings_set_int (settings, KEY_ACTIVATE_DELAY, timeout);
- g_object_unref (client);
+ g_object_unref (settings);
}
static int
config_get_mode (gboolean *is_writable)
{
- MateConfClient *client;
+ GSettings *settings;
int mode;
- char *string;
- client = mateconf_client_get_default ();
+ settings = g_settings_new (GSETTINGS_SCHEMA);
if (is_writable)
{
- *is_writable = mateconf_client_key_is_writable (client,
- KEY_MODE,
- NULL);
+ *is_writable = g_settings_is_writable (settings,
+ KEY_MODE);
}
- string = mateconf_client_get_string (client, KEY_MODE, NULL);
- if (string)
- {
- mateconf_string_to_enum (mode_enum_map, string, &mode);
- g_free (string);
- }
- else
- {
- mode = GS_MODE_BLANK_ONLY;
- }
+ mode = g_settings_get_enum (settings, KEY_MODE);
- g_object_unref (client);
+ g_object_unref (settings);
return mode;
}
@@ -166,37 +144,33 @@ config_get_mode (gboolean *is_writable)
static void
config_set_mode (int mode)
{
- MateConfClient *client;
- const char *mode_string;
+ GSettings *settings;
- client = mateconf_client_get_default ();
+ settings = g_settings_new (GSETTINGS_SCHEMA);
- mode_string = mateconf_enum_to_string (mode_enum_map, mode);
- mateconf_client_set_string (client, KEY_MODE, mode_string, NULL);
+ g_settings_set_enum (settings, KEY_MODE, mode);
- g_object_unref (client);
+ g_object_unref (settings);
}
static char *
config_get_theme (gboolean *is_writable)
{
- MateConfClient *client;
+ GSettings *settings;
char *name;
int mode;
- client = mateconf_client_get_default ();
+ settings = g_settings_new (GSETTINGS_SCHEMA);
if (is_writable)
{
gboolean can_write_theme;
gboolean can_write_mode;
- can_write_theme = mateconf_client_key_is_writable (client,
- KEY_THEMES,
- NULL);
- can_write_mode = mateconf_client_key_is_writable (client,
- KEY_MODE,
- NULL);
+ can_write_theme = g_settings_is_writable (settings,
+ KEY_THEMES);
+ can_write_mode = g_settings_is_writable (settings,
+ KEY_MODE);
*is_writable = can_write_theme && can_write_mode;
}
@@ -213,14 +187,11 @@ config_get_theme (gboolean *is_writable)
}
else
{
- GSList *list;
- list = mateconf_client_get_list (client,
- KEY_THEMES,
- MATECONF_VALUE_STRING,
- NULL);
- if (list != NULL)
- {
- name = g_strdup (list->data);
+ gchar **strv;
+ strv = g_settings_get_strv (settings,
+ KEY_THEMES);
+ if (strv != NULL) {
+ name = g_strdup (strv[0]);
}
else
{
@@ -229,28 +200,29 @@ config_get_theme (gboolean *is_writable)
name = g_strdup ("__blank-only");
}
- g_slist_foreach (list, (GFunc)g_free, NULL);
- g_slist_free (list);
+ g_strfreev (strv);
}
- g_object_unref (client);
+ g_object_unref (settings);
return name;
}
-static GSList *
+static gchar **
get_all_theme_ids (GSThemeManager *theme_manager)
{
- GSList *ids = NULL;
+ gchar **ids = NULL;
GSList *entries;
GSList *l;
+ guint idx = 0;
entries = gs_theme_manager_get_info_list (theme_manager);
+ ids = g_new0 (gchar *, g_slist_length (entries) + 1);
for (l = entries; l; l = l->next)
{
GSThemeInfo *info = l->data;
- ids = g_slist_prepend (ids, g_strdup (gs_theme_info_get_id (info)));
+ ids[idx++] = g_strdup (gs_theme_info_get_id (info));
gs_theme_info_unref (info);
}
g_slist_free (entries);
@@ -261,11 +233,11 @@ get_all_theme_ids (GSThemeManager *theme_manager)
static void
config_set_theme (const char *theme_id)
{
- MateConfClient *client;
- GSList *list = NULL;
+ GSettings *settings;
+ gchar **strv = NULL;
int mode;
- client = mateconf_client_get_default ();
+ settings = g_settings_new (GSETTINGS_SCHEMA);
if (theme_id && strcmp (theme_id, "__blank-only") == 0)
{
@@ -276,46 +248,42 @@ config_set_theme (const char *theme_id)
mode = GS_MODE_RANDOM;
/* set the themes key to contain all available screensavers */
- list = get_all_theme_ids (theme_manager);
+ strv = get_all_theme_ids (theme_manager);
}
else
{
mode = GS_MODE_SINGLE;
- list = g_slist_append (list, g_strdup (theme_id));
+ strv = g_strsplit (theme_id, "%%%", 1);
}
config_set_mode (mode);
- mateconf_client_set_list (client,
- KEY_THEMES,
- MATECONF_VALUE_STRING,
- list,
- NULL);
+ g_settings_set_strv (settings,
+ KEY_THEMES,
+ (const gchar * const*) strv);
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
+ g_strfreev (strv);
- g_object_unref (client);
+ g_object_unref (settings);
}
static gboolean
config_get_enabled (gboolean *is_writable)
{
int enabled;
- MateConfClient *client;
+ GSettings *settings;
- client = mateconf_client_get_default ();
+ settings = g_settings_new (GSETTINGS_SCHEMA);
if (is_writable)
{
- *is_writable = mateconf_client_key_is_writable (client,
- KEY_LOCK,
- NULL);
+ *is_writable = g_settings_is_writable (settings,
+ KEY_LOCK);
}
- enabled = mateconf_client_get_bool (client, KEY_IDLE_ACTIVATION_ENABLED, NULL);
+ enabled = g_settings_get_boolean (settings, KEY_IDLE_ACTIVATION_ENABLED);
- g_object_unref (client);
+ g_object_unref (settings);
return enabled;
}
@@ -323,33 +291,32 @@ config_get_enabled (gboolean *is_writable)
static void
config_set_enabled (gboolean enabled)
{
- MateConfClient *client;
+ GSettings *settings;
- client = mateconf_client_get_default ();
+ settings = g_settings_new (GSETTINGS_SCHEMA);
- mateconf_client_set_bool (client, KEY_IDLE_ACTIVATION_ENABLED, enabled, NULL);
+ g_settings_set_boolean (settings, KEY_IDLE_ACTIVATION_ENABLED, enabled);
- g_object_unref (client);
+ g_object_unref (settings);
}
static gboolean
config_get_lock (gboolean *is_writable)
{
- MateConfClient *client;
+ GSettings *settings;
gboolean lock;
- client = mateconf_client_get_default ();
+ settings = g_settings_new (GSETTINGS_SCHEMA);
if (is_writable)
{
- *is_writable = mateconf_client_key_is_writable (client,
- KEY_LOCK,
- NULL);
+ *is_writable = g_settings_is_writable (settings,
+ KEY_LOCK);
}
- lock = mateconf_client_get_bool (client, KEY_LOCK, NULL);
+ lock = g_settings_get_boolean (settings, KEY_LOCK);
- g_object_unref (client);
+ g_object_unref (settings);
return lock;
}
@@ -357,27 +324,27 @@ config_get_lock (gboolean *is_writable)
static gboolean
config_get_lock_disabled ()
{
- MateConfClient *client;
+ GSettings *settings;
gboolean lock;
- client = mateconf_client_get_default ();
+ settings = g_settings_new (LOCKDOWN_SETTINGS_SCHEMA);
- lock = mateconf_client_get_bool (client, KEY_LOCK_DISABLE, NULL);
+ lock = g_settings_get_boolean (settings, KEY_LOCK_DISABLE);
- g_object_unref (client);
+ g_object_unref (settings);
return lock;
}
static void
config_set_lock (gboolean lock)
{
- MateConfClient *client;
+ GSettings *settings;
- client = mateconf_client_get_default ();
+ settings = g_settings_new (GSETTINGS_SCHEMA);
- mateconf_client_set_bool (client, KEY_LOCK, lock, NULL);
+ g_settings_set_boolean (settings, KEY_LOCK, lock);
- g_object_unref (client);
+ g_object_unref (settings);
}
static void
@@ -438,20 +405,16 @@ preview_set_theme (GtkWidget *widget,
}
else if (theme && strcmp (theme, "__random") == 0)
{
- GSList *themes;
+ gchar **themes;
themes = get_all_theme_ids (theme_manager);
if (themes != NULL)
{
- GSList *l;
gint32 i;
- i = g_random_int_range (0, g_slist_length (themes));
- l = g_slist_nth (themes, i);
-
- job_set_theme (job, (const char *) l->data);
- g_slist_foreach (themes, (GFunc) g_free, NULL);
- g_slist_free (themes);
+ i = g_random_int_range (0, g_strv_length (themes));
+ job_set_theme (job, themes[i]);
+ g_strfreev (themes);
gs_job_start (job);
}
@@ -1134,13 +1097,6 @@ enabled_checkbox_toggled (GtkToggleButton *button, gpointer user_data)
}
static void
-invalid_type_warning (const char *type)
-{
- g_warning ("Error retrieving configuration key '%s': Invalid type",
- type);
-}
-
-static void
ui_disable_lock (gboolean disable)
{
GtkWidget *widget;
@@ -1206,96 +1162,45 @@ ui_set_delay (int delay)
}
static void
-key_changed_cb (MateConfClient *client,
- guint cnxn_id,
- MateConfEntry *entry,
- gpointer data)
+key_changed_cb (GSettings *settings, const gchar *key, gpointer data)
{
- const char *key;
- MateConfValue *value;
-
- key = mateconf_entry_get_key (entry);
-
- if (! g_str_has_prefix (key, KEY_DIR) && ! g_str_has_prefix (key, MATE_LOCKDOWN_DIR))
- {
- return;
- }
-
- value = mateconf_entry_get_value (entry);
-
if (strcmp (key, KEY_IDLE_ACTIVATION_ENABLED) == 0)
{
- if (value->type == MATECONF_VALUE_BOOL)
- {
gboolean enabled;
- enabled = mateconf_value_get_bool (value);
+ enabled = g_settings_get_boolean (settings, key);
ui_set_enabled (enabled);
- }
- else
- {
- invalid_type_warning (key);
- }
}
else if (strcmp (key, KEY_LOCK) == 0)
{
- if (value->type == MATECONF_VALUE_BOOL)
- {
- gboolean enabled;
+ gboolean enabled;
- enabled = mateconf_value_get_bool (value);
+ enabled = g_settings_get_boolean (settings, key);
ui_set_lock (enabled);
- }
- else
- {
- invalid_type_warning (key);
- }
}
else if (strcmp (key, KEY_LOCK_DISABLE) == 0)
{
- if (value->type == MATECONF_VALUE_BOOL)
- {
- gboolean disabled;
+ gboolean disabled;
- disabled = mateconf_value_get_bool (value);
+ disabled = g_settings_get_boolean (settings, key);
ui_disable_lock (disabled);
- }
- else
- {
- invalid_type_warning (key);
- }
}
else if (strcmp (key, KEY_THEMES) == 0)
{
- if (value->type == MATECONF_VALUE_LIST)
- {
- GtkWidget *treeview;
+ GtkWidget *treeview;
treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
setup_treeview_selection (treeview);
- }
- else
- {
- invalid_type_warning (key);
- }
}
else if (strcmp (key, KEY_ACTIVATE_DELAY) == 0)
{
-
- if (value->type == MATECONF_VALUE_INT)
- {
int delay;
- delay = mateconf_value_get_int (value);
- ui_set_delay (delay);
- }
- else
- {
- invalid_type_warning (key);
- }
+ delay = g_settings_get_int (settings, key);
+ ui_set_delay (delay);
}
else
@@ -1578,12 +1483,12 @@ init_capplet (void)
GtkWidget *fullscreen_preview_area;
GtkWidget *fullscreen_preview_close;
char *gtk_builder_file;
- char *string;
gdouble activate_delay;
gboolean enabled;
gboolean is_writable;
- MateConfClient *client;
+ GSettings *settings;
GError *error=NULL;
+ gint mode;
gtk_builder_file = g_build_filename (GTKBUILDERDIR, GTK_BUILDER_FILE, NULL);
builder = gtk_builder_new();
@@ -1687,42 +1592,21 @@ init_capplet (void)
gtk_widget_show_all (dialog);
/* Update list of themes if using random screensaver */
- client = mateconf_client_get_default ();
- string = mateconf_client_get_string (client, KEY_MODE, NULL);
- if (string != NULL)
- {
- int mode;
- GSList *list;
-
- mateconf_string_to_enum (mode_enum_map, string, &mode);
- g_free (string);
-
- if (mode == GS_MODE_RANDOM)
- {
- list = get_all_theme_ids (theme_manager);
- mateconf_client_set_list (client, KEY_THEMES, MATECONF_VALUE_STRING, list, NULL);
-
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
- }
- }
-
- mateconf_client_add_dir (client, KEY_DIR,
- MATECONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
- mateconf_client_notify_add (client,
- KEY_DIR,
- key_changed_cb,
- NULL, NULL, NULL);
- mateconf_client_add_dir (client, MATE_LOCKDOWN_DIR,
- MATECONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
- mateconf_client_notify_add (client,
- MATE_LOCKDOWN_DIR,
- key_changed_cb,
- NULL, NULL, NULL);
-
- g_object_unref (client);
+ settings = g_settings_new (GSETTINGS_SCHEMA);
+ mode = g_settings_get_enum (settings, KEY_MODE);
+ if (mode == GS_MODE_RANDOM) {
+ gchar **list;
+ list = get_all_theme_ids (theme_manager);
+ g_settings_set_strv (settings, KEY_THEMES, (const gchar * const*) list);
+ g_strfreev (list);
+ }
+
+ g_signal_connect (settings,
+ "changed",
+ G_CALLBACK (key_changed_cb),
+ NULL);
+
+ g_object_unref (settings);
preview_clear (preview);
gs_job_set_widget (job, preview);