[evolution/wip/gsettings: 6/22] More mail GSettings migration



commit b9eebfcb4f371ce3549264a97983b5f9cb6493df
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Wed Oct 19 11:46:15 2011 +0200

    More mail GSettings migration

 data/evolution.convert      |    4 +-
 mail/e-mail-reader.c        |   93 ++++++++++++++++++------------------------
 mail/em-folder-properties.c |   11 ++---
 mail/message-list.c         |   69 +++++++++++---------------------
 4 files changed, 69 insertions(+), 108 deletions(-)
---
diff --git a/data/evolution.convert b/data/evolution.convert
index 44fb9a8..ea70dc8 100644
--- a/data/evolution.convert
+++ b/data/evolution.convert
@@ -83,6 +83,8 @@ charset = /apps/evolution/mail/display/charset
 citation-colour = /apps/evolution/mail/display/citation_colour
 composer-charset = /apps/evolution/mail/composer/charset
 composer-current-folder = /apps/evolution/mail/composer/current_folder
+composer-height = /apps/evolution/mail/composer/height
+composer-ignore-list-reply-to = /apps/evolution/mail/composer/ignore_list_reply_to
 composer-inline-spelling = /apps/evolution/mail/composer/inline_spelling
 composer-magic-links = /apps/evolution/mail/composer/magic_links
 composer-magic-smileys = /apps/evolution/mail/composer/magic_smileys
@@ -101,8 +103,6 @@ composer-outlook-filenames = /apps/evolution/mail/composer/outlook_filenames
 composer-top-signature = /apps/evolution/mail/composer/top_signature
 composer-no-signature-delim = /apps/evolution/mail/composer/no_signature_delim
 composer-width = /apps/evolution/mail/composer/width
-composer-height = /apps/evolution/mail/composer/height
-composer-ignore-list-reply-to = /apps/evolution/mail/composer/ignore_list_reply_to
 default-account = /apps/evolution/mail/default_account
 enable-vfolders = /apps/evolution/mail/display/enable_vfolders
 error-level = /apps/evolution/mail/display/error_level
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 9209942..820fadf 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -36,7 +36,6 @@
 #include "e-util/e-charset.h"
 #include "e-util/e-util.h"
 #include "e-util/e-alert-dialog.h"
-#include "e-util/gconf-bridge.h"
 #include "shell/e-shell-utils.h"
 #include "widgets/misc/e-popup-action.h"
 #include "widgets/misc/e-menu-tool-action.h"
@@ -482,7 +481,7 @@ action_mail_flag_for_followup_cb (GtkAction *action,
 static gboolean
 get_close_browser_reader (EMailReader *reader)
 {
-	GConfClient *client;
+	GSettings *settings;
 	const gchar *key;
 	gchar *value;
 	gboolean close_it = FALSE;
@@ -491,10 +490,10 @@ get_close_browser_reader (EMailReader *reader)
 	if (!E_IS_MAIL_BROWSER (reader))
 		return FALSE;
 
-	client = gconf_client_get_default ();
+	settings = g_settings_new ("org.gnome.evolution.mail");
 
-	key = "/apps/evolution/mail/prompts/reply_close_browser";
-	value = gconf_client_get_string (client, key, NULL);
+	key = "prompt-on-reply-close-browser";
+	value = g_settings_get_string (settings, key);
 
 	if (value && g_str_equal (value, "always")) {
 		close_it = TRUE;
@@ -523,13 +522,13 @@ get_close_browser_reader (EMailReader *reader)
 		close_it = response == GTK_RESPONSE_YES || response == GTK_RESPONSE_OK;
 
 		if (response == GTK_RESPONSE_OK)
-			gconf_client_set_string (client, key, "always", NULL);
+			g_settings_set_string (settings, key, "always");
 		else if (response == GTK_RESPONSE_CANCEL)
-			gconf_client_set_string (client, key, "never", NULL);
+			g_settings_set_string (settings, key, "never");
 	}
 
 	g_free (value);
-	g_object_unref (client);
+	g_object_unref (settings);
 
 	return close_it;
 }
@@ -1189,13 +1188,11 @@ action_mail_reply_all_check (CamelFolder *folder,
 		response = gtk_dialog_run (GTK_DIALOG (dialog));
 
 		if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check))) {
-			GConfClient *client;
-			const gchar *key;
+			GSettings *settings;
 
-			client = gconf_client_get_default ();
-			key = "/apps/evolution/mail/prompts/reply_many_recips";
-			gconf_client_set_bool (client, key, FALSE, NULL);
-			g_object_unref (client);
+			settings = g_settings_new ("org.gnome.evolution.mail");
+			g_settings_set_boolean (settings, "prompt-on-reply-many-recips");
+			g_object_unref (settings);
 		}
 
 		gtk_widget_destroy (dialog);
