aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@gnome-db.org>2011-11-02 00:26:07 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-11-02 00:26:07 +0800
commitfa4a42d741fade66d51857fb2653e27e347aef80 (patch)
treebbb26a574f30fea5fb4d7cfda0e62890ce71bf4c /modules
parentf31ecdfc22646e5c0b6979954cf5861a9fb68722 (diff)
downloadgsoc2013-evolution-fa4a42d741fade66d51857fb2653e27e347aef80.tar.gz
gsoc2013-evolution-fa4a42d741fade66d51857fb2653e27e347aef80.tar.zst
gsoc2013-evolution-fa4a42d741fade66d51857fb2653e27e347aef80.zip
Migrate SA extension to GSettings
Diffstat (limited to 'modules')
-rw-r--r--modules/mail/em-mailer-prefs.c115
-rw-r--r--modules/mail/em-mailer-prefs.h4
-rw-r--r--modules/spamassassin/evolution-spamassassin.c38
3 files changed, 68 insertions, 89 deletions
diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c
index 290e189e4b..b04c35b088 100644
--- a/modules/mail/em-mailer-prefs.c
+++ b/modules/mail/em-mailer-prefs.c
@@ -33,8 +33,6 @@
#include <gtkhtml/gtkhtml-properties.h>
#include <libxml/tree.h>
-#include <gconf/gconf-client.h>
-
#include "libedataserverui/e-cell-renderer-color.h"
#include <e-util/e-util.h>
@@ -106,13 +104,7 @@ em_mailer_prefs_finalize (GObject *object)
g_object_unref (prefs->builder);
- if (prefs->labels_change_notify_id) {
- gconf_client_notify_remove (prefs->gconf, prefs->labels_change_notify_id);
-
- prefs->labels_change_notify_id = 0;
- }
-
- g_object_unref (prefs->gconf);
+ g_object_unref (prefs->settings);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (em_mailer_prefs_parent_class)->finalize (object);
@@ -130,7 +122,7 @@ em_mailer_prefs_class_init (EMMailerPrefsClass *class)
static void
em_mailer_prefs_init (EMMailerPrefs *preferences)
{
- preferences->gconf = gconf_client_get_default ();
+ preferences->settings = g_settings_new ("org.gnome.evolution.mail");
}
enum {
@@ -142,13 +134,16 @@ static void
jh_tree_refill (EMMailerPrefs *prefs)
{
GtkListStore *store = prefs->junk_header_list_store;
- GSList *l, *cjh = gconf_client_get_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL);
+ gchar **strv;
+ gint i;
+
+ strv = g_settings_get_strv (prefs->settings, "junk-custom-header");
gtk_list_store_clear (store);
- for (l = cjh; l; l = l->next) {
+ for (i = 0; strv[i] != NULL; i++) {
GtkTreeIter iter;
- gchar **tokens = g_strsplit (l->data, "=", 2);
+ gchar **tokens = g_strsplit (strv[i], "=", 2);
gtk_list_store_append (store, &iter);
gtk_list_store_set (
@@ -159,8 +154,7 @@ jh_tree_refill (EMMailerPrefs *prefs)
g_strfreev (tokens);
}
- g_slist_foreach (cjh, (GFunc) g_free, NULL);
- g_slist_free (cjh);
+ g_strfreev (strv);
}
static void
@@ -191,7 +185,6 @@ jh_add_cb (GtkWidget *widget,
GtkBuilder *builder = gtk_builder_new ();
gchar *tok;
const gchar *name, *value;
- GSList *list;
e_load_ui_builder_definition (builder, "mail-config.ui");
dialog = e_builder_get_widget (builder, "add-custom-junk-header");
@@ -205,16 +198,24 @@ jh_add_cb (GtkWidget *widget,
G_CALLBACK (jh_dialog_entry_changed_cb), builder);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
+ gchar **strv;
+ GPtrArray *array;
+ gint i;
+
name = gtk_entry_get_text (GTK_ENTRY (e_builder_get_widget (builder, "junk-header-name")));
value = gtk_entry_get_text (GTK_ENTRY (e_builder_get_widget (builder, "junk-header-content")));
- list = gconf_client_get_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL);
+ strv = g_settings_get_strv (prefs->settings, "junk-custom-header");
+ array = g_ptr_array_new ();
+ for (i = 0; strv[i] != NULL; i++)
+ g_ptr_array_add (array, strv[i]);
tok = g_strdup_printf ("%s=%s", name, value);
- list = g_slist_append (list, tok);
- gconf_client_set_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, list, NULL);
+ g_ptr_array_add (array, tok);
+ g_ptr_array_add (array, NULL);
+ g_settings_set_strv (prefs->settings, "junk-custom-header", array->pdata);
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
+ g_ptr_array_free (array, TRUE);
+ g_strfreev (strv);
}
g_object_unref (builder);
@@ -237,38 +238,32 @@ jh_remove_cb (GtkWidget *widget,
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (prefs->junk_header_tree));
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
gchar *name = NULL, *value = NULL;
- GSList *prev = NULL, *node, *list = gconf_client_get_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL);
+ gchar **strv;
+ GPtrArray *array = g_ptr_array_new ();
+ gint i;
+
+ strv = g_settings_get_strv (prefs->settings, "junk-custom-header");
gtk_tree_model_get (model, &iter, JH_LIST_COLUMN_NAME, &name, JH_LIST_COLUMN_VALUE, &value, -1);
- node = list;
- while (node) {
+ for (i = 0; strv[i] != NULL; i++) {
gchar *test;
gint len = strlen (name);
- test = strncmp (node->data, name, len) == 0 ? (gchar *) node->data + len : NULL;
+ test = strncmp (strv[i], name, len) == 0 ? (gchar *) strv[i] + len : NULL;
if (test) {
test++;
if (strcmp (test, value) == 0)
- break;
+ continue;
}
- prev = node;
- node = node->next;
+ g_ptr_array_add (array, strv[i]);
}
- if (prev && !node) {
- /* Not found. So what? */
- } else if (prev && node) {
- prev->next = node->next;
- g_free (node->data);
- } else if (!prev && node) {
- list = list->next;
- g_free (node->data);
- }
+ g_ptr_array_add (array, NULL);
- gconf_client_set_list (prefs->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, list, NULL);
+ g_settings_set_strv (prefs->settings, "junk-custom-header", array->pdata);
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
+ g_strfreev (strv);
+ g_ptr_array_free (array, TRUE);
g_free (name);
g_free (value);
@@ -494,7 +489,7 @@ toggle_button_toggled (GtkToggleButton *toggle,
const gchar *key;
key = g_object_get_data ((GObject *) toggle, "key");
- gconf_client_set_bool (prefs->gconf, key, gtk_toggle_button_get_active (toggle), NULL);
+ g_settings_set_boolean (prefs->settings, key, gtk_toggle_button_get_active (toggle));
}
static void
@@ -531,7 +526,7 @@ toggle_button_init (EMMailerPrefs *prefs,
{
gboolean bool;
- bool = gconf_client_get_bool (prefs->gconf, key, NULL);
+ bool = g_settings_get_boolean (prefs->settings, key);
gtk_toggle_button_set_active (toggle, not ? !bool : bool);
if (toggled) {
@@ -539,7 +534,7 @@ toggle_button_init (EMMailerPrefs *prefs,
g_signal_connect (toggle, "toggled", toggled, prefs);
}
- if (!gconf_client_key_is_writable (prefs->gconf, key, NULL))
+ if (!g_settings_is_writable (prefs->settings, key)
gtk_widget_set_sensitive ((GtkWidget *) toggle, FALSE);
}
@@ -553,10 +548,10 @@ trash_days_changed (GtkComboBox *combo_box,
g_return_if_fail (index >= 0);
g_return_if_fail (index < G_N_ELEMENTS (empty_trash_frequency));
- gconf_client_set_int (
- prefs->gconf,
- "/apps/evolution/mail/trash/empty_on_exit_days",
- empty_trash_frequency[index].days, NULL);
+ g_settings_set_int (
+ prefs->settings,
+ "trash-empty-on-exit-days",
+ empty_trash_frequency[index].days);
}
static void
@@ -567,9 +562,9 @@ emmp_empty_trash_init (EMMailerPrefs *prefs,
GtkListStore *store;
GtkTreeIter iter;
- days = gconf_client_get_int (
- prefs->gconf,
- "/apps/evolution/mail/trash/empty_on_exit_days", NULL);
+ days = g_settings_get_int (
+ prefs->settings,
+ "trash-empty-on-exit-days");
store = GTK_LIST_STORE (gtk_combo_box_get_model (combo_box));
gtk_list_store_clear (store);
@@ -601,10 +596,10 @@ junk_days_changed (GtkComboBox *combo_box,
g_return_if_fail (index >= 0);
g_return_if_fail (index < G_N_ELEMENTS (empty_trash_frequency));
- gconf_client_set_int (
- prefs->gconf,
- "/apps/evolution/mail/junk/empty_on_exit_days",
- empty_trash_frequency[index].days, NULL);
+ g_settings_set_int (
+ prefs->settings,
+ "junk-empty-on-exit-days",
+ empty_trash_frequency[index].days);
}
static void
@@ -615,9 +610,9 @@ emmp_empty_junk_init (EMMailerPrefs *prefs,
GtkListStore *store;
GtkTreeIter iter;
- days = gconf_client_get_int (
- prefs->gconf,
- "/apps/evolution/mail/junk/empty_on_exit_days", NULL);
+ days = g_settings_get_int (
+ prefs->settings,
+ "junk-empty-on-exit-days");
store = GTK_LIST_STORE (gtk_combo_box_get_model (combo_box));
gtk_list_store_clear (store);
@@ -652,7 +647,7 @@ http_images_changed (GtkWidget *widget,
else
policy = E_MAIL_IMAGE_LOADING_POLICY_NEVER;
- gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/display/load_http_images", policy, NULL);
+ g_settings_set_int (prefs->settings, "load-http-images", policy);
}
static GtkWidget *
@@ -870,9 +865,9 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs,
/* HTML Mail tab */
/* Loading Images */
- locked = !gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/load_http_images", NULL);
+ locked = !g_settings_is_writable (prefs->settings, "load-http-images");
- val = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/display/load_http_images", NULL);
+ val = g_settings_get_int (prefs->settings, "load-http-images");
prefs->images_never = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "radImagesNever"));
gtk_toggle_button_set_active (prefs->images_never, val == E_MAIL_IMAGE_LOADING_POLICY_NEVER);
if (locked)
diff --git a/modules/mail/em-mailer-prefs.h b/modules/mail/em-mailer-prefs.h
index 35ebec3bf7..eee2d248ac 100644
--- a/modules/mail/em-mailer-prefs.h
+++ b/modules/mail/em-mailer-prefs.h
@@ -24,7 +24,6 @@
#define EM_MAILER_PREFS_H
#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
#include <shell/e-shell.h>
#include <widgets/misc/e-preferences-window.h>
@@ -56,7 +55,7 @@ struct _EMMailerPrefs {
GtkVBox parent_object;
GtkBuilder *builder;
- GConfClient *gconf;
+ GSettings *settings;
/* General tab */
@@ -81,7 +80,6 @@ struct _EMMailerPrefs {
GtkWidget *label_remove;
GtkWidget *label_tree;
GtkListStore *label_list_store;
- guint labels_change_notify_id; /* mail_config's notify id */
/* Headers tab */
GtkButton *add_header;
diff --git a/modules/spamassassin/evolution-spamassassin.c b/modules/spamassassin/evolution-spamassassin.c
index b578acf228..a628753aba 100644
--- a/modules/spamassassin/evolution-spamassassin.c
+++ b/modules/spamassassin/evolution-spamassassin.c
@@ -25,7 +25,6 @@
#include <shell/e-shell.h>
#include <e-util/e-mktemp.h>
-#include <e-util/gconf-bridge.h>
#include <mail/e-mail-junk-filter.h>
/* Standard GObject macros */
@@ -1074,7 +1073,7 @@ e_spam_assassin_class_init (ESpamAssassinClass *class)
junk_filter_class->available = spam_assassin_available;
junk_filter_class->new_config_widget = spam_assassin_new_config_widget;
- /* XXX Argh, the boolean sense of the GConf key is inverted from
+ /* XXX Argh, the boolean sense of the GSettings key is inverted from
* that of the checkbox widget. The checkbox wording is more
* natural, but GConfBridge doesn't support transform functions
* so the property has to match the sense of the GConf key. */
@@ -1146,36 +1145,23 @@ e_spam_assassin_interface_init (CamelJunkFilterInterface *interface)
static void
e_spam_assassin_init (ESpamAssassin *extension)
{
+ GSettings *settings;
+
extension->socket_path_mutex = g_mutex_new ();
/* XXX Once we move to GSettings these probably don't
* need to be properties anymore. GConfBridge is
* just easier to deal with than GConfClient. */
- gconf_bridge_bind_property (
- gconf_bridge_get (),
- "/apps/evolution/mail/junk/sa/local_only",
- G_OBJECT (extension), "local-only");
-
- gconf_bridge_bind_property (
- gconf_bridge_get (),
- "/apps/evolution/mail/junk/sa/spamc_binary",
- G_OBJECT (extension), "spamc-binary");
-
- gconf_bridge_bind_property (
- gconf_bridge_get (),
- "/apps/evolution/mail/junk/sa/spamd_binary",
- G_OBJECT (extension), "spamd-binary");
-
- gconf_bridge_bind_property (
- gconf_bridge_get (),
- "/apps/evolution/mail/junk/sa/socket_path",
- G_OBJECT (extension), "socket-path");
-
- gconf_bridge_bind_property (
- gconf_bridge_get (),
- "/apps/evolution/mail/junk/sa/use_daemon",
- G_OBJECT (extension), "use-daemon");
+ settings = g_settings_new ("org.gnome.evolution.mail");
+
+ g_settings_bind (settings, "junk-sa-local-only", G_OBJECT (extension), "local-only", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (settings, "junk-sa-spamc-binary", G_OBJECT (extension), "spamc-binary", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (settings, "junk-sa-spamd-binary", G_OBJECT (extension), "spamd-binary", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (settings, "junk-sa-socjet-path", G_OBJECT (extension), "socket-path", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (settings, "junk-sa-use-daemon", G_OBJECT (extension), "use-daemon", G_SETTINGS_BIND_DEFAULT);
+
+ g_object_unref (settings);
if (extension->spamc_binary == NULL)
extension->spamc_binary = g_strdup (SPAMC_BINARY);