[gnome-settings-daemon] Migrate gnome-settings-daemon settings (/apps/gnome/gnome_settings_daemon) to GSettings
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] Migrate gnome-settings-daemon settings (/apps/gnome/gnome_settings_daemon) to GSettings
- Date: Thu, 7 Oct 2010 09:56:52 +0000 (UTC)
commit 450f288b7c11cdae48fc16a7b80f5b3a554fc856
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Tue Oct 5 16:30:32 2010 +0200
Migrate gnome-settings-daemon settings (/apps/gnome/gnome_settings_daemon) to GSettings
configure.ac | 1 +
gnome-settings-daemon/gnome-settings-manager.c | 43 ++-----
gnome-settings-daemon/gnome-settings-plugin-info.c | 66 ++++------
gnome-settings-daemon/gnome-settings-plugin-info.h | 3 +-
plugins/housekeeping/gsd-disk-space.c | 109 ++++++-----------
plugins/housekeeping/gsd-ldsm-dialog.c | 70 ++++++-----
plugins/media-keys/acme.h | 44 ++++----
plugins/media-keys/gsd-media-keys-manager.c | 133 +++++++++-----------
plugins/xrandr/gsd-xrandr-manager.c | 63 +++------
9 files changed, 214 insertions(+), 318 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b1bd763..3774e32 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,7 @@ PKG_CHECK_MODULES(SETTINGS_DAEMON,
glib-2.0 >= $GLIB_REQUIRED_VERSION
gtk+-3.0 >= $GTK_REQUIRED_VERSION
gconf-2.0 >= $GCONF_REQUIRED_VERSION
+ gio-2.0 >= $GIO_REQUIRED_VERSION
gmodule-2.0
gthread-2.0
dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
diff --git a/gnome-settings-daemon/gnome-settings-manager.c b/gnome-settings-daemon/gnome-settings-manager.c
index 0f89ee3..0869fc5 100644
--- a/gnome-settings-daemon/gnome-settings-manager.c
+++ b/gnome-settings-daemon/gnome-settings-manager.c
@@ -28,10 +28,10 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <glib-object.h>
+#include <gio/gio.h>
#define DBUS_API_SUBJECT_TO_CHANGE
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <gconf/gconf-client.h>
#include "gnome-settings-plugin-info.h"
#include "gnome-settings-manager.h"
@@ -40,7 +40,7 @@
#define GSD_MANAGER_DBUS_PATH "/org/gnome/SettingsDaemon"
-#define DEFAULT_SETTINGS_PREFIX "/apps/gnome_settings_daemon/plugins"
+#define DEFAULT_SETTINGS_PREFIX "org.gnome.settings-daemon"
#define PLUGIN_EXT ".gnome-settings-plugin"
@@ -49,7 +49,7 @@
struct GnomeSettingsManagerPrivate
{
DBusGConnection *connection;
- GConfClient *gconf_client;
+ GSettings *settings;
char *settings_prefix;
GSList *plugins;
};
@@ -159,7 +159,6 @@ _load_file (GnomeSettingsManager *manager,
GnomeSettingsPluginInfo *info;
char *key_name;
int priority;
- GError *error;
GSList *l;
g_debug ("Loading plugin: %s", filename);
@@ -185,24 +184,10 @@ _load_file (GnomeSettingsManager *manager,
g_signal_connect (info, "deactivated",
G_CALLBACK (on_plugin_deactivated), manager);
- key_name = g_strdup_printf ("%s/%s/active",
+ key_name = g_strdup_printf ("%s.plugins.%s",
manager->priv->settings_prefix,
gnome_settings_plugin_info_get_location (info));
- gnome_settings_plugin_info_set_enabled_key_name (info, key_name);
- g_free (key_name);
-
- key_name = g_strdup_printf ("%s/%s/priority",
- manager->priv->settings_prefix,
- gnome_settings_plugin_info_get_location (info));
- error = NULL;
- priority = gconf_client_get_int (manager->priv->gconf_client, key_name, &error);
- if (error == NULL) {
- if (priority > 0) {
- gnome_settings_plugin_info_set_priority (info, priority);
- }
- } else {
- g_error_free (error);
- }
+ gnome_settings_plugin_info_set_settings_prefix (info, key_name);
g_free (key_name);
out:
@@ -337,16 +322,11 @@ gnome_settings_manager_start (GnomeSettingsManager *manager,
goto out;
}
- manager->priv->gconf_client = gconf_client_get_default ();
-
- gnome_settings_profile_start ("preloading gconf keys");
- gconf_client_add_dir (manager->priv->gconf_client,
- manager->priv->settings_prefix,
- GCONF_CLIENT_PRELOAD_RECURSIVE,
- NULL);
- gnome_settings_profile_end ("preloading gconf keys");
+ gnome_settings_profile_start ("initializing plugins");
+ manager->priv->settings = g_settings_new (manager->priv->settings_prefix);
_load_all (manager);
+ gnome_settings_profile_end ("initializing plugins");
ret = TRUE;
out:
@@ -381,11 +361,8 @@ gnome_settings_manager_stop (GnomeSettingsManager *manager)
_unload_all (manager);
- gconf_client_remove_dir (manager->priv->gconf_client,
- manager->priv->settings_prefix,
- NULL);
- g_object_unref (manager->priv->gconf_client);
- manager->priv->gconf_client = NULL;
+ g_object_unref (manager->priv->settings);
+ manager->priv->settings = NULL;
}
static void
diff --git a/gnome-settings-daemon/gnome-settings-plugin-info.c b/gnome-settings-daemon/gnome-settings-plugin-info.c
index a4a10a8..823530e 100644
--- a/gnome-settings-daemon/gnome-settings-plugin-info.c
+++ b/gnome-settings-daemon/gnome-settings-plugin-info.c
@@ -25,7 +25,7 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <gmodule.h>
-#include <gconf/gconf-client.h>
+#include <gio/gio.h>
#include "gnome-settings-plugin-info.h"
#include "gnome-settings-module.h"
@@ -48,7 +48,7 @@ typedef enum
struct GnomeSettingsPluginInfoPrivate
{
char *file;
- GConfClient *client;
+ GSettings *settings;
char *location;
GnomeSettingsPluginLoader loader;
@@ -70,8 +70,6 @@ struct GnomeSettingsPluginInfoPrivate
when the interpreter has not been correctly initializated) */
int available : 1;
- guint enabled_notification_id;
-
/* Priority determines the order in which plugins are started and
* stopped. A lower number means higher priority. */
guint priority;
@@ -117,14 +115,7 @@ gnome_settings_plugin_info_finalize (GObject *object)
g_free (info->priv->copyright);
g_strfreev (info->priv->authors);
- if (info->priv->enabled_notification_id != 0) {
- gconf_client_notify_remove (info->priv->client,
- info->priv->enabled_notification_id);
-
- info->priv->enabled_notification_id = 0;
- }
-
- g_object_unref (info->priv->client);
+ g_object_unref (info->priv->settings);
G_OBJECT_CLASS (gnome_settings_plugin_info_parent_class)->finalize (object);
}
@@ -164,7 +155,6 @@ static void
gnome_settings_plugin_info_init (GnomeSettingsPluginInfo *info)
{
info->priv = GNOME_SETTINGS_PLUGIN_INFO_GET_PRIVATE (info);
- info->priv->client = gconf_client_get_default ();
}
static void
@@ -295,33 +285,6 @@ gnome_settings_plugin_info_fill_from_file (GnomeSettingsPluginInfo *info,
return ret;
}
-static void
-plugin_enabled_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- GnomeSettingsPluginInfo *info)
-{
- if (gconf_value_get_bool (entry->value)) {
- gnome_settings_plugin_info_activate (info);
- } else {
- gnome_settings_plugin_info_deactivate (info);
- }
-}
-
-void
-gnome_settings_plugin_info_set_enabled_key_name (GnomeSettingsPluginInfo *info,
- const char *key_name)
-{
- info->priv->enabled_notification_id = gconf_client_notify_add (info->priv->client,
- key_name,
- (GConfClientNotifyFunc)plugin_enabled_cb,
- info,
- NULL,
- NULL);
-
- info->priv->enabled = gconf_client_get_bool (info->priv->client, key_name, NULL);
-}
-
GnomeSettingsPluginInfo *
gnome_settings_plugin_info_new_from_file (const char *filename)
{
@@ -340,6 +303,29 @@ gnome_settings_plugin_info_new_from_file (const char *filename)
}
static void
+plugin_enabled_cb (GSettings *settings,
+ const gchar *key,
+ GnomeSettingsPluginInfo *info)
+{
+ if (g_strcmp0 (key, "active") == 0) {
+ if (g_settings_get_boolean (settings, "active"))
+ gnome_settings_plugin_info_activate (info);
+ else
+ gnome_settings_plugin_info_deactivate (info);
+ }
+}
+
+void
+gnome_settings_plugin_info_set_settings_prefix (GnomeSettingsPluginInfo *info,
+ const char *settings_prefix)
+{
+ info->priv->settings = g_settings_new (settings_prefix);
+ info->priv->enabled = g_settings_get_boolean (info->priv->settings, "active");
+ g_signal_connect (G_OBJECT (info->priv->settings), "changed",
+ G_CALLBACK (plugin_enabled_cb), info);
+}
+
+static void
_deactivate_plugin (GnomeSettingsPluginInfo *info)
{
gnome_settings_plugin_deactivate (info->priv->plugin);
diff --git a/gnome-settings-daemon/gnome-settings-plugin-info.h b/gnome-settings-daemon/gnome-settings-plugin-info.h
index 9db32ce..d3fac9b 100644
--- a/gnome-settings-daemon/gnome-settings-plugin-info.h
+++ b/gnome-settings-daemon/gnome-settings-plugin-info.h
@@ -52,8 +52,7 @@ GType gnome_settings_plugin_info_get_type (void) G_GNUC_CON
GnomeSettingsPluginInfo *gnome_settings_plugin_info_new_from_file (const char *filename);
-void gnome_settings_plugin_info_set_enabled_key_name (GnomeSettingsPluginInfo *info,
- const char *key_name);
+void gnome_settings_plugin_info_set_settings_prefix (GnomeSettingsPluginInfo *info, const char *settings_prefix);
gboolean gnome_settings_plugin_info_activate (GnomeSettingsPluginInfo *info);
gboolean gnome_settings_plugin_info_deactivate (GnomeSettingsPluginInfo *info);
diff --git a/plugins/housekeeping/gsd-disk-space.c b/plugins/housekeeping/gsd-disk-space.c
index f474d96..fb9bcb0 100644
--- a/plugins/housekeeping/gsd-disk-space.c
+++ b/plugins/housekeeping/gsd-disk-space.c
@@ -35,7 +35,6 @@
#include <gio/gunixmounts.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
#include "gsd-disk-space.h"
#include "gsd-ldsm-dialog.h"
@@ -48,12 +47,12 @@
#define DISK_SPACE_ANALYZER "baobab"
-#define GCONF_HOUSEKEEPING_DIR "/apps/gnome_settings_daemon/plugins/housekeeping"
-#define GCONF_FREE_PC_NOTIFY_KEY "free_percent_notify"
-#define GCONF_FREE_PC_NOTIFY_AGAIN_KEY "free_percent_notify_again"
-#define GCONF_FREE_SIZE_NO_NOTIFY "free_size_gb_no_notify"
-#define GCONF_MIN_NOTIFY_PERIOD "min_notify_period"
-#define GCONF_IGNORE_PATHS "ignore_paths"
+#define SETTINGS_HOUSEKEEPING_DIR "org.gnome.settings-daemon.plugins.housekeeping"
+#define SETTINGS_FREE_PC_NOTIFY_KEY "free-percent-notify"
+#define SETTINGS_FREE_PC_NOTIFY_AGAIN_KEY "free-percent-notify-again"
+#define SETTINGS_FREE_SIZE_NO_NOTIFY "free-size-gb-no-notify"
+#define SETTINGS_MIN_NOTIFY_PERIOD "min-notify-period"
+#define SETTINGS_IGNORE_PATHS "ignore-paths"
typedef struct
{
@@ -70,8 +69,7 @@ static double free_percent_notify_again = 0.01;
static unsigned int free_size_gb_no_notify = 2;
static unsigned int min_notify_period = 10;
static GSList *ignore_paths = NULL;
-static unsigned int gconf_notify_id;
-static GConfClient *client = NULL;
+static GSettings *settings = NULL;
static GsdLdsmDialog *dialog = NULL;
static guint64 *time_read;
@@ -568,70 +566,48 @@ ldsm_is_hash_item_in_ignore_paths (gpointer key,
static void
gsd_ldsm_get_config ()
{
- GError *error = NULL;
-
- free_percent_notify = gconf_client_get_float (client,
- GCONF_HOUSEKEEPING_DIR "/" GCONF_FREE_PC_NOTIFY_KEY,
- &error);
- if (error != NULL) {
- g_warning ("Error reading configuration from GConf: %s", error->message ? error->message : "Unknown error");
- g_clear_error (&error);
- }
+ gchar **settings_list;
+
+ free_percent_notify = g_settings_get_double (settings, SETTINGS_FREE_PC_NOTIFY_KEY);
if (free_percent_notify >= 1 || free_percent_notify < 0) {
g_warning ("Invalid configuration of free_percent_notify: %f\n" \
"Using sensible default", free_percent_notify);
free_percent_notify = 0.05;
}
- free_percent_notify_again = gconf_client_get_float (client,
- GCONF_HOUSEKEEPING_DIR "/" GCONF_FREE_PC_NOTIFY_AGAIN_KEY,
- &error);
- if (error != NULL) {
- g_warning ("Error reading configuration from GConf: %s", error->message ? error->message : "Unknown error");
- g_clear_error (&error);
- }
+ free_percent_notify_again = g_settings_get_double (settings, SETTINGS_FREE_PC_NOTIFY_AGAIN_KEY);
if (free_percent_notify_again >= 1 || free_percent_notify_again < 0) {
g_warning ("Invalid configuration of free_percent_notify_again: %f\n" \
"Using sensible default\n", free_percent_notify_again);
free_percent_notify_again = 0.01;
}
- free_size_gb_no_notify = gconf_client_get_int (client,
- GCONF_HOUSEKEEPING_DIR "/" GCONF_FREE_SIZE_NO_NOTIFY,
- &error);
- if (error != NULL) {
- g_warning ("Error reading configuration from GConf: %s", error->message ? error->message : "Unknown error");
- g_clear_error (&error);
- }
- min_notify_period = gconf_client_get_int (client,
- GCONF_HOUSEKEEPING_DIR "/" GCONF_MIN_NOTIFY_PERIOD,
- &error);
- if (error != NULL) {
- g_warning ("Error reading configuration from GConf: %s", error->message ? error->message : "Unkown error");
- g_clear_error (&error);
- }
-
- if (ignore_paths != NULL) {
+ free_size_gb_no_notify = g_settings_get_int (settings, SETTINGS_FREE_SIZE_NO_NOTIFY);
+ min_notify_period = g_settings_get_int (settings, SETTINGS_MIN_NOTIFY_PERIOD);
+
+ if (ignore_paths != NULL) {
g_slist_foreach (ignore_paths, (GFunc) g_free, NULL);
g_slist_free (ignore_paths);
- }
- ignore_paths = gconf_client_get_list (client,
- GCONF_HOUSEKEEPING_DIR "/" GCONF_IGNORE_PATHS,
- GCONF_VALUE_STRING, &error);
- if (error != NULL) {
- g_warning ("Error reading configuration from GConf: %s", error->message ? error->message : "Unkown error");
- g_clear_error (&error);
- } else {
+ }
+
+ settings_list = g_settings_get_strv (settings, SETTINGS_IGNORE_PATHS);
+ if (settings_list != NULL) {
+ gint i;
+
+ for (i = 0; i < G_N_ELEMENTS (settings_list); i++) {
+ if (settings_list[i] != NULL)
+ ignore_paths = g_slist_append (ignore_paths, settings_list[i]);
+ }
+
/* Make sure we dont leave stale entries in ldsm_notified_hash */
- g_hash_table_foreach_remove (ldsm_notified_hash,
- ldsm_is_hash_item_in_ignore_paths, NULL);
- }
+ g_hash_table_foreach_remove (ldsm_notified_hash,
+ ldsm_is_hash_item_in_ignore_paths, NULL);
+ }
}
static void
-gsd_ldsm_update_config (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
+gsd_ldsm_update_config (GSettings *settings,
+ const gchar *key,
gpointer user_data)
{
gsd_ldsm_get_config ();
@@ -640,8 +616,6 @@ gsd_ldsm_update_config (GConfClient *client,
void
gsd_ldsm_setup (gboolean check_now)
{
- GError *error = NULL;
-
if (ldsm_notified_hash || ldsm_timeout_id || ldsm_monitor) {
g_warning ("Low disk space monitor already initialized.");
return;
@@ -651,19 +625,13 @@ gsd_ldsm_setup (gboolean check_now)
g_free,
ldsm_free_mount_info);
- client = gconf_client_get_default ();
- if (client != NULL) {
+ settings = g_settings_new (SETTINGS_HOUSEKEEPING_DIR);
+ if (settings != NULL) {
gsd_ldsm_get_config ();
- gconf_notify_id = gconf_client_notify_add (client,
- GCONF_HOUSEKEEPING_DIR,
- (GConfClientNotifyFunc) gsd_ldsm_update_config,
- NULL, NULL, &error);
- if (error != NULL) {
- g_warning ("Cannot register callback for GConf notification");
- g_clear_error (&error);
- }
+ g_signal_connect (G_OBJECT (settings), "changed",
+ G_CALLBACK (gsd_ldsm_update_config), NULL);
} else {
- g_warning ("Failed to get default client");
+ g_warning ("Failed to get settings client");
}
ldsm_monitor = g_unix_mount_monitor_new ();
@@ -694,9 +662,8 @@ gsd_ldsm_clean (void)
g_object_unref (ldsm_monitor);
ldsm_monitor = NULL;
- if (client) {
- gconf_client_notify_remove (client, gconf_notify_id);
- g_object_unref (client);
+ if (settings != NULL) {
+ g_object_unref (settings);
}
if (dialog) {
diff --git a/plugins/housekeeping/gsd-ldsm-dialog.c b/plugins/housekeeping/gsd-ldsm-dialog.c
index c02352c..1c26898 100644
--- a/plugins/housekeeping/gsd-ldsm-dialog.c
+++ b/plugins/housekeeping/gsd-ldsm-dialog.c
@@ -18,11 +18,11 @@
*/
#include <glib/gi18n.h>
-#include <gconf/gconf-client.h>
+#include <gio/gio.h>
#include "gsd-ldsm-dialog.h"
-#define GCONF_CLIENT_IGNORE_PATHS "/apps/gnome_settings_daemon/plugins/housekeeping/ignore_paths"
+#define SETTINGS_HOUSEKEEPING_DIR "org.gnome.settings-daemon.plugins.housekeeping"
enum
{
@@ -149,44 +149,46 @@ ignore_check_button_toggled_cb (GtkToggleButton *button,
gpointer user_data)
{
GsdLdsmDialog *dialog = (GsdLdsmDialog *)user_data;
- GConfClient *client;
- GSList *ignore_paths;
- GError *error = NULL;
- gboolean ignore, ret, updated;
+ GSettings *settings;
+ gchar **settings_list;
+ gboolean ignore, updated;
- client = gconf_client_get_default ();
- if (client != NULL) {
- ignore_paths = gconf_client_get_list (client,
- GCONF_CLIENT_IGNORE_PATHS,
- GCONF_VALUE_STRING, &error);
- if (error != NULL) {
- g_warning ("Cannot change ignore preference - failed to read existing configuration: %s",
- error->message ? error->message : "Unkown error");
- g_clear_error (&error);
- return;
- } else {
- ignore = gtk_toggle_button_get_active (button);
- updated = update_ignore_paths (&ignore_paths, dialog->priv->mount_path, ignore);
+ settings = g_settings_new (SETTINGS_HOUSEKEEPING_DIR);
+ if (settings != NULL) {
+ gint i;
+ GSList *ignore_paths = NULL;
+
+ settings_list = g_settings_get_strv (settings, "ignore-paths");
+
+ for (i = 0; i < G_N_ELEMENTS (settings_list); i++) {
+ if (settings_list[i] != NULL)
+ ignore_paths = g_slist_append (ignore_paths, g_strdup (settings_list[i]));
}
+
+ ignore = gtk_toggle_button_get_active (button);
+ updated = update_ignore_paths (&ignore_paths, dialog->priv->mount_path, ignore);
+
+ g_strfreev (settings_list);
- if (!updated)
- return;
-
- ret = gconf_client_set_list (client,
- GCONF_CLIENT_IGNORE_PATHS,
- GCONF_VALUE_STRING,
- ignore_paths, &error);
- if (!ret || error != NULL) {
- g_warning ("Cannot change ignore preference - failed to commit changes: %s",
- error->message ? error->message : "Unkown error");
- g_clear_error (&error);
+ if (updated) {
+ GSList *l;
+ GPtrArray *array = g_ptr_array_new ();
+
+ for (l = ignore_paths; l != NULL; l = l->next)
+ g_ptr_array_add (array, l->data);
+
+ if (!g_settings_set_strv (settings, "ignore-paths", (const gchar **) array->pdata)) {
+ g_warning ("Cannot change ignore preference - failed to commit changes");
+ }
+
+ g_ptr_array_free (array, FALSE);
}
-
+
g_slist_foreach (ignore_paths, (GFunc) g_free, NULL);
g_slist_free (ignore_paths);
- g_object_unref (client);
+ g_object_unref (settings);
} else {
- g_warning ("Cannot change ignore preference - failed to get GConfClient");
+ g_warning ("Cannot change ignore preference - failed to get settings client");
}
}
@@ -228,7 +230,7 @@ gsd_ldsm_dialog_init (GsdLdsmDialog *dialog)
/* Create the check button to ignore future warnings */
dialog->priv->ignore_check_button = gtk_check_button_new ();
/* The button should be inactive if the dialog was just called.
- * I suppose it could be possible for the user to manually edit the GConf key between
+ * I suppose it could be possible for the user to manually edit the GSettings key between
* the mount being checked and the dialog appearing, but I don't think it matters
* too much */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->ignore_check_button), FALSE);
diff --git a/plugins/media-keys/acme.h b/plugins/media-keys/acme.h
index 8ceae21..bcf9567 100644
--- a/plugins/media-keys/acme.h
+++ b/plugins/media-keys/acme.h
@@ -23,8 +23,8 @@
#include "gsd-keygrab.h"
-#define GCONF_BINDING_DIR "/apps/gnome_settings_daemon/keybindings"
-#define GCONF_MISC_DIR "/apps/gnome_settings_daemon"
+#define SETTINGS_BINDING_DIR "org.gnome.desktop.keybindings"
+#define SETTINGS_MISC_DIR "org.gnome.settings-daemon"
enum {
TOUCHPAD_KEY,
@@ -51,28 +51,28 @@ enum {
static struct {
int key_type;
- const char *gconf_key;
+ const char *settings_key;
Key *key;
} keys[HANDLED_KEYS] = {
- { TOUCHPAD_KEY, GCONF_BINDING_DIR "/touchpad", NULL },
- { MUTE_KEY, GCONF_BINDING_DIR "/volume_mute",NULL },
- { VOLUME_DOWN_KEY, GCONF_BINDING_DIR "/volume_down", NULL },
- { VOLUME_UP_KEY, GCONF_BINDING_DIR "/volume_up", NULL },
- { POWER_KEY, GCONF_BINDING_DIR "/power", NULL },
- { EJECT_KEY, GCONF_BINDING_DIR "/eject", NULL },
- { HOME_KEY, GCONF_BINDING_DIR "/home", NULL },
- { MEDIA_KEY, GCONF_BINDING_DIR "/media", NULL },
- { CALCULATOR_KEY, GCONF_BINDING_DIR "/calculator", NULL },
- { SEARCH_KEY, GCONF_BINDING_DIR "/search", NULL },
- { EMAIL_KEY, GCONF_BINDING_DIR "/email", NULL },
- { SCREENSAVER_KEY, GCONF_BINDING_DIR "/screensaver", NULL },
- { HELP_KEY, GCONF_BINDING_DIR "/help", NULL },
- { WWW_KEY, GCONF_BINDING_DIR "/www", NULL },
- { PLAY_KEY, GCONF_BINDING_DIR "/play", NULL },
- { PAUSE_KEY, GCONF_BINDING_DIR "/pause", NULL },
- { STOP_KEY, GCONF_BINDING_DIR "/stop", NULL },
- { PREVIOUS_KEY, GCONF_BINDING_DIR "/previous", NULL },
- { NEXT_KEY, GCONF_BINDING_DIR "/next", NULL },
+ { TOUCHPAD_KEY, "touchpad", NULL },
+ { MUTE_KEY, "volume-mute",NULL },
+ { VOLUME_DOWN_KEY, "volume-down", NULL },
+ { VOLUME_UP_KEY, "volume-up", NULL },
+ { POWER_KEY, "power", NULL },
+ { EJECT_KEY, "eject", NULL },
+ { HOME_KEY, "home", NULL },
+ { MEDIA_KEY, "media", NULL },
+ { CALCULATOR_KEY, "calculator", NULL },
+ { SEARCH_KEY, "search", NULL },
+ { EMAIL_KEY, "email", NULL },
+ { SCREENSAVER_KEY, "screensaver", NULL },
+ { HELP_KEY, "help", NULL },
+ { WWW_KEY, "www", NULL },
+ { PLAY_KEY, "play", NULL },
+ { PAUSE_KEY, "pause", NULL },
+ { STOP_KEY, "stop", NULL },
+ { PREVIOUS_KEY, "previous", NULL },
+ { NEXT_KEY, "next", NULL },
};
#endif /* __ACME_H__ */
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index b563f73..7281a26 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -33,10 +33,10 @@
#include <glib.h>
#include <glib/gi18n.h>
+#include <gio/gio.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
@@ -60,7 +60,7 @@
#define GSD_MEDIA_KEYS_DBUS_PATH GSD_DBUS_PATH "/MediaKeys"
#define GSD_MEDIA_KEYS_DBUS_NAME GSD_DBUS_NAME ".MediaKeys"
-#define TOUCHPAD_ENABLED_KEY "/desktop/gnome/peripherals/touchpad/touchpad_enabled"
+#define TOUCHPAD_ENABLED_KEY "touchpad-enabled"
#define VOLUME_STEP 6 /* percents for one volume button press */
#define MAX_VOLUME 65536.0
@@ -80,7 +80,7 @@ struct GsdMediaKeysManagerPrivate
GvcMixerStream *stream;
#endif /* HAVE_PULSE */
GtkWidget *dialog;
- GConfClient *conf_client;
+ GSettings *settings;
GVolumeMonitor *volume_monitor;
/* Multihead stuff */
@@ -90,7 +90,6 @@ struct GsdMediaKeysManagerPrivate
GList *media_players;
DBusGConnection *connection;
- guint notify[HANDLED_KEYS];
};
enum {
@@ -154,13 +153,14 @@ get_term_command (GsdMediaKeysManager *manager)
{
char *cmd_term;
char *cmd = NULL;
+ GSettings *settings;
- cmd_term = gconf_client_get_string (manager->priv->conf_client,
- "/desktop/gnome/applications/terminal/exec", NULL);
+ settings = g_settings_new ("org.gnome.desktop.applications.terminal");
+ cmd_term = g_settings_get_string (settings, "exec");
if ((cmd_term != NULL) && (strcmp (cmd_term, "") != 0)) {
char *cmd_args;
- cmd_args = gconf_client_get_string (manager->priv->conf_client,
- "/desktop/gnome/applications/terminal/exec_arg", NULL);
+
+ cmd_args = g_settings_get_string (settings, "exec-arg");
if ((cmd_args != NULL) && (strcmp (cmd_term, "") != 0)) {
cmd = g_strdup_printf ("%s %s -e", cmd_term, cmd_args);
} else {
@@ -171,6 +171,7 @@ get_term_command (GsdMediaKeysManager *manager)
}
g_free (cmd_term);
+ g_object_unref (settings);
return cmd;
}
@@ -270,21 +271,20 @@ is_valid_shortcut (const char *string)
}
static void
-update_kbd_cb (GConfClient *client,
- guint id,
- GConfEntry *entry,
+update_kbd_cb (GSettings *settings,
+ const gchar *key,
GsdMediaKeysManager *manager)
{
int i;
gboolean need_flush = TRUE;
- g_return_if_fail (entry->key != NULL);
+ g_return_if_fail (key != NULL);
gdk_error_trap_push ();
/* Find the key that was modified */
for (i = 0; i < HANDLED_KEYS; i++) {
- if (strcmp (entry->key, keys[i].gconf_key) == 0) {
+ if (strcmp (key, keys[i].settings_key) == 0) {
char *tmp;
Key *key;
@@ -296,9 +296,7 @@ update_kbd_cb (GConfClient *client,
g_free (keys[i].key);
keys[i].key = NULL;
- tmp = gconf_client_get_string (manager->priv->conf_client,
- keys[i].gconf_key, NULL);
-
+ tmp = g_settings_get_string (manager->priv->settings, keys[i].settings_key);
if (is_valid_shortcut (tmp) == FALSE) {
g_free (tmp);
break;
@@ -341,18 +339,7 @@ init_kbd (GsdMediaKeysManager *manager)
char *tmp;
Key *key;
- manager->priv->notify[i] =
- gconf_client_notify_add (manager->priv->conf_client,
- keys[i].gconf_key,
- (GConfClientNotifyFunc) update_kbd_cb,
- manager,
- NULL,
- NULL);
-
- tmp = gconf_client_get_string (manager->priv->conf_client,
- keys[i].gconf_key,
- NULL);
-
+ tmp = g_settings_get_string (manager->priv->settings, keys[i].settings_key);
if (!is_valid_shortcut (tmp)) {
g_debug ("Not a valid shortcut: '%s'", tmp);
g_free (tmp);
@@ -456,12 +443,12 @@ do_unknown_action (GsdMediaKeysManager *manager,
const char *url)
{
char *string;
+ GSettings *settings;
g_return_if_fail (url != NULL);
- string = gconf_client_get_string (manager->priv->conf_client,
- "/desktop/gnome/url-handlers/unknown/command",
- NULL);
+ settings = g_settings_new ("org.gnome.desktop.url-handlers.unknown");
+ string = g_settings_get_string (settings, "command");
if ((string != NULL) && (strcmp (string, "") != 0)) {
char *cmd;
@@ -469,17 +456,19 @@ do_unknown_action (GsdMediaKeysManager *manager,
execute (manager, cmd, FALSE, FALSE);
g_free (cmd);
}
+
g_free (string);
+ g_object_unref (settings);
}
static void
do_help_action (GsdMediaKeysManager *manager)
{
char *string;
+ GSettings *settings;
- string = gconf_client_get_string (manager->priv->conf_client,
- "/desktop/gnome/url-handlers/ghelp/command",
- NULL);
+ settings = g_settings_new ("org.gnome.desktop.url-handlers.ghelp");
+ string = g_settings_get_string (settings, "command");
if ((string != NULL) && (strcmp (string, "") != 0)) {
char *cmd;
@@ -491,16 +480,17 @@ do_help_action (GsdMediaKeysManager *manager)
}
g_free (string);
+ g_object_unref (settings);
}
static void
do_mail_action (GsdMediaKeysManager *manager)
{
char *string;
+ GSettings *settings;
- string = gconf_client_get_string (manager->priv->conf_client,
- "/desktop/gnome/url-handlers/mailto/command",
- NULL);
+ settings = g_settings_new ("org.gnome.desktop.url-handlers.mailto");
+ string = g_settings_get_string (settings, "command");
if ((string != NULL) && (strcmp (string, "") != 0)) {
char *cmd;
@@ -508,28 +498,31 @@ do_mail_action (GsdMediaKeysManager *manager)
execute (manager,
cmd,
FALSE,
- gconf_client_get_bool (manager->priv->conf_client,
- "/desktop/gnome/url-handlers/mailto/needs_terminal", NULL));
+ g_settings_get_boolean (settings, "needs-terminal"));
g_free (cmd);
}
+
g_free (string);
+ g_object_unref (settings);
}
static void
do_media_action (GsdMediaKeysManager *manager)
{
char *command;
+ GSettings *settings;
- command = gconf_client_get_string (manager->priv->conf_client,
- "/desktop/gnome/applications/media/exec", NULL);
+ settings = g_settings_new ("org.gnome.desktop.applications.media");
+ command = g_settings_get_string (settings, "exec");
if ((command != NULL) && (strcmp (command, "") != 0)) {
execute (manager,
command,
FALSE,
- gconf_client_get_bool (manager->priv->conf_client,
- "/desktop/gnome/applications/media/needs_term", NULL));
+ g_settings_get_boolean (settings, "needs-terminal"));
}
+
g_free (command);
+ g_object_unref (settings);
}
static void
@@ -537,10 +530,10 @@ do_www_action (GsdMediaKeysManager *manager,
const char *url)
{
char *string;
+ GSettings *settings;
- string = gconf_client_get_string (manager->priv->conf_client,
- "/desktop/gnome/url-handlers/http/command",
- NULL);
+ settings = g_settings_new ("org.gnome.desktop.url-handlers.http");
+ string = g_settings_get_string (settings, "command");
if ((string != NULL) && (strcmp (string, "") != 0)) {
gchar *cmd;
@@ -554,13 +547,14 @@ do_www_action (GsdMediaKeysManager *manager,
execute (manager,
cmd,
FALSE,
- gconf_client_get_bool (manager->priv->conf_client,
- "/desktop/gnome/url-handlers/http/needs_terminal", NULL));
+ g_settings_get_boolean (settings, "needs-terminal"));
g_free (cmd);
} else {
do_unknown_action (manager, url ? url : "");
}
+
g_free (string);
+ g_object_unref (settings);
}
static void
@@ -638,8 +632,11 @@ do_eject_action (GsdMediaKeysManager *manager)
static void
do_touchpad_action (GsdMediaKeysManager *manager)
{
- GConfClient *client = manager->priv->conf_client;
- gboolean state = gconf_client_get_bool (client, TOUCHPAD_ENABLED_KEY, NULL);
+ GSettings *settings;
+ gboolean state;
+
+ settings = g_settings_new ("org.gnome.desktop.peripherals.touchpad");
+ state = g_settings_get_boolean (settings, TOUCHPAD_ENABLED_KEY);
dialog_init (manager);
gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (manager->priv->dialog),
@@ -647,7 +644,8 @@ do_touchpad_action (GsdMediaKeysManager *manager)
FALSE);
dialog_show (manager);
- gconf_client_set_bool (client, TOUCHPAD_ENABLED_KEY, !state, NULL);
+ g_settings_set_boolean (settings, TOUCHPAD_ENABLED_KEY, !state);
+ g_object_unref (settings);
}
#ifdef HAVE_PULSE
@@ -684,13 +682,14 @@ do_sound_action (GsdMediaKeysManager *manager,
guint vol, norm_vol_step;
int vol_step;
gboolean sound_changed;
+ GSettings *settings;
if (manager->priv->stream == NULL)
return;
- vol_step = gconf_client_get_int (manager->priv->conf_client,
- GCONF_MISC_DIR "/volume_step",
- NULL);
+ settings = g_settings_new (SETTINGS_MISC_DIR);
+ /* FIXME: why is this key under org.gnome.settings-daemon?? */
+ vol_step = g_settings_get_int (settings, "volume_step");
if (vol_step <= 0 || vol_step > 100)
vol_step = VOLUME_STEP;
@@ -1065,12 +1064,9 @@ start_media_keys_idle_cb (GsdMediaKeysManager *manager)
g_debug ("Starting media_keys manager");
gnome_settings_profile_start (NULL);
manager->priv->volume_monitor = g_volume_monitor_get ();
- manager->priv->conf_client = gconf_client_get_default ();
-
- gconf_client_add_dir (manager->priv->conf_client,
- GCONF_BINDING_DIR,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
+ manager->priv->settings = g_settings_new (SETTINGS_BINDING_DIR);
+ g_signal_connect (G_OBJECT (manager->priv->settings), "changed",
+ G_CALLBACK (update_kbd_cb), manager);
init_screens (manager);
init_kbd (manager);
@@ -1147,20 +1143,9 @@ gsd_media_keys_manager_stop (GsdMediaKeysManager *manager)
manager);
}
- if (priv->conf_client) {
- gconf_client_remove_dir (priv->conf_client,
- GCONF_BINDING_DIR,
- NULL);
-
- for (i = 0; i < HANDLED_KEYS; ++i) {
- if (priv->notify[i] != 0) {
- gconf_client_notify_remove (priv->conf_client, priv->notify[i]);
- priv->notify[i] = 0;
- }
- }
-
- g_object_unref (priv->conf_client);
- priv->conf_client = NULL;
+ if (priv->settings) {
+ g_object_unref (priv->settings);
+ priv->settings = NULL;
}
if (priv->volume_monitor != NULL) {
diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
index 0aef5de..0d34ce1 100644
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -34,10 +34,10 @@
#include <glib.h>
#include <glib/gi18n.h>
+#include <gio/gio.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
#include <dbus/dbus-glib.h>
#define GNOME_DESKTOP_USE_UNSTABLE_API
@@ -59,11 +59,11 @@
#define GSD_XRANDR_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_XRANDR_MANAGER, GsdXrandrManagerPrivate))
-#define CONF_DIR "/apps/gnome_settings_daemon/xrandr"
-#define CONF_KEY_SHOW_NOTIFICATION_ICON (CONF_DIR "/show_notification_icon")
-#define CONF_KEY_TURN_ON_EXTERNAL_MONITORS_AT_STARTUP (CONF_DIR "/turn_on_external_monitors_at_startup")
-#define CONF_KEY_TURN_ON_LAPTOP_MONITOR_AT_STARTUP (CONF_DIR "/turn_on_laptop_monitor_at_startup")
-#define CONF_KEY_DEFAULT_CONFIGURATION_FILE (CONF_DIR "/default_configuration_file")
+#define CONF_DIR "org.gnome.settings-daemon.xrandr"
+#define CONF_KEY_SHOW_NOTIFICATION_ICON ("show-notification-icon")
+#define CONF_KEY_TURN_ON_EXTERNAL_MONITORS_AT_STARTUP ("turn-on-external-monitors-at-startup")
+#define CONF_KEY_TURN_ON_LAPTOP_MONITOR_AT_STARTUP ("turn-on-laptop-monitor-at-startup")
+#define CONF_KEY_DEFAULT_CONFIGURATION_FILE ("default-configuration-file")
#define VIDEO_KEYSYM "XF86Display"
#define ROTATE_KEYSYM "XF86RotateWindows"
@@ -101,8 +101,7 @@ struct GsdXrandrManagerPrivate
GtkWidget *popup_menu;
GnomeRRConfig *configuration;
GnomeRRLabeler *labeler;
- GConfClient *client;
- int notify_id;
+ GSettings *settings;
/* fn-F7 status */
int current_fn_f7_config; /* -1 if no configs */
@@ -2143,21 +2142,19 @@ status_icon_stop (GsdXrandrManager *manager)
static void
start_or_stop_icon (GsdXrandrManager *manager)
{
- if (gconf_client_get_bool (manager->priv->client, CONF_KEY_SHOW_NOTIFICATION_ICON, NULL)) {
+ if (g_settings_get_boolean (manager->priv->settings, CONF_KEY_SHOW_NOTIFICATION_ICON)) {
status_icon_start (manager);
- }
- else {
+ } else {
status_icon_stop (manager);
}
}
static void
-on_config_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
+on_config_changed (GSettings *settings,
+ const gchar *key,
GsdXrandrManager *manager)
{
- if (strcmp (entry->key, CONF_KEY_SHOW_NOTIFICATION_ICON) == 0)
+ if (strcmp (key, CONF_KEY_SHOW_NOTIFICATION_ICON) == 0)
start_or_stop_icon (manager);
}
@@ -2190,9 +2187,9 @@ apply_default_boot_configuration (GsdXrandrManager *mgr, guint32 timestamp)
gboolean turn_on_external, turn_on_laptop;
turn_on_external =
- gconf_client_get_bool (mgr->priv->client, CONF_KEY_TURN_ON_EXTERNAL_MONITORS_AT_STARTUP, NULL);
+ g_settings_get_boolean (mgr->priv->settings, CONF_KEY_TURN_ON_EXTERNAL_MONITORS_AT_STARTUP);
turn_on_laptop =
- gconf_client_get_bool (mgr->priv->client, CONF_KEY_TURN_ON_LAPTOP_MONITOR_AT_STARTUP, NULL);
+ g_settings_get_boolean (mgr->priv->settings, CONF_KEY_TURN_ON_LAPTOP_MONITOR_AT_STARTUP);
if (turn_on_external && turn_on_laptop)
config = make_clone_setup (screen);
@@ -2273,7 +2270,7 @@ apply_default_configuration_from_file (GsdXrandrManager *manager, guint32 timest
char *default_config_filename;
gboolean result;
- default_config_filename = gconf_client_get_string (priv->client, CONF_KEY_DEFAULT_CONFIGURATION_FILE, NULL);
+ default_config_filename = g_settings_get_string (priv->settings, CONF_KEY_DEFAULT_CONFIGURATION_FILE);
if (!default_config_filename)
return FALSE;
@@ -2308,19 +2305,9 @@ gsd_xrandr_manager_start (GsdXrandrManager *manager,
log_screen (manager->priv->rw_screen);
manager->priv->running = TRUE;
- manager->priv->client = gconf_client_get_default ();
-
- g_assert (manager->priv->notify_id == 0);
-
- gconf_client_add_dir (manager->priv->client, CONF_DIR,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
-
- manager->priv->notify_id =
- gconf_client_notify_add (
- manager->priv->client, CONF_DIR,
- (GConfClientNotifyFunc)on_config_changed,
- manager, NULL, NULL);
+ manager->priv->settings = g_settings_new (CONF_DIR);
+ g_signal_connect (manager->priv->settings, "changed",
+ G_CALLBACK (on_config_changed), manager);
if (manager->priv->switch_video_mode_keycode) {
gdk_error_trap_push ();
@@ -2398,17 +2385,9 @@ gsd_xrandr_manager_stop (GsdXrandrManager *manager)
(GdkFilterFunc) event_filter,
manager);
- if (manager->priv->notify_id != 0) {
- gconf_client_remove_dir (manager->priv->client,
- CONF_DIR, NULL);
- gconf_client_notify_remove (manager->priv->client,
- manager->priv->notify_id);
- manager->priv->notify_id = 0;
- }
-
- if (manager->priv->client != NULL) {
- g_object_unref (manager->priv->client);
- manager->priv->client = NULL;
+ if (manager->priv->settings != NULL) {
+ g_object_unref (manager->priv->settings);
+ manager->priv->settings = NULL;
}
if (manager->priv->rw_screen != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]