diff options
author | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-10-13 22:53:51 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-10-13 22:53:51 +0800 |
commit | d4e8e2f809d4da7dd5ac0b53a7900e5bd39777f9 (patch) | |
tree | 57244f41cfcd1cd6ded0348501ce465ebfba9d2d /shell | |
parent | 805d8c25ac6c8f58c8e17f3b89fa50f17cfdf27b (diff) | |
download | gsoc2013-evolution-d4e8e2f809d4da7dd5ac0b53a7900e5bd39777f9.tar gsoc2013-evolution-d4e8e2f809d4da7dd5ac0b53a7900e5bd39777f9.tar.gz gsoc2013-evolution-d4e8e2f809d4da7dd5ac0b53a7900e5bd39777f9.tar.bz2 gsoc2013-evolution-d4e8e2f809d4da7dd5ac0b53a7900e5bd39777f9.tar.lz gsoc2013-evolution-d4e8e2f809d4da7dd5ac0b53a7900e5bd39777f9.tar.xz gsoc2013-evolution-d4e8e2f809d4da7dd5ac0b53a7900e5bd39777f9.tar.zst gsoc2013-evolution-d4e8e2f809d4da7dd5ac0b53a7900e5bd39777f9.zip |
Migrate most of the shell code to GSettings
Diffstat (limited to 'shell')
-rw-r--r-- | shell/e-shell-migrate.c | 28 | ||||
-rw-r--r-- | shell/e-shell-window-private.c | 55 | ||||
-rw-r--r-- | shell/e-shell.c | 13 | ||||
-rw-r--r-- | shell/main.c | 61 |
4 files changed, 63 insertions, 94 deletions
diff --git a/shell/e-shell-migrate.c b/shell/e-shell-migrate.c index dd75a40b82..e694ec29fd 100644 --- a/shell/e-shell-migrate.c +++ b/shell/e-shell-migrate.c @@ -38,9 +38,6 @@ #include "es-event.h" -#define GCONF_VERSION_KEY "/apps/evolution/version" -#define GCONF_LAST_VERSION_KEY "/apps/evolution/last_version" - /******************** Begin XDG Base Directory Migration ********************/ /* These are the known EShellBackend names as of Evolution 3.0 */ static const gchar *shell_backend_names[] = @@ -735,23 +732,23 @@ shell_migrate_get_version (EShell *shell, gint *minor, gint *micro) { - GConfClient *client; - const gchar *key; + GSettings *settings; gchar *string; *major = 0; *minor = 0; *micro = 0; - key = GCONF_VERSION_KEY; - client = e_shell_get_gconf_client (shell); - string = gconf_client_get_string (client, key, NULL); + settings = g_settings_new ("org.gnome.evolution"); + string = g_settings_get_string (settings, "version"); if (string != NULL) { /* Since 1.4.0 we've kept the version key in GConf. */ sscanf (string, "%d.%d.%d", major, minor, micro); g_free (string); } + + g_object_unref (settings); } static void @@ -902,7 +899,7 @@ gboolean e_shell_migrate_attempt (EShell *shell) { ESEvent *ese; - GConfClient *client; + GSettings *settings; const gchar *key; gint major, minor, micro; gint last_major, last_minor, last_micro; @@ -912,7 +909,7 @@ e_shell_migrate_attempt (EShell *shell) g_return_val_if_fail (E_IS_SHELL (shell), FALSE); - client = e_shell_get_gconf_client (shell); + settings = g_settings_new ("org.gnome.evolution"); if (sscanf (BASE_VERSION, "%d.%d", &curr_major, &curr_minor) != 2) { g_warning ("Could not parse BASE_VERSION (%s)", BASE_VERSION); @@ -946,14 +943,13 @@ e_shell_migrate_attempt (EShell *shell) /* Record a successful migration. */ string = g_strdup_printf ( "%d.%d.%d", curr_major, curr_minor, curr_micro); - gconf_client_set_string (client, GCONF_VERSION_KEY, string, NULL); + g_settings_set_string (settings, "version", string); g_free (string); migrated = TRUE; - key = GCONF_LAST_VERSION_KEY; - /* Try to retrieve the last migrated version from GConf. */ - string = gconf_client_get_string (client, key, NULL); + /* Try to retrieve the last migrated version from GSettings. */ + string = g_settings_get_string (client, "last-upgraded-version"); if (migrated || string == NULL || sscanf (string, "%d.%d.%d", &last_major, &last_minor, &last_micro) != 3) { last_major = major; @@ -964,9 +960,11 @@ e_shell_migrate_attempt (EShell *shell) string = g_strdup_printf ( "%d.%d.%d", last_major, last_minor, last_micro); - gconf_client_set_string (client, key, string, NULL); + g_settings_set_string (client, "last-upgraded-version", string); g_free (string); + g_object_unref (settings); + /** @Event: Shell attempted upgrade * @Id: upgrade.done * @Target: ESMenuTargetState diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c index 2b86bb1ec3..2b3d159ada 100644 --- a/shell/e-shell-window-private.c +++ b/shell/e-shell-window-private.c @@ -31,17 +31,14 @@ shell_window_save_switcher_style_cb (GtkRadioAction *action, EShellWindow *shell_window) { EShell *shell; - GConfClient *client; + GSettings *settings; GtkToolbarStyle style; - const gchar *key; const gchar *string; - GError *error = NULL; shell = e_shell_window_get_shell (shell_window); - client = e_shell_get_gconf_client (shell); + settings = g_settings_new ("org.gnome.evolution.shell"); style = gtk_radio_action_get_current_value (action); - key = "/apps/evolution/shell/view_defaults/buttons_style"; switch (style) { case GTK_TOOLBAR_ICONS: @@ -62,10 +59,8 @@ shell_window_save_switcher_style_cb (GtkRadioAction *action, break; } - if (!gconf_client_set_string (client, key, string, &error)) { - g_warning ("%s", error->message); - g_error_free (error); - } + g_settings_set_string (settings, "buttons-style", string); + g_object_unref (settings); } static void @@ -73,21 +68,16 @@ shell_window_init_switcher_style (EShellWindow *shell_window) { EShell *shell; GtkAction *action; - GConfClient *client; + GSettings *settings; GtkToolbarStyle style; - const gchar *key; gchar *string; - GError *error = NULL; - - /* XXX GConfBridge doesn't let you convert between numeric properties - * and string keys, so we have to create the binding manually. */ shell = e_shell_window_get_shell (shell_window); - client = e_shell_get_gconf_client (shell); + settings = g_settings_new ("org.gnome.evolution.shell"); action = ACTION (SWITCHER_STYLE_ICONS); - key = "/apps/evolution/shell/view_defaults/buttons_style"; - string = gconf_client_get_string (client, key, &error); + string = g_settings_get_string (settings, "buttons-style"); + g_object_unref (settings); if (string != NULL) { if (strcmp (string, "icons") == 0) @@ -266,7 +256,7 @@ e_shell_window_private_constructed (EShellWindow *shell_window) { EShellWindowPrivate *priv = shell_window->priv; EShell *shell; - GConfBridge *bridge; + GSettings *settings; GtkAction *action; GtkAccelGroup *accel_group; GtkUIManager *ui_manager; @@ -421,37 +411,31 @@ e_shell_window_private_constructed (EShellWindow *shell_window) action, "sensitive", G_BINDING_SYNC_CREATE); - /* Bind GObject properties to GConf keys. */ + /* Bind GObject properties to GSettings keys. */ - bridge = gconf_bridge_get (); + settings = g_settings_new ("org.gnome.evolution.shell"); object = G_OBJECT (shell_window); - key = "/apps/evolution/shell/view_defaults/component_id"; - gconf_bridge_bind_property (bridge, key, object, "active-view"); + g_settings_bind (settings, "default-component-id", object, "active-view", G_SETTINGS_BIND_DEFAULT); object = G_OBJECT (priv->content_pane); - key = "/apps/evolution/shell/view_defaults/folder_bar/width"; - gconf_bridge_bind_property_delayed (bridge, key, object, "position"); + g_settings_bind (settings, "folder-bar-width", object, "position", G_SETTINGS_BIND_DEFAULT); object = G_OBJECT (shell_window); - key = "/apps/evolution/shell/view_defaults/sidebar_visible"; - gconf_bridge_bind_property (bridge, key, object, "sidebar-visible"); + g_settings_bind (settings, "sidebar-visible", object, "sidebar-visible", G_SETTINGS_BIND_DEFAULT); object = G_OBJECT (shell_window); - key = "/apps/evolution/shell/view_defaults/statusbar_visible"; - gconf_bridge_bind_property (bridge, key, object, "taskbar-visible"); + g_settings_bind (settings, "statusbar-visible", object, "taskbar-visible", G_SETTINGS_BIND_DEFAULT); if (e_shell_get_express_mode (shell)) { e_shell_window_set_switcher_visible (shell_window, FALSE); } else { object = G_OBJECT (shell_window); - key = "/apps/evolution/shell/view_defaults/buttons_visible"; - gconf_bridge_bind_property (bridge, key, object, "switcher-visible"); + g_settings_bind (settings, "buttons-visible", object, "switcher-visible", G_SETTINGS_BIND_DEFAULT); } object = G_OBJECT (shell_window); - key = "/apps/evolution/shell/view_defaults/toolbar_visible"; - gconf_bridge_bind_property (bridge, key, object, "toolbar-visible"); + g_settings_bind (settings, "toolbar-visible", object, "toolbar-visible", G_SETTINGS_BIND_DEFAULT); /* Configure the initial size and position of the window by way * of either a user-supplied geometry string or the last recorded @@ -465,8 +449,9 @@ e_shell_window_private_constructed (EShellWindow *shell_window) g_free (priv->geometry); priv->geometry = NULL; } else { + /* FIXME: how to bind this */ key = "/apps/evolution/shell/view_defaults/window"; - gconf_bridge_bind_window (bridge, key, window, TRUE, TRUE); + gconf_bridge_bind_window (gconf_bridge_get (), key, window, TRUE, TRUE); } shell_window_init_switcher_style (shell_window); @@ -476,6 +461,8 @@ e_shell_window_private_constructed (EShellWindow *shell_window) e_plugin_ui_enable_manager (ui_manager, id); gtk_application_add_window (GTK_APPLICATION (shell), window); + + g_object_unref (settings); } void diff --git a/shell/e-shell.c b/shell/e-shell.c index 1e8cd3c0f9..740bec8306 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -1430,18 +1430,13 @@ e_shell_create_shell_window (EShell *shell, /* EShellWindow initializes its active view from a GConf key, * so set the key ahead of time to control the intial view. */ if (view_name != NULL) { - GConfClient *client; + GSettings *settings; const gchar *key; - GError *error = NULL; - client = e_shell_get_gconf_client (shell); - key = "/apps/evolution/shell/view_defaults/component_id"; - gconf_client_set_string (client, key, view_name, &error); + settings = g_settings_new ("org.gnome.evolution.shell"); + g_settings_set_string (settings, "default-component-id", view_name); - if (error != NULL) { - g_warning ("%s", error->message); - g_error_free (error); - } + g_object_unref (settings); } shell_window = e_shell_window_new ( diff --git a/shell/main.c b/shell/main.c index bb056e3ded..7dc285ade3 100644 --- a/shell/main.c +++ b/shell/main.c @@ -52,8 +52,6 @@ #endif #endif -#include <gconf/gconf-client.h> - #include <libxml/xmlmemory.h> #include <libxml/parser.h> #include <libxml/tree.h> @@ -89,9 +87,6 @@ #define APPLICATION_ID "org.gnome.Evolution" -#define SKIP_WARNING_DIALOG_KEY \ - "/apps/evolution/shell/skip_warning_dialog" - /* STABLE_VERSION is only defined for development versions. */ #ifdef STABLE_VERSION #define DEVELOPMENT 1 @@ -350,31 +345,28 @@ static EShell * create_default_shell (void) { EShell *shell; - GConfClient *client; + GSettings *settings; GApplicationFlags flags; - const gchar *key; gboolean online = TRUE; gboolean is_meego = FALSE; gboolean small_screen = FALSE; GError *error = NULL; - client = gconf_client_get_default (); + settings = g_settings_new ("org.gnome.evolution.shell"); /* Requesting online or offline mode from the command-line * should be persistent, just like selecting it in the UI. */ - key = "/apps/evolution/shell/start_offline"; - if (start_online || force_online) { online = TRUE; - gconf_client_set_bool (client, key, FALSE, &error); + g_settings_set_boolean (settings, "start-offline", FALSE); } else if (start_offline) { online = FALSE; - gconf_client_set_bool (client, key, TRUE, &error); + g_settings_set_boolean (settings, "start-offline", TRUE); } else { gboolean value; - value = gconf_client_get_bool (client, key, &error); + value = g_settings_get_boolean (settings, "start-offline"); if (error == NULL) online = !value; } @@ -386,10 +378,8 @@ create_default_shell (void) /* Determine whether to run Evolution in "express" mode. */ - key = "/apps/evolution/shell/express_mode"; - if (!express_mode) - express_mode = gconf_client_get_bool (client, key, &error); + express_mode = g_settings_get_boolean (settings, "express-mode"); if (express_mode) e_shell_detect_meego (&is_meego, &small_screen); @@ -421,7 +411,7 @@ create_default_shell (void) if (force_online) e_shell_lock_network_available (shell); - g_object_unref (client); + g_object_unref (settings); return shell; } @@ -431,7 +421,7 @@ main (gint argc, gchar **argv) { EShell *shell; - GConfClient *client; + GSettings *settings; #ifdef DEVELOPMENT gboolean skip_warning_dialog; #endif @@ -591,22 +581,21 @@ main (gint argc, if (force_shutdown) shell_force_shutdown (); - client = gconf_client_get_default (); - if (disable_preview) { const gchar *key; - key = "/apps/evolution/mail/display/safe_list"; - gconf_client_set_bool (client, key, TRUE, NULL); - - key = "/apps/evolution/addressbook/display/show_preview"; - gconf_client_set_bool (client, key, FALSE, NULL); + settings = g_settings_new ("org.gnome.evolution.mail"); + g_settings_set_boolean (settings, "safe-list", TRUE); + g_object_unref (settings); - key = "/apps/evolution/calendar/display/show_memo_preview"; - gconf_client_set_bool (client, key, FALSE, NULL); + settings = g_settings_new ("org.gnome.evolution.addressbook"); + g_settings_set_boolean (settings, "show-preview", FALSE); + g_object_unref (settings); - key = "/apps/evolution/calendar/display/show_task_preview"; - gconf_client_set_bool (client, key, FALSE, NULL); + settings = g_settings_new ("org.gnome.evolution.calendar"); + g_settings_set_boolean (settings, "show-memo-preview", FALSE); + g_settings_set_boolean (settings, "show-task-preview", FALSE); + g_object_unref (settings); } #ifdef G_OS_UNIX @@ -638,16 +627,16 @@ main (gint argc, gtk_accel_map_load (e_get_accels_filename ()); #ifdef DEVELOPMENT - skip_warning_dialog = gconf_client_get_bool ( - client, SKIP_WARNING_DIALOG_KEY, NULL); + settings = g_settings_new ("org.gnome.evolution.shell"); + skip_warning_dialog = g_settings_get_boolean ( + settings, "skip-warning-dialog"); if (!skip_warning_dialog && !getenv ("EVOLVE_ME_HARDER")) - gconf_client_set_bool ( - client, SKIP_WARNING_DIALOG_KEY, - show_development_warning (), NULL); -#endif + g_settings_set_boolean ( + settings, "skip-warning-dialog"); - g_object_unref (client); + g_object_unref (settings); +#endif shell = create_default_shell (); |