From 5b21823d0e5c5a6ad927a180fb9aa8b9419f6612 Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Tue, 27 Apr 2010 16:48:51 +0530 Subject: Listen for account added signal from the EAccountList. Helps to refresh account while loading from the capplet externally. --- mail/em-folder-tree-model.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 3daacc52c5..b779caf63a 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -37,10 +37,13 @@ #include +#include "e-mail-store.h" + #include "mail-config.h" #include "mail-session.h" #include "mail-tools.h" #include "mail-mt.h" +#include "mail-ops.h" /* sigh, these 2 only needed for outbox total count checking - a mess */ #include "mail-folder-cache.h" @@ -80,6 +83,7 @@ struct _EMFolderTreeModelPrivate { gulong account_changed_id; gulong account_removed_id; + gulong account_added_id; }; enum { @@ -256,6 +260,26 @@ account_removed_cb (EAccountList *accounts, em_folder_tree_model_remove_store (model, si->store); } +/* HACK: FIXME: the component should listen to the account object directly */ +static void +add_new_store (gchar *uri, CamelStore *store, gpointer user_data) +{ + EAccount *account = user_data; + + if (store == NULL) + return; + + e_mail_store_add (store, account->name); +} + +static void +account_added_cb (EAccountList *accounts, + EAccount *account, + EMFolderTreeModel *model) +{ + mail_get_store (e_account_get_string (account, E_ACCOUNT_SOURCE_URL), NULL, add_new_store, account); +} + static void folder_tree_model_selection_finalized_cb (EMFolderTreeModel *model) { @@ -332,6 +356,8 @@ folder_tree_model_finalize (GObject *object) priv->accounts, priv->account_changed_id); g_signal_handler_disconnect ( priv->accounts, priv->account_removed_id); + g_signal_handler_disconnect ( + priv->accounts, priv->account_added_id); /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (parent_class)->finalize (object); @@ -512,6 +538,9 @@ folder_tree_model_init (EMFolderTreeModel *model) model->priv->account_removed_id = g_signal_connect ( model->priv->accounts, "account-removed", G_CALLBACK (account_removed_cb), model); + model->priv->account_added_id = g_signal_connect ( + model->priv->accounts, "account-added", + G_CALLBACK (account_added_cb), model); g_signal_connect (mail_folder_cache_get_default (), "folder-unread-updated", -- cgit v1.2.3