aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@gnome-db.org>2011-10-26 23:54:50 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-10-26 23:54:50 +0800
commit9744056c5e69227abdcdd55c4bffb674b29bd765 (patch)
treed0b54f23e6fd42a2887f01af3bb41f5c2552fa67
parent8d001181fbaf1350764e75c28f61e1ae3498dbb3 (diff)
downloadgsoc2013-evolution-9744056c5e69227abdcdd55c4bffb674b29bd765.tar
gsoc2013-evolution-9744056c5e69227abdcdd55c4bffb674b29bd765.tar.gz
gsoc2013-evolution-9744056c5e69227abdcdd55c4bffb674b29bd765.tar.bz2
gsoc2013-evolution-9744056c5e69227abdcdd55c4bffb674b29bd765.tar.lz
gsoc2013-evolution-9744056c5e69227abdcdd55c4bffb674b29bd765.tar.xz
gsoc2013-evolution-9744056c5e69227abdcdd55c4bffb674b29bd765.tar.zst
gsoc2013-evolution-9744056c5e69227abdcdd55c4bffb674b29bd765.zip
More GSettings migration
-rw-r--r--mail/e-mail-browser.c10
-rw-r--r--mail/e-mail-label-list-store.c105
-rw-r--r--mail/em-composer-utils.c21
3 files changed, 110 insertions, 26 deletions
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index fe8b8984f3..aaa12b1d14 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -550,7 +550,7 @@ mail_browser_constructed (GObject *object)
EShell *shell;
EFocusTracker *focus_tracker;
ESearchBar *search_bar;
- GConfBridge *bridge;
+ GSettings *settings;
GtkAccelGroup *accel_group;
GtkActionGroup *action_group;
GtkAction *action;
@@ -710,13 +710,13 @@ mail_browser_constructed (GObject *object)
search_bar, "changed",
G_CALLBACK (em_format_queue_redraw), priv->formatter);
- /* Bind GObject properties to GConf keys. */
+ /* Bind GObject properties to GSettings keys. */
- bridge = gconf_bridge_get ();
+ settings = g_settings_new ("org.gnome.evolution.mail");
object = G_OBJECT (reader);
- key = "/apps/evolution/mail/display/show_deleted";
- gconf_bridge_bind_property (bridge, key, object, "show-deleted");
+ g_settings_bind (settings, "show-deleted", object, "show-deleted", G_SETTINGS_BIND_DEFAULT);
+ g_object_unref (settings);
id = "org.gnome.evolution.mail.browser";
e_plugin_ui_register_manager (ui_manager, id, object);
diff --git a/mail/e-mail-label-list-store.c b/mail/e-mail-label-list-store.c
index f604893bb3..e9f9c4b509 100644
--- a/mail/e-mail-label-list-store.c
+++ b/mail/e-mail-label-list-store.c
@@ -27,10 +27,10 @@
#include <glib/gi18n.h>
#include <camel/camel.h>
-#include "e-util/gconf-bridge.h"
struct _EMailLabelListStorePrivate {
GHashTable *tag_index;
+ GSettings *mail_settings;
};
static struct {
@@ -160,24 +160,107 @@ mail_label_list_store_finalize (GObject *object)
priv = E_MAIL_LABEL_LIST_STORE (object)->priv;
g_hash_table_destroy (priv->tag_index);
+ if (priv->mail_settings != NULL) {
+ g_object_unref (priv->mail_settings);
+ priv->mail_settings = NULL;
+ }
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
+
+static void labels_settings_changed_cb (GSettings *settings, const gchar *key, gpointer user_data);
+
+static void
+labels_model_changed_cb (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ EMailLabelListStore *store;
+ GtkTreeIter iter;
+ GPtrArray *array;
+ gboolean res;
+
+ store = E_MAIL_LABEL_LIST_STORE (user_data);
+
+ /* Make sure we don't enter an infinite synchronizing loop */
+ g_signal_handlers_block_by_func (store->priv->mail_settings, labels_settings_changed_cb, store);
+
+ /* Build list to store in GSettings */
+ array = g_ptr_array_new ();
+ res = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
+ while (res) {
+ gchar *string;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
+ 0, &string, -1);
+ g_ptr_array_add (array, string);
+
+ res = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
+ }
+
+ g_ptr_array_add (array, NULL);
+ g_settings_set_strv (store->priv->mail_settings, "labels", array->pdata);
+
+ g_ptr_array_free (array, TRUE);
+ g_signal_handlers_unblock_by_func (store->priv->mail_settings, labels_settings_changed_cb, store);
+}
+
+static void
+labels_settings_changed_cb (GSettings *settings,
+ const gchar *key,
+ gpointer user_data)
+{
+ EMailLabelListStore *store;
+ gchar **strv;
+ gint i;
+
+ store = E_MAIL_LABEL_LIST_STORE (user_data);
+
+ /* Make sure we don't enter an infinite synchronizing loop */
+ g_signal_handlers_block_by_func (store, labels_model_changed_cb, store);
+
+ gtk_list_store_clear (GTK_LIST_STORE (store));
+
+ strv = g_settings_get_strv (store->priv->mail_settings, "labels");
+ for (i = 0; strv[i] != NULL; i++) {
+ GtkTreeIter iter;
+
+ gtk_list_store_insert_with_values (GTK_LIST_STORE (store),
+ &iter, -1,
+ 0, strv[i],
+ -1);
+ }
+
+ g_strfreev (strv);
+
+ g_signal_handlers_unblock_by_func (store, labels_model_changed_cb, store);
+}
+
static void
mail_label_list_store_constructed (GObject *object)
{
EMailLabelListStore *store;
- GConfBridge *bridge;
- const gchar *key;
store = E_MAIL_LABEL_LIST_STORE (object);
- bridge = gconf_bridge_get ();
- key = "/apps/evolution/mail/labels";
- gconf_bridge_bind_string_list_store (
- bridge, key, GTK_LIST_STORE (store));
+ /* Connect to GSettings' change notifications */
+ store->priv->mail_settings = g_settings_new ("org.gnome.evolution.mail");
+ g_signal_connect (store->priv->mail_settings, "changed::labels",
+ G_CALLBACK (labels_settings_changed_cb), store);
+ labels_settings_changed_cb (store->priv->mail_settings, "labels", store);
+
+ /* Connect to ListStore change notifications */
+ g_signal_connect (store, "row-inserted",
+ G_CALLBACK (labels_model_changed_cb), store);
+ g_signal_connect (store, "row-changed",
+ G_CALLBACK (labels_model_changed_cb), store);
+ g_signal_connect (store, "row-deleted",
+ G_CALLBACK (labels_model_changed_cb), store);
+ g_signal_connect (store, "rows-reordered",
+ G_CALLBACK (labels_model_changed_cb), store);
mail_label_list_store_ensure_defaults (store);
@@ -245,10 +328,10 @@ mail_label_list_store_init (EMailLabelListStore *store)
/* XXX While it may seem awkward to cram the label name and color
* into a single string column, we do it for the benefit of
- * letting GConfBridge keep the model in sync with GConf.
+ * letting GSettings keep the model in sync.
*
* XXX There's a valid argument to be made that this information
- * doesn't belong in GConf in the first place. A key file
+ * doesn't belong in GSettings in the first place. A key file
* under $(user_data_dir)/mail would work better. */
gtk_list_store_set_column_types (GTK_LIST_STORE (store), 1, &type);
}
@@ -404,7 +487,7 @@ e_mail_label_list_store_get_tag (EMailLabelListStore *store,
strv = g_strsplit_set (encoded, ":|", 3);
/* XXX I guess for historical reasons the default label tags have
- * a "$Label" prefix, but the default list in GConf doesn't
+ * a "$Label" prefix, but the default list in GSettings doesn't
* include tags. That's why the <tag> part is optional.
* So if we're missing the <tag> part, look it up in the
* hard-coded default list above.
@@ -431,7 +514,7 @@ e_mail_label_list_store_get_tag (EMailLabelListStore *store,
}
}
- /* XXX Still no luck? The label list in GConf must be screwed up.
+ /* XXX Still no luck? The label list in GSettings must be screwed up.
* We must not return NULL because the tag is used as a key in
* the index hash table, so generate a tag from the name. */
if (result == NULL)
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index eacf61b90f..06db108b8e 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -69,9 +69,6 @@
#define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
#endif
-#define GCONF_KEY_TEMPLATE_PLACEHOLDERS \
- "/apps/evolution/mail/template_placeholders"
-
typedef struct _AsyncContext AsyncContext;
typedef struct _ForwardData ForwardData;
@@ -1261,15 +1258,19 @@ em_utils_edit_message (EShell *shell,
/* Template specific code follows. */
if (folder_is_templates) {
CamelDataWrapper *content;
- GConfClient *gconf;
+ GSettings *settings;
+ gchar **strv;
+ gint i;
GSList *clue_list = NULL;
- gconf = gconf_client_get_default ();
- /* Get the list from gconf */
- clue_list = gconf_client_get_list (
- gconf, GCONF_KEY_TEMPLATE_PLACEHOLDERS,
- GCONF_VALUE_STRING, NULL );
- g_object_unref (gconf);
+ settings = g_settings_new ("org.gnome.evolution.eplugin.templates");
+
+ /* Get the list from GSettings */
+ strv = g_settings_get_strv (settings, "template-placeholders");
+ for (i = 0; strv[i] != NULL; i++)
+ clue_list = g_slist_append (clue_list, g_strdup (strv[i]));
+ g_object_unref (settings);
+ g_strfreev (strv);
content = camel_medium_get_content (CAMEL_MEDIUM (message));
traverse_parts (clue_list, message, content);