@@ -1225,17 +1222,17 @@ static void
 action_mail_reply_all_cb (GtkAction *action,
                           EMailReader *reader)
 {
-	GConfClient *client;
+	GSettings *settings;
 	const gchar *key;
 	guint32 state;
 	gboolean ask;
 
 	state = e_mail_reader_check_state (reader);
 
-	client = gconf_client_get_default ();
-	key = "/apps/evolution/mail/prompts/reply_many_recips";
-	ask = gconf_client_get_bool (client, key, NULL);
-	g_object_unref (client);
+	settings = g_settings_new ("org.gnome.evolution.mail");
+	key = "prompt-on-reply-many-recips";
+	ask = g_settings_get_boolean (settings, key);
+	g_object_unref (settings);
 
 	if (ask && !(state & E_MAIL_READER_SELECTION_IS_MAILING_LIST)) {
 		EActivity *activity;
@@ -1275,17 +1272,15 @@ static void
 action_mail_reply_group_cb (GtkAction *action,
                             EMailReader *reader)
 {
-	GConfClient *client;
+	GSettings *settings;
 	gboolean reply_list;
-	const gchar *key;
 	guint32 state;
 
 	state = e_mail_reader_check_state (reader);
 
-	client = gconf_client_get_default ();
-	key = "/apps/evolution/mail/composer/group_reply_to_list";
-	reply_list = gconf_client_get_bool (client, key, NULL);
-	g_object_unref (client);
+	settings = g_settings_new ("org.gnome.evolution.mail");
+	reply_list = g_settings_get_boolean (settings, "composer-group-reply-to-list");
+	g_object_unref (settings);
 
 	if (reply_list && (state & E_MAIL_READER_SELECTION_IS_MAILING_LIST)) {
 		e_mail_reader_reply_to_message (
@@ -1311,7 +1306,7 @@ action_mail_reply_sender_check (CamelFolder *folder,
 	EAlertSink *alert_sink;
 	CamelMimeMessage *message;
 	EMailReplyType type = E_MAIL_REPLY_TO_SENDER;
-	GConfClient *client;
+	GSettings *settings;
 	const gchar *key;
 	gboolean ask_ignore_list_reply_to;
 	gboolean ask_list_reply_to;
@@ -1341,13 +1336,10 @@ action_mail_reply_sender_check (CamelFolder *folder,
 
 	g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
 
-	client = gconf_client_get_default ();
+	settings = g_settings_new ("org.gnome.evolution.mail");
 
-	key = "/apps/evolution/mail/composer/ignore_list_reply_to";
-	ask_ignore_list_reply_to = gconf_client_get_bool (client, key, NULL);
-
-	key = "/apps/evolution/mail/prompts/list_reply_to";
-	ask_list_reply_to = gconf_client_get_bool (client, key, NULL);
+	ask_ignore_list_reply_to = g_settings_get_boolean (settings, "composer-ignore-list-reply-to");
+	ask_list_reply_to = g_settings_get_boolean (settings, "prompt-on-list-reply-to");
 
 	munged_list_message = em_utils_is_munged_list_message (message);
 
@@ -1379,8 +1371,7 @@ action_mail_reply_sender_check (CamelFolder *folder,
 		active = gtk_toggle_button_get_active (
 			GTK_TOGGLE_BUTTON (check));
 		if (active) {
-			key = "/apps/evolution/mail/prompts/private_list_reply";
-			gconf_client_set_bool (client, key, FALSE, NULL);
+			g_settings_set_boolean (settings, "prompt-on-private-list-reply", FALSE);
 		}
 
 		gtk_widget_destroy (dialog);
@@ -1426,14 +1417,12 @@ action_mail_reply_sender_check (CamelFolder *folder,
 		active = gtk_toggle_button_get_active (
 			GTK_TOGGLE_BUTTON (check_again));
 		if (active) {
-			key = "/apps/evolution/mail/prompts/list_reply_to";
-			gconf_client_set_bool (client, key, FALSE, NULL);
+			g_settings_set_boolean (settings, "prompt-on-list-reply-to");
 		}
 
-		key = "/apps/evolution/mail/composer/ignore_list_reply_to";
 		active = gtk_toggle_button_get_active (
 			GTK_TOGGLE_BUTTON (check_always_ignore));
-		gconf_client_set_bool (client, key, active, NULL);
+		g_settings_set_boolean (settings, "composer-ignore-list-reply-to", active);
 
 		gtk_widget_destroy (dialog);
 
@@ -1456,7 +1445,7 @@ action_mail_reply_sender_check (CamelFolder *folder,
 	check_close_browser_reader (closure->reader);
 
 exit:
-	g_object_unref (client);
+	g_object_unref (settings);
 	g_object_unref (message);
 
 	mail_reader_closure_free (closure);
@@ -1466,7 +1455,7 @@ static void
 action_mail_reply_sender_cb (GtkAction *action,
                              EMailReader *reader)
 {
-	GConfClient *client;
+	GSettings *settings;
 	gboolean ask_list_reply_to;
 	gboolean ask_private_list_reply;
 	gboolean ask;
@@ -1475,12 +1464,10 @@ action_mail_reply_sender_cb (GtkAction *action,
 
 	state = e_mail_reader_check_state (reader);
 
-	client = gconf_client_get_default ();
-	key = "/apps/evolution/mail/prompts/list_reply_to";
-	ask_list_reply_to = gconf_client_get_bool (client, key, NULL);
-	key = "/apps/evolution/mail/prompts/private_list_reply";
-	ask_private_list_reply = gconf_client_get_bool (client, key, NULL);
-	g_object_unref (client);
+	settings = g_settings_new ("org.gnome.evolution.mail");
+	ask_list_reply_to = g_settings_get_boolean (settings, "prompt-on-list-reply-to");
+	ask_private_list_reply = g_settings_get_boolean (settings, "prompt-on-private-list-reply");
+	g_object_unref (settings);
 
 	ask = (ask_private_list_reply || ask_list_reply_to);
 
@@ -3392,7 +3379,7 @@ e_mail_reader_init (EMailReader *reader,
 	EWebView *web_view;
 	GtkActionGroup *action_group;
 	GtkWidget *message_list;
-	GConfBridge *bridge;
+	GSettings *settings;
 	GtkAction *action;
 	gboolean sensitive;
 	const gchar *action_name;
@@ -3477,19 +3464,19 @@ e_mail_reader_init (EMailReader *reader,
 		action_group, mail_reader_search_folder_entries,
 		G_N_ELEMENTS (mail_reader_search_folder_entries), reader);
 
-	/* Bind GObject properties to GConf keys. */
+	/* Bind GObject properties to GSettings keys. */
 
-	bridge = gconf_bridge_get ();
+	settings = g_settings_new ("org.gnome.evolution.mail");
 
 	action_name = "mail-caret-mode";
-	key = "/apps/evolution/mail/display/caret_mode";
 	action = e_mail_reader_get_action (reader, action_name);
-	gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active");
+	g_settings_bind (settings, "caret-mode", G_OBJECT (action), "active", G_SETTINGS_BIND_DEFAULT);
 
 	action_name = "mail-show-all-headers";
-	key = "/apps/evolution/mail/display/show_all_headers";
 	action = e_mail_reader_get_action (reader, action_name);
-	gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active");
+	g_settings_bind (settings, "show-all-headers", G_OBJECT (action), "active", G_SETTINGS_BIND_DEFAULT);
+
+	g_object_unref (settings);
 
 	/* Fine tuning. */
 
diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c
index 6e8e04c..6c8b97a 100644
--- a/mail/em-folder-properties.c
+++ b/mail/em-folder-properties.c
@@ -29,8 +29,6 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 
-#include <gconf/gconf-client.h>
-
 #include "em-folder-properties.h"
 #include "em-config.h"
 
@@ -254,7 +252,7 @@ emfp_dialog_run (AsyncContext *context)
 	CamelStore *local_store;
 	CamelStore *parent_store;
 	gboolean hide_deleted;
-	GConfClient *client;
+	GSettings *settings;
 	const gchar *name;
 	const gchar *key;
 
@@ -272,10 +270,9 @@ emfp_dialog_run (AsyncContext *context)
 	context->unread = camel_folder_summary_get_unread_count (context->folder->summary);
 	deleted = camel_folder_summary_get_deleted_count (context->folder->summary);
 
-	client = gconf_client_get_default ();
-	key = "/apps/evolution/mail/display/show_deleted";
-	hide_deleted = !gconf_client_get_bool (client, key, NULL);
-	g_object_unref (client);
+	settings = g_settings_new ("org.gnome.evolution.mail");
+	hide_deleted = !g_settings_get_boolean (settings, "show-deleted");
+	g_object_unref (settings);
 
 	/*
 	 * Do the calculation only for those accounts that support VTRASHes
diff --git a/mail/message-list.c b/mail/message-list.c
index 1e903a3..35071cf 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -36,8 +36,6 @@
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
 
-#include <gconf/gconf-client.h>
-
 #include "e-util/e-icon-factory.h"
 #include "e-util/e-poolv.h"
 #include "e-util/e-util-private.h"
@@ -1961,18 +1959,21 @@ filter_date (time_t date)
 static ECell * create_composite_cell (gint col)
 {
 	ECell *cell_vbox, *cell_hbox, *cell_sub, *cell_date, *cell_from, *cell_tree, *cell_attach;
-	GConfClient *client;
+	GSettings *settings;
 	gchar *fixed_name = NULL;
 	gboolean show_email;
 	gint alt_col = (col == COL_FROM) ? COL_SENDER : COL_RECIPIENTS;
 	gboolean same_font = FALSE;
 
-	client = gconf_client_get_default ();
-	show_email = gconf_client_get_bool (client, "/apps/evolution/mail/display/show_email", NULL);
-	same_font = gconf_client_get_bool (client, "/apps/evolution/mail/display/vertical_view_fonts", NULL);
-	if (!same_font)
-		fixed_name = gconf_client_get_string (client, "/desktop/gnome/interface/monospace_font_name", NULL);
-	g_object_unref (client);
+	settings = g_settings_new ("org.gnome.evolution.mail");
+	show_email = g_settings_get_boolean (settings, "show-email");
+	same_font = g_settings_get_boolean (settings, "vertical-view-fonts");
+	g_object_unref (settings);
+	if (!same_font) {
+		settings = g_settings_new ("org.gnome.desktop.interface");
+		fixed_name = g_settings_get_string (settings, "monospace-font-name");
+		g_object_unref (settings);
+	}
 
 	cell_vbox = e_cell_vbox_new ();
 
@@ -2830,34 +2831,13 @@ message_list_selectable_init (ESelectableInterface *interface)
 	interface->select_all = message_list_selectable_select_all;
 }
 
-static gboolean
-read_boolean_with_default (GConfClient *gconf,
-                           const gchar *key,
-                           gboolean def_value)
-{
-	GConfValue *value;
-	gboolean res;
-
-	g_return_val_if_fail (gconf != NULL, def_value);
-	g_return_val_if_fail (key != NULL, def_value);
-
-	value = gconf_client_get (gconf, key, NULL);
-	if (!value)
-		return def_value;
-
-	res = gconf_value_get_bool (value);
-	gconf_value_free (value);
-
-	return res;
-}
-
 static void
 message_list_construct (MessageList *message_list)
 {
 	AtkObject *a11y;
 	gboolean constructed;
 	gchar *etspecfile;
-	GConfClient *client;
+	GSettings *settings;
 
 	message_list->model =
 		e_tree_memory_callbacks_new (ml_tree_icon_at,
@@ -2883,15 +2863,13 @@ message_list_construct (MessageList *message_list)
 
 					     message_list);
 
-	client = gconf_client_get_default ();
+	settings = g_settings_new ("org.gnome.evolution.mail");
 	e_tree_memory_set_expanded_default (
 		E_TREE_MEMORY (message_list->model),
-		read_boolean_with_default (
-			client, "/apps/evolution/mail/display/thread_expand", TRUE));
+		g_settings_get_boolean (settings, "thread-expand"));
 	message_list->priv->thread_latest =
-		read_boolean_with_default (
-		client, "/apps/evolution/mail/display/thread_latest", TRUE);
-	g_object_unref (client);
+		g_settings_get_boolean (settings, "thread-latest"));
+	g_object_unref (settings);
 
 	/*
 	 * The etree
@@ -3902,7 +3880,7 @@ message_list_set_folder (MessageList *message_list,
 {
 	ETreeModel *etm = message_list->model;
 	gboolean hide_deleted;
-	GConfClient *client;
+	GSettings *settings;
 
 	g_return_if_fail (IS_MESSAGE_LIST (message_list));
 
@@ -3991,9 +3969,9 @@ message_list_set_folder (MessageList *message_list,
 			folder, "changed",
 			G_CALLBACK (folder_changed), message_list);
 
-		client = gconf_client_get_default ();
-		hide_deleted = !gconf_client_get_bool (client, "/apps/evolution/mail/display/show_deleted", NULL);
-		g_object_unref (client);
+		settings = g_settings_new ("org.gnome.evolution.mail");
+		hide_deleted = !g_settings_get_boolean (settings, "show-deleted");
+		g_object_unref (settings);
 
 		message_list->hidedeleted =
 			hide_deleted && non_trash_folder;
@@ -5035,7 +5013,7 @@ mail_regen_list (MessageList *ml,
                  gboolean scroll_to_cursor)
 {
 	struct _regen_list_msg *m;
-	GConfClient *client;
+	GSettings *settings;
 	const gchar *key;
 	gboolean thread_subject;
 
@@ -5053,10 +5031,9 @@ mail_regen_list (MessageList *ml,
 
 	mail_regen_cancel (ml);
 
-	client = gconf_client_get_default ();
-	key = "/apps/evolution/mail/display/thread_subject";
-	thread_subject = gconf_client_get_bool (client, key, NULL);
-	g_object_unref (client);
+	settings = g_settings_new ("org.gnome.evolution.mail");
+	thread_subject = g_settings_get_boolean (settings, "thread-subject");
+	g_object_unref (settings);
 
 #ifndef BROKEN_ETREE
 	/* this can sometimes crash,so ... */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]