aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-11-22 23:18:51 +0800
committerMilan Crha <mcrha@redhat.com>2012-11-22 23:18:51 +0800
commitdd958f0120603d87e2c8b3250b742d53230f2780 (patch)
tree0eb308d0a44be64aee97fa8882779c6ad465dd61
parentd7d54dffc8b746548e888e00f1c06eb2ccdc2a53 (diff)
downloadgsoc2013-evolution-dd958f0120603d87e2c8b3250b742d53230f2780.tar.gz
gsoc2013-evolution-dd958f0120603d87e2c8b3250b742d53230f2780.tar.zst
gsoc2013-evolution-dd958f0120603d87e2c8b3250b742d53230f2780.zip
Bug #202576 - A way to refresh IMAP folder list
-rw-r--r--modules/mail/e-mail-shell-view-actions.c63
-rw-r--r--modules/mail/e-mail-shell-view-actions.h2
-rw-r--r--modules/mail/e-mail-shell-view.c4
-rw-r--r--ui/evolution-mail.ui1
4 files changed, 70 insertions, 0 deletions
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index 123352b181..1d39ad7cd2 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -125,6 +125,58 @@ action_mail_account_properties_cb (GtkAction *action,
}
static void
+account_refresh_folder_info_received_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ CamelStore *store;
+ CamelFolderInfo *info;
+ EActivity *activity;
+ GError *error = NULL;
+
+ store = CAMEL_STORE (source);
+ activity = user_data;
+ info = camel_store_get_folder_info_finish (store, result, &error);
+ if (info) {
+ /* provider takes care of notifications of new/removed folders,
+ thus it's enough to free the returned list */
+ camel_store_free_folder_info (store, info);
+ }
+
+ if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_message ("%s: Failed: %s", G_STRFUNC, error->message);
+
+ g_clear_error (&error);
+
+ if (activity)
+ g_object_unref (activity);
+}
+
+static void
+action_mail_account_refresh_cb (GtkAction *action,
+ EMailShellView *mail_shell_view)
+{
+ EMailShellSidebar *mail_shell_sidebar;
+ EMFolderTree *folder_tree;
+ EMailReader *reader;
+ EActivity *activity;
+ CamelStore *store;
+ GCancellable *cancellable;
+
+ mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
+ folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+ store = em_folder_tree_get_selected_store (folder_tree);
+ g_return_if_fail (store != NULL);
+
+ reader = E_MAIL_READER (e_mail_shell_content_get_mail_view (mail_shell_view->priv->mail_shell_content));
+ activity = e_mail_reader_new_activity (reader);
+ cancellable = e_activity_get_cancellable (activity);
+
+ camel_store_get_folder_info (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE,
+ G_PRIORITY_DEFAULT, cancellable, account_refresh_folder_info_received_cb, activity);
+}
+
+static void
action_mail_create_search_folder_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
@@ -1242,6 +1294,13 @@ static GtkActionEntry mail_entries[] = {
N_("Edit properties of this account"),
G_CALLBACK (action_mail_account_properties_cb) },
+ { "mail-account-refresh",
+ GTK_STOCK_REFRESH,
+ N_("_Refresh"),
+ NULL,
+ N_("Refresh list of folders of this account"),
+ G_CALLBACK (action_mail_account_refresh_cb) },
+
{ "mail-download",
NULL,
N_("_Download Messages for Offline Usage"),
@@ -1505,6 +1564,10 @@ static EPopupActionEntry mail_popup_entries[] = {
NULL,
"mail-account-expunge" },
+ { "mail-popup-account-refresh",
+ NULL,
+ "mail-account-refresh" },
+
{ "mail-popup-account-properties",
NULL,
"mail-account-properties" },
diff --git a/modules/mail/e-mail-shell-view-actions.h b/modules/mail/e-mail-shell-view-actions.h
index d3197dde90..ff0829b662 100644
--- a/modules/mail/e-mail-shell-view-actions.h
+++ b/modules/mail/e-mail-shell-view-actions.h
@@ -31,6 +31,8 @@
E_SHELL_WINDOW_ACTION ((window), "mail-account-expunge")
#define E_SHELL_WINDOW_ACTION_MAIL_ACCOUNT_PROPERTIES(window) \
E_SHELL_WINDOW_ACTION ((window), "mail-account-properties")
+#define E_SHELL_WINDOW_ACTION_MAIL_ACCOUNT_REFRESH(window) \
+ E_SHELL_WINDOW_ACTION ((window), "mail-account-refresh")
#define E_SHELL_WINDOW_ACTION_MAIL_ADD_SENDER(window) \
E_SHELL_WINDOW_ACTION ((window), "mail-add-sender")
#define E_SHELL_WINDOW_ACTION_MAIL_CARET_MODE(window) \
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 42cb277d11..419ad3edb3 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -944,6 +944,10 @@ mail_shell_view_update_actions (EShellView *shell_view)
sensitive = folder_is_store && !store_is_builtin;
gtk_action_set_sensitive (action, sensitive);
+ action = ACTION (MAIL_ACCOUNT_REFRESH);
+ sensitive = folder_is_store;
+ gtk_action_set_sensitive (action, sensitive);
+
action = ACTION (MAIL_FLUSH_OUTBOX);
sensitive = folder_is_outbox;
gtk_action_set_sensitive (action, sensitive);
diff --git a/ui/evolution-mail.ui b/ui/evolution-mail.ui
index 83490ba883..e191a624a4 100644
--- a/ui/evolution-mail.ui
+++ b/ui/evolution-mail.ui
@@ -93,6 +93,7 @@
<menuitem action='mail-popup-folder-rename'/>
<menuitem action='mail-popup-folder-refresh'/>
<menuitem action='mail-popup-flush-outbox'/>
+ <menuitem action='mail-popup-account-refresh'/>
<menuitem action='mail-popup-manage-subscriptions'/>
<menuitem action='mail-popup-account-expunge'/>
<menuitem action='mail-popup-account-disable'/>