[gnome-screensaver] Port GNOME Screensaver to GSettings
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-screensaver] Port GNOME Screensaver to GSettings
- Date: Thu, 2 Dec 2010 11:57:06 +0000 (UTC)
commit b79cfa1292dd24e66796d1bfc4684c3c363c2448
Author: Richard Hughes <richard hughsie com>
Date: Thu Dec 2 11:33:10 2010 +0000
Port GNOME Screensaver to GSettings
Note: this is a minimal port, as the preferences capplet is moving to
gnome-control-center and being made much simpler.
configure.ac | 9 +-
data/.gitignore | 4 +-
data/Makefile.am | 30 +-
data/gnome-screensaver.schemas.in | 243 ------------
data/org.gnome.screensaver.gschema.migrate | 16 +
data/org.gnome.screensaver.gschema.xml.in.in | 84 ++++
po/POTFILES.in | 2 +-
src/gnome-screensaver-preferences.c | 307 +++++----------
src/gs-lock-plug.c | 1 -
src/gs-prefs.c | 545 +++++++-------------------
10 files changed, 368 insertions(+), 873 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0b9cac5..5009fe4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,12 +34,12 @@ AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Name of default gettext domain])
AM_GLIB_GNU_GETTEXT
+GLIB_GSETTINGS
# Dependencies
DBUS_REQUIRED_VERSION=0.30
GLIB_REQUIRED_VERSION=2.15.0
-GCONF_REQUIRED_VERSION=2.6.1
GDK_REQUIRED_VERSION=2.90.7
GTK_REQUIRED_VERSION=2.90.7
X11_REQUIRED_VERSION=1.0
@@ -60,14 +60,12 @@ PKG_CHECK_MODULES(GNOME_SCREENSAVER,
x11 >= $X11_REQUIRED_VERSION
gtk+-3.0 >= $GTK_REQUIRED_VERSION
dbus-glib-1 >= $DBUS_REQUIRED_VERSION
- gconf-2.0 >= $GCONF_REQUIRED_VERSION
gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION
libgnome-menu >= $LIBGNOME_MENU_REQUIRED_VERSION)
AC_SUBST(GNOME_SCREENSAVER_CFLAGS)
AC_SUBST(GNOME_SCREENSAVER_LIBS)
PKG_CHECK_MODULES(GNOME_SCREENSAVER_DIALOG,
- gconf-2.0 >= $GCONF_REQUIRED_VERSION
gthread-2.0
gtk+-3.0 >= $GTK_REQUIRED_VERSION)
AC_SUBST(GNOME_SCREENSAVER_DIALOG_CFLAGS)
@@ -75,7 +73,6 @@ AC_SUBST(GNOME_SCREENSAVER_DIALOG_LIBS)
PKG_CHECK_MODULES(GNOME_SCREENSAVER_CAPPLET,
gio-2.0 >= $GLIB_REQUIRED_VERSION
- gconf-2.0 >= $GCONF_REQUIRED_VERSION
gtk+-3.0 >= $GTK_REQUIRED_VERSION
libgnome-menu >= $LIBGNOME_MENU_REQUIRED_VERSION)
AC_SUBST(GNOME_SCREENSAVER_CAPPLET_CFLAGS)
@@ -93,9 +90,6 @@ 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(GCONFTOOL, gconftool-2)
-
-AM_GCONF_SOURCE_2
GNOME_COMPILE_WARNINGS(yes)
@@ -803,6 +797,7 @@ data/Makefile
data/gnome-screensavers.menu
data/gnome-screensaver.pc
data/org.gnome.ScreenSaver.service
+data/org.gnome.screensaver.gschema.xml.in
data/images/Makefile
data/images/cosmos/Makefile
savers/Makefile
diff --git a/data/.gitignore b/data/.gitignore
index a1eb70d..8343454 100644
--- a/data/.gitignore
+++ b/data/.gitignore
@@ -1,8 +1,10 @@
Makefile
Makefile.in
*.desktop
-*.schemas
+*.valid
*.gladep
*.menu
*.directory
*.pc
+org.gnome.screensaver.gschema.xml
+org.gnome.screensaver.gschema.xml.in
diff --git a/data/Makefile.am b/data/Makefile.am
index 053d845..472dbe2 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -9,11 +9,14 @@ man_MANS = \
gnome-screensaver-preferences.1 \
$(NULL)
- INTLTOOL_SCHEMAS_RULE@
+ GSETTINGS_RULES@
-schemasdir = @GCONF_SCHEMA_FILE_DIR@
-schemas_in_files = gnome-screensaver.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
+ INTLTOOL_XML_NOMERGE_RULE@
+
+gsettings_SCHEMAS = org.gnome.screensaver.gschema.xml
+
+migrationdir = $(datadir)/GConf/gsettings
+dist_migration_DATA = org.gnome.screensaver.gschema.migrate
@INTLTOOL_DESKTOP_RULE@
@@ -46,7 +49,7 @@ dbussessionservicedir = $(DBUS_SESSION_SERVICE_DIR)
dbussessionservice_DATA = org.gnome.ScreenSaver.service
EXTRA_DIST = \
- $(schemas_in_files) \
+ $(gsettings_SCHEMAS:.xml=.xml.in.in) \
$(desktop_in_files) \
$(directory_in_files) \
$(gtkbuilder_DATA) \
@@ -59,26 +62,15 @@ EXTRA_DIST = \
$(NULL)
DISTCLEANFILES = \
- $(schemas_DATA) \
+ $(gsettings_SCHEMAS) \
$(desktop_DATA) \
$(directory_DATA) \
$(NULL)
MAINTAINERCLEANFILES = \
*~ \
- Makefile.in
-
-if GCONF_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 \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --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.gnome.screensaver.gschema.migrate b/data/org.gnome.screensaver.gschema.migrate
new file mode 100644
index 0000000..b4371fa
--- /dev/null
+++ b/data/org.gnome.screensaver.gschema.migrate
@@ -0,0 +1,16 @@
+[org.gnome.screensaver]
+idle-activation-enabled = /apps/gnome-screensaver/idle_activation_enabled
+lock-enabled = /apps/gnome-screensaver/lock_enabled
+mode = /apps/gnome-screensaver/mode
+themes = /apps/gnome-screensaver/themes
+idle-delay = /apps/gnome-screensaver/idle_delay
+power-management-delay = /apps/gnome-screensaver/power_management_delay
+cycle-delay = /apps/gnome-screensaver/cycle_delay
+lock-delay = /apps/gnome-screensaver/lock_delay
+embedded-keyboard-enabled = /apps/gnome-screensaver/embedded_keyboard_enabled
+embedded-keyboard-command = /apps/gnome-screensaver/embedded_keyboard_command
+logout-enabled = /apps/gnome-screensaver/logout_enabled
+logout-delay = /apps/gnome-screensaver/logout_delay
+logout-command = /apps/gnome-screensaver/logout_command
+user-switch-enabled = /apps/gnome-screensaver/user_switch_enabled
+status-message-enabled = /apps/gnome-screensaver/status_message_enabled
diff --git a/data/org.gnome.screensaver.gschema.xml.in.in b/data/org.gnome.screensaver.gschema.xml.in.in
new file mode 100644
index 0000000..6763898
--- /dev/null
+++ b/data/org.gnome.screensaver.gschema.xml.in.in
@@ -0,0 +1,84 @@
+<schemalist>
+ <enum id="org.gnome.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.gnome.screensaver" path="/apps/gnome-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.gnome.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 4946beb..de2c781 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,8 +3,8 @@
data/gnome-screensaver-preferences.desktop.in
[type: gettext/glade]data/gnome-screensaver-preferences.ui
data/gnome-screensaver.directory.in
-data/gnome-screensaver.schemas.in
data/images/cosmos/cosmos.xml.in.in
+data/org.gnome.screensaver.gschema.xml.in.in
savers/cosmos-slideshow.desktop.in.in
savers/footlogo-floaters.desktop.in.in
savers/personal-slideshow.desktop.in.in
diff --git a/src/gnome-screensaver-preferences.c b/src/gnome-screensaver-preferences.c
index 0d19f90..5eaa7b8 100644
--- a/src/gnome-screensaver-preferences.c
+++ b/src/gnome-screensaver-preferences.c
@@ -33,7 +33,6 @@
#include <glib/gi18n.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
#include <gio/gio.h>
@@ -45,18 +44,17 @@
#define GTK_BUILDER_FILE "gnome-screensaver-preferences.ui"
-#define GNOME_LOCKDOWN_DIR "/desktop/gnome/lockdown"
-#define KEY_LOCK_DISABLE GNOME_LOCKDOWN_DIR "/disable_lock_screen"
+#define LOCKDOWN_SETTINGS_SCHEMA "org.gnome.desktop.lockdown"
+#define KEY_LOCK_DISABLE "disable-lock-screen"
-#define KEY_DIR "/apps/gnome-screensaver"
-#define GNOME_SESSION_DIR "/desktop/gnome/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 GNOME_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 GS_SETTINGS_SCHEMA "org.gnome.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 "gnome-power-preferences"
@@ -66,13 +64,6 @@ enum {
N_COLUMNS
};
-static GConfEnumStringPair mode_enum_map [] = {
- { GS_MODE_BLANK_ONLY, "blank-only" },
- { GS_MODE_RANDOM, "random" },
- { GS_MODE_SINGLE, "single" },
- { 0, NULL }
-};
-
/* Drag and drop info */
enum {
TARGET_URI_LIST,
@@ -92,18 +83,17 @@ static GSJob *job = NULL;
static gint32
config_get_activate_delay (gboolean *is_writable)
{
- GConfClient *client;
+ GSettings *client;
gint32 delay;
- client = gconf_client_get_default ();
+ client = g_settings_new (GS_SETTINGS_SCHEMA);
if (is_writable) {
- *is_writable = gconf_client_key_is_writable (client,
- KEY_ACTIVATE_DELAY,
- NULL);
+ *is_writable = g_settings_is_writable (client,
+ KEY_ACTIVATE_DELAY);
}
- delay = gconf_client_get_int (client, KEY_ACTIVATE_DELAY, NULL);
+ delay = g_settings_get_int (client, KEY_ACTIVATE_DELAY);
if (delay < 1) {
delay = 1;
@@ -117,11 +107,11 @@ config_get_activate_delay (gboolean *is_writable)
static void
config_set_activate_delay (gint32 timeout)
{
- GConfClient *client;
+ GSettings *client;
- client = gconf_client_get_default ();
+ client = g_settings_new (GS_SETTINGS_SCHEMA);
- gconf_client_set_int (client, KEY_ACTIVATE_DELAY, timeout, NULL);
+ g_settings_set_int (client, KEY_ACTIVATE_DELAY, timeout);
g_object_unref (client);
}
@@ -129,25 +119,17 @@ config_set_activate_delay (gint32 timeout)
static int
config_get_mode (gboolean *is_writable)
{
- GConfClient *client;
+ GSettings *client;
int mode;
- char *string;
- client = gconf_client_get_default ();
+ client = g_settings_new (GS_SETTINGS_SCHEMA);
if (is_writable) {
- *is_writable = gconf_client_key_is_writable (client,
- KEY_MODE,
- NULL);
+ *is_writable = g_settings_is_writable (client,
+ KEY_MODE);
}
- string = gconf_client_get_string (client, KEY_MODE, NULL);
- if (string) {
- gconf_string_to_enum (mode_enum_map, string, &mode);
- g_free (string);
- } else {
- mode = GS_MODE_BLANK_ONLY;
- }
+ mode = g_settings_get_enum (client, KEY_MODE);
g_object_unref (client);
@@ -157,13 +139,11 @@ config_get_mode (gboolean *is_writable)
static void
config_set_mode (int mode)
{
- GConfClient *client;
- const char *mode_string;
+ GSettings *client;
- client = gconf_client_get_default ();
+ client = g_settings_new (GS_SETTINGS_SCHEMA);
- mode_string = gconf_enum_to_string (mode_enum_map, mode);
- gconf_client_set_string (client, KEY_MODE, mode_string, NULL);
+ g_settings_set_enum (client, KEY_MODE, mode);
g_object_unref (client);
}
@@ -171,22 +151,20 @@ config_set_mode (int mode)
static char *
config_get_theme (gboolean *is_writable)
{
- GConfClient *client;
+ GSettings *client;
char *name;
int mode;
- client = gconf_client_get_default ();
+ client = g_settings_new (GS_SETTINGS_SCHEMA);
if (is_writable) {
gboolean can_write_theme;
gboolean can_write_mode;
- can_write_theme = gconf_client_key_is_writable (client,
- KEY_THEMES,
- NULL);
- can_write_mode = gconf_client_key_is_writable (client,
- KEY_MODE,
- NULL);
+ can_write_theme = g_settings_is_writable (client,
+ KEY_THEMES);
+ can_write_mode = g_settings_is_writable (client,
+ KEY_MODE);
*is_writable = can_write_theme && can_write_mode;
}
@@ -198,21 +176,18 @@ config_get_theme (gboolean *is_writable)
} else if (mode == GS_MODE_RANDOM) {
name = g_strdup ("__random");
} else {
- GSList *list;
- list = gconf_client_get_list (client,
- KEY_THEMES,
- GCONF_VALUE_STRING,
- NULL);
- if (list != NULL) {
- name = g_strdup (list->data);
+ gchar **strv;
+ strv = g_settings_get_strv (client,
+ KEY_THEMES);
+ if (strv != NULL) {
+ name = g_strdup (strv[0]);
} else {
/* TODO: handle error */
/* default to blank */
name = g_strdup ("__blank-only");
}
- g_slist_foreach (list, (GFunc)g_free, NULL);
- g_slist_free (list);
+ g_strfreev (strv);
}
g_object_unref (client);
@@ -220,18 +195,19 @@ config_get_theme (gboolean *is_writable)
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);
@@ -242,11 +218,11 @@ get_all_theme_ids (GSThemeManager *theme_manager)
static void
config_set_theme (const char *theme_id)
{
- GConfClient *client;
- GSList *list = NULL;
+ GSettings *client;
+ gchar **strv = NULL;
int mode;
- client = gconf_client_get_default ();
+ client = g_settings_new (GS_SETTINGS_SCHEMA);
if (theme_id && strcmp (theme_id, "__blank-only") == 0) {
mode = GS_MODE_BLANK_ONLY;
@@ -254,22 +230,19 @@ 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);
- gconf_client_set_list (client,
- KEY_THEMES,
- GCONF_VALUE_STRING,
- list,
- NULL);
+ g_settings_set_strv (client,
+ 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);
}
@@ -278,17 +251,16 @@ static gboolean
config_get_enabled (gboolean *is_writable)
{
int enabled;
- GConfClient *client;
+ GSettings *client;
- client = gconf_client_get_default ();
+ client = g_settings_new (GS_SETTINGS_SCHEMA);
if (is_writable) {
- *is_writable = gconf_client_key_is_writable (client,
- KEY_LOCK,
- NULL);
+ *is_writable = g_settings_is_writable (client,
+ KEY_LOCK);
}
- enabled = gconf_client_get_bool (client, KEY_IDLE_ACTIVATION_ENABLED, NULL);
+ enabled = g_settings_get_boolean (client, KEY_IDLE_ACTIVATION_ENABLED);
g_object_unref (client);
@@ -298,11 +270,11 @@ config_get_enabled (gboolean *is_writable)
static void
config_set_enabled (gboolean enabled)
{
- GConfClient *client;
+ GSettings *client;
- client = gconf_client_get_default ();
+ client = g_settings_new (GS_SETTINGS_SCHEMA);
- gconf_client_set_bool (client, KEY_IDLE_ACTIVATION_ENABLED, enabled, NULL);
+ g_settings_set_boolean (client, KEY_IDLE_ACTIVATION_ENABLED, enabled);
g_object_unref (client);
}
@@ -310,18 +282,17 @@ config_set_enabled (gboolean enabled)
static gboolean
config_get_lock (gboolean *is_writable)
{
- GConfClient *client;
+ GSettings *client;
gboolean lock;
- client = gconf_client_get_default ();
+ client = g_settings_new (GS_SETTINGS_SCHEMA);
if (is_writable) {
- *is_writable = gconf_client_key_is_writable (client,
- KEY_LOCK,
- NULL);
+ *is_writable = g_settings_is_writable (client,
+ KEY_LOCK);
}
- lock = gconf_client_get_bool (client, KEY_LOCK, NULL);
+ lock = g_settings_get_boolean (client, KEY_LOCK);
g_object_unref (client);
@@ -331,12 +302,12 @@ config_get_lock (gboolean *is_writable)
static gboolean
config_get_lock_disabled ()
{
- GConfClient *client;
+ GSettings *client;
gboolean lock;
- client = gconf_client_get_default ();
+ client = g_settings_new (LOCKDOWN_SETTINGS_SCHEMA);
- lock = gconf_client_get_bool (client, KEY_LOCK_DISABLE, NULL);
+ lock = g_settings_get_boolean (client, KEY_LOCK_DISABLE);
g_object_unref (client);
return lock;
@@ -345,11 +316,11 @@ config_get_lock_disabled ()
static void
config_set_lock (gboolean lock)
{
- GConfClient *client;
+ GSettings *client;
- client = gconf_client_get_default ();
+ client = g_settings_new (GS_SETTINGS_SCHEMA);
- gconf_client_set_bool (client, KEY_LOCK, lock, NULL);
+ g_settings_set_boolean (client, KEY_LOCK, lock);
g_object_unref (client);
}
@@ -406,19 +377,15 @@ preview_set_theme (GtkWidget *widget,
if ((theme && strcmp (theme, "__blank-only") == 0)) {
} 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);
}
@@ -1040,13 +1007,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;
@@ -1108,71 +1068,39 @@ ui_set_delay (int delay)
}
static void
-key_changed_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
+key_changed_cb (GSettings *settings,
+ const gchar *key,
+ gpointer data)
{
- const char *key;
- GConfValue *value;
-
- key = gconf_entry_get_key (entry);
-
- if (! g_str_has_prefix (key, KEY_DIR) && ! g_str_has_prefix (key, GNOME_LOCKDOWN_DIR)) {
- return;
- }
-
- value = gconf_entry_get_value (entry);
-
if (strcmp (key, KEY_IDLE_ACTIVATION_ENABLED) == 0) {
- if (value->type == GCONF_VALUE_BOOL) {
- gboolean enabled;
+ gboolean enabled;
- enabled = gconf_value_get_bool (value);
+ enabled = g_settings_get_boolean (settings, key);
- ui_set_enabled (enabled);
- } else {
- invalid_type_warning (key);
- }
+ ui_set_enabled (enabled);
} else if (strcmp (key, KEY_LOCK) == 0) {
- if (value->type == GCONF_VALUE_BOOL) {
- gboolean enabled;
+ gboolean enabled;
- enabled = gconf_value_get_bool (value);
+ enabled = g_settings_get_boolean (settings, key);
- ui_set_lock (enabled);
- } else {
- invalid_type_warning (key);
- }
+ ui_set_lock (enabled);
} else if (strcmp (key, KEY_LOCK_DISABLE) == 0) {
- if (value->type == GCONF_VALUE_BOOL) {
- gboolean disabled;
+ gboolean disabled;
- disabled = gconf_value_get_bool (value);
+ disabled = g_settings_get_boolean (settings, key);
- ui_disable_lock (disabled);
- } else {
- invalid_type_warning (key);
- }
+ ui_disable_lock (disabled);
} else if (strcmp (key, KEY_THEMES) == 0) {
- if (value->type == GCONF_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);
- }
+ treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview"));
+ setup_treeview_selection (treeview);
} else if (strcmp (key, KEY_ACTIVATE_DELAY) == 0) {
- if (value->type == GCONF_VALUE_INT) {
- int delay;
+ int delay;
- delay = gconf_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 {
/*g_warning ("Config key not handled: %s", key);*/
@@ -1426,12 +1354,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;
- GConfClient *client;
+ GSettings *client;
GError *error=NULL;
+ gint mode;
gtk_builder_file = g_build_filename (GTKBUILDERDIR, GTK_BUILDER_FILE, NULL);
builder = gtk_builder_new();
@@ -1529,38 +1457,19 @@ init_capplet (void)
gtk_widget_show_all (dialog);
/* Update list of themes if using random screensaver */
- client = gconf_client_get_default ();
- string = gconf_client_get_string (client, KEY_MODE, NULL);
- if (string != NULL) {
- int mode;
- GSList *list;
-
- gconf_string_to_enum (mode_enum_map, string, &mode);
- g_free (string);
-
- if (mode == GS_MODE_RANDOM) {
- list = get_all_theme_ids (theme_manager);
- gconf_client_set_list (client, KEY_THEMES, GCONF_VALUE_STRING, list, NULL);
-
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
- }
- }
-
- gconf_client_add_dir (client, KEY_DIR,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
- gconf_client_notify_add (client,
- KEY_DIR,
- key_changed_cb,
- NULL, NULL, NULL);
- gconf_client_add_dir (client, GNOME_LOCKDOWN_DIR,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
- gconf_client_notify_add (client,
- GNOME_LOCKDOWN_DIR,
- key_changed_cb,
- NULL, NULL, NULL);
+ client = g_settings_new (GS_SETTINGS_SCHEMA);
+ mode = g_settings_get_enum (client, KEY_MODE);
+ if (mode == GS_MODE_RANDOM) {
+ gchar **list;
+ list = get_all_theme_ids (theme_manager);
+ g_settings_set_strv (client, KEY_THEMES, (const gchar * const*) list);
+ g_strfreev (list);
+ }
+
+ g_signal_connect (client,
+ "changed",
+ G_CALLBACK (key_changed_cb),
+ NULL);
g_object_unref (client);
diff --git a/src/gs-lock-plug.c b/src/gs-lock-plug.c
index 21033da..70f324e 100644
--- a/src/gs-lock-plug.c
+++ b/src/gs-lock-plug.c
@@ -36,7 +36,6 @@
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
#ifdef WITH_KBD_LAYOUT_INDICATOR
#include <libgnomekbd/gkbd-indicator.h>
diff --git a/src/gs-prefs.c b/src/gs-prefs.c
index dbb576f..f937606 100644
--- a/src/gs-prefs.c
+++ b/src/gs-prefs.c
@@ -26,7 +26,7 @@
#include <glib.h>
#include <glib-object.h>
-#include <gconf/gconf-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 GNOME_LOCKDOWN_DIR "/desktop/gnome/lockdown"
-#define KEY_LOCK_DISABLE GNOME_LOCKDOWN_DIR "/disable_lock_screen"
-#define KEY_USER_SWITCH_DISABLE GNOME_LOCKDOWN_DIR "/disable_user_switching"
-
-#define KEY_DIR "/apps/gnome-screensaver"
-#define GNOME_SESSION_DIR "/desktop/gnome/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 GNOME_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.gnome.desktop.lockdown"
+#define KEY_LOCK_DISABLE "disable-lock-screen"
+#define KEY_USER_SWITCH_DISABLE "disable-user-switching"
+
+#define GS_SETTINGS_SCHEMA "org.gnome.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
{
- GConfClient *gconf_client;
+ GSettings *settings;
+ GSettings *lockdown;
};
enum {
@@ -72,13 +72,6 @@ enum {
PROP_0
};
-static GConfEnumStringPair 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)
@@ -197,27 +190,26 @@ _gs_prefs_set_cycle_timeout (GSPrefs *prefs,
static void
_gs_prefs_set_mode (GSPrefs *prefs,
- const char *value)
+ gint mode)
{
- int mode;
-
- if (value && gconf_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);
g_slist_free (prefs->themes);
}
/* 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
@@ -320,445 +312,204 @@ _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_gconf (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 = gconf_client_get_bool (prefs->priv->gconf_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 = gconf_client_get_bool (prefs->priv->gconf_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 = gconf_client_get_bool (prefs->priv->gconf_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 = gconf_client_get_bool (prefs->priv->gconf_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 = gconf_client_get_int (prefs->priv->gconf_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 = gconf_client_get_int (prefs->priv->gconf_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 = gconf_client_get_int (prefs->priv->gconf_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 = gconf_client_get_int (prefs->priv->gconf_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 = gconf_client_get_string (prefs->priv->gconf_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 = gconf_client_get_list (prefs->priv->gconf_client,
- KEY_THEMES,
- GCONF_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 = gconf_client_get_bool (prefs->priv->gconf_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 = gconf_client_get_string (prefs->priv->gconf_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 = gconf_client_get_bool (prefs->priv->gconf_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 = gconf_client_get_bool (prefs->priv->gconf_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 = gconf_client_get_string (prefs->priv->gconf_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 = gconf_client_get_int (prefs->priv->gconf_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 = gconf_client_get_bool (prefs->priv->gconf_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 (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- GSPrefs *prefs)
+key_changed_cb (GSettings *settings,
+ const gchar *key,
+ GSPrefs *prefs)
{
- gboolean changed = FALSE;
- const char *key;
- GConfValue *value;
-
- key = gconf_entry_get_key (entry);
-
- if (! g_str_has_prefix (key, KEY_DIR) && ! g_str_has_prefix (key, GNOME_LOCKDOWN_DIR))
- return;
-
- value = gconf_entry_get_value (entry);
-
if (strcmp (key, KEY_MODE) == 0) {
- if (value->type == GCONF_VALUE_STRING) {
- const char *str;
-
- str = gconf_value_get_string (value);
- _gs_prefs_set_mode (prefs, str);
+ gint mode;
- 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 != GCONF_VALUE_LIST) {
- return;
- }
-
- list = gconf_value_get_list (value);
-
- if (list
- && gconf_value_get_list_type (value) == GCONF_VALUE_STRING) {
- GSList *l;
- GSList *new_list;
-
- changed = TRUE;
-
- new_list = NULL;
- for (l = list; l; l = l->next) {
- char *s;
-
- s = gconf_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) {
- if (value->type == GCONF_VALUE_INT) {
- int delay;
-
- delay = gconf_value_get_int (value);
- _gs_prefs_set_timeout (prefs, delay);
+ int 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) {
- if (value->type == GCONF_VALUE_INT) {
- int delay;
+ int delay;
- delay = gconf_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) {
- if (value->type == GCONF_VALUE_INT) {
- int delay;
-
- delay = gconf_value_get_int (value);
- _gs_prefs_set_lock_timeout (prefs, delay);
+ int 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) {
- if (value->type == GCONF_VALUE_BOOL) {
- gboolean enabled;
+ gboolean enabled;
- enabled = gconf_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) {
- if (value->type == GCONF_VALUE_BOOL) {
- gboolean enabled;
-
- enabled = gconf_value_get_bool (value);
- _gs_prefs_set_lock_enabled (prefs, enabled);
+ gboolean 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) {
- if (value->type == GCONF_VALUE_BOOL) {
- gboolean disabled;
-
- disabled = gconf_value_get_bool (value);
- _gs_prefs_set_lock_disabled (prefs, disabled);
+ gboolean 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) {
- if (value->type == GCONF_VALUE_BOOL) {
- gboolean disabled;
+ gboolean disabled;
- disabled = gconf_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) {
- if (value->type == GCONF_VALUE_INT) {
- int delay;
-
- delay = gconf_value_get_int (value);
- _gs_prefs_set_cycle_timeout (prefs, delay);
+ int 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) {
- if (value->type == GCONF_VALUE_BOOL) {
- gboolean enabled;
+ gboolean enabled;
- enabled = gconf_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) {
- if (value->type == GCONF_VALUE_STRING) {
- const char *command;
-
- command = gconf_value_get_string (value);
- _gs_prefs_set_keyboard_command (prefs, command);
+ const char *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) {
- if (value->type == GCONF_VALUE_BOOL) {
- gboolean enabled;
-
- enabled = gconf_value_get_bool (value);
- _gs_prefs_set_status_message_enabled (prefs, enabled);
+ gboolean 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) {
- if (value->type == GCONF_VALUE_BOOL) {
- gboolean enabled;
+ gboolean enabled;
- enabled = gconf_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) {
- if (value->type == GCONF_VALUE_INT) {
- int delay;
-
- delay = gconf_value_get_int (value);
- _gs_prefs_set_logout_timeout (prefs, delay);
+ int 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) {
- if (value->type == GCONF_VALUE_STRING) {
- const char *command;
+ const char *command;
- command = gconf_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) {
- if (value->type == GCONF_VALUE_BOOL) {
- gboolean enabled;
-
- enabled = gconf_value_get_bool (value);
- _gs_prefs_set_user_switch_enabled (prefs, enabled);
+ gboolean enabled;
- changed = TRUE;
- } else {
- invalid_type_warning (key);
- }
+ enabled = g_settings_get_boolean (settings, key);
+ _gs_prefs_set_user_switch_enabled (prefs, enabled);
} else {
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
@@ -766,7 +517,16 @@ gs_prefs_init (GSPrefs *prefs)
{
prefs->priv = GS_PREFS_GET_PRIVATE (prefs);
- prefs->priv->gconf_client = gconf_client_get_default ();
+ prefs->priv->settings = g_settings_new (GS_SETTINGS_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;
@@ -782,30 +542,7 @@ gs_prefs_init (GSPrefs *prefs)
prefs->mode = GS_MODE_SINGLE;
- /* GConf setup */
- gconf_client_add_dir (prefs->priv->gconf_client,
- KEY_DIR,
- GCONF_CLIENT_PRELOAD_NONE, NULL);
- gconf_client_add_dir (prefs->priv->gconf_client,
- GNOME_LOCKDOWN_DIR,
- GCONF_CLIENT_PRELOAD_NONE, NULL);
- gconf_client_add_dir (prefs->priv->gconf_client,
- GNOME_SESSION_DIR,
- GCONF_CLIENT_PRELOAD_NONE, NULL);
-
-
- gconf_client_notify_add (prefs->priv->gconf_client,
- KEY_DIR,
- (GConfClientNotifyFunc)key_changed_cb,
- prefs,
- NULL, NULL);
- gconf_client_notify_add (prefs->priv->gconf_client,
- GNOME_LOCKDOWN_DIR,
- (GConfClientNotifyFunc)key_changed_cb,
- prefs,
- NULL, NULL);
-
- gs_prefs_load_from_gconf (prefs);
+ gs_prefs_load_from_settings (prefs);
}
static void
@@ -820,9 +557,13 @@ gs_prefs_finalize (GObject *object)
g_return_if_fail (prefs->priv != NULL);
- if (prefs->priv->gconf_client) {
- g_object_unref (prefs->priv->gconf_client);
- prefs->priv->gconf_client = NULL;
+ if (prefs->priv->settings) {
+ 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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]