[evolution] EMailShellView: Open the selected folder ourselves.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EMailShellView: Open the selected folder ourselves.
- Date: Tue, 3 May 2011 01:35:33 +0000 (UTC)
commit ae28ea4621c9ced08524548ca67a5297c284ce01
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon May 2 21:01:48 2011 -0400
EMailShellView: Open the selected folder ourselves.
This one's a little involved:
- EMailShellView now obtains a CamelFolder itself in response to
EMFolderTree::folder-selected signals. Uses EActivity to do so.
- Revise EMFolderTree::folder-selected signal arguments to be more
useful: emit a CamelStore object instead of a folder URI.
- Also revise EMFolderTree::folder-activiated signal arguments the
same way while we're at it.
- Remove the "folder_uri" argument from e_mail_reader_set_folder().
If you have a CamelFolder object you can obtain the URI string by
calling camel_folder_get_uri().
e-util/e-marshal.list | 2 +-
mail/e-mail-notebook-view.c | 14 ++--
mail/e-mail-paned-view.c | 7 +-
mail/e-mail-reader-utils.c | 2 +-
mail/e-mail-reader.c | 22 +++---
mail/e-mail-reader.h | 6 +-
mail/em-folder-selector.c | 14 +++-
mail/em-folder-tree.c | 49 +++++++------
mail/em-folder-tree.h | 10 +-
mail/mail.error.xml | 6 ++
modules/mail/e-mail-shell-backend.c | 2 +-
modules/mail/e-mail-shell-content.c | 5 +-
modules/mail/e-mail-shell-view-private.c | 119 +++++++++++++++++++++++++++---
modules/mail/e-mail-shell-view-private.h | 3 +
modules/mail/e-mail-shell-view.c | 22 ++----
15 files changed, 194 insertions(+), 89 deletions(-)
---
diff --git a/e-util/e-marshal.list b/e-util/e-marshal.list
index d4e6f43..7cdfc09 100644
--- a/e-util/e-marshal.list
+++ b/e-util/e-marshal.list
@@ -43,6 +43,7 @@ NONE:OBJECT,STRING
NONE:OBJECT,STRING,INT
NONE:OBJECT,STRING,STRING
NONE:OBJECT,STRING,STRING,INT,STRING,STRING,STRING
+NONE:OBJECT,STRING,UINT
NONE:POINTER,INT
NONE:POINTER,INT,INT,INT,INT
NONE:POINTER,INT,OBJECT
@@ -53,6 +54,5 @@ NONE:STRING,DOUBLE
NONE:STRING,INT,INT
NONE:STRING,POINTER,POINTER
NONE:STRING,STRING
-NONE:STRING,STRING,UINT
NONE:UINT,STRING
STRING:NONE
diff --git a/mail/e-mail-notebook-view.c b/mail/e-mail-notebook-view.c
index bd92b52..d5a7965 100644
--- a/mail/e-mail-notebook-view.c
+++ b/mail/e-mail-notebook-view.c
@@ -981,7 +981,7 @@ mail_netbook_view_open_mail (EMailView *view,
E_MAIL_READER (pane), "folder-loaded",
G_CALLBACK (reconnect_folder_loaded_event), nview);
e_mail_reader_set_folder (
- E_MAIL_READER (pane), folder, folder_uri);
+ E_MAIL_READER (pane), folder);
e_mail_reader_set_group_by_threads (
E_MAIL_READER (pane),
e_mail_reader_get_group_by_threads (E_MAIL_READER (view)));
@@ -1078,22 +1078,23 @@ build_histogram (GtkWidget *widget, CamelFolder *folder)
static void
mail_notebook_view_set_folder (EMailReader *reader,
- CamelFolder *folder,
- const gchar *folder_uri)
+ CamelFolder *folder)
{
EMailNotebookViewPrivate *priv;
GtkWidget *new_view;
+ const gchar *folder_uri;
#if HAVE_CLUTTER
EMailTab *tab;
ClutterActor *clone;
ClutterTimeline *timeline;
#endif
- if (!folder_uri)
+ if (folder == NULL)
return;
priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv;
+ folder_uri = camel_folder_get_uri (folder);
new_view = g_hash_table_lookup (priv->views, folder_uri);
if (new_view) {
gint curr = emnv_get_page_num (E_MAIL_NOTEBOOK_VIEW (reader), new_view);
@@ -1123,7 +1124,8 @@ mail_notebook_view_set_folder (EMailReader *reader,
return;
}
- if (folder || folder_uri) {
+ /* FIXME Redundant NULL check. */
+ if (folder != NULL) {
gint page;
#if HAVE_CLUTTER
GtkWidget *list;
@@ -1221,7 +1223,7 @@ mail_notebook_view_set_folder (EMailReader *reader,
g_object_set_data ((GObject *)list, "actor", priv->actor);
#endif
- e_mail_reader_set_folder (E_MAIL_READER (priv->current_view), folder, folder_uri);
+ e_mail_reader_set_folder (E_MAIL_READER (priv->current_view), folder);
g_hash_table_insert (priv->views, g_strdup (folder_uri), priv->current_view);
g_signal_connect (
priv->current_view, "changed",
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index c1e4cc4..62d3e67 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -456,8 +456,7 @@ mail_paned_view_get_window (EMailReader *reader)
static void
mail_paned_view_set_folder (EMailReader *reader,
- CamelFolder *folder,
- const gchar *folder_uri)
+ CamelFolder *folder)
{
EMailPanedViewPrivate *priv;
EMailView *view;
@@ -469,6 +468,7 @@ mail_paned_view_set_folder (EMailReader *reader,
GtkWidget *message_list;
GKeyFile *key_file;
gchar *group_name;
+ const gchar *folder_uri;
const gchar *key;
gboolean value;
GError *error = NULL;
@@ -488,7 +488,7 @@ mail_paned_view_set_folder (EMailReader *reader,
/* Chain up to interface's default set_folder() method. */
default_interface = g_type_default_interface_peek (E_TYPE_MAIL_READER);
- default_interface->set_folder (reader, folder, folder_uri);
+ default_interface->set_folder (reader, folder);
if (folder == NULL)
goto exit;
@@ -507,6 +507,7 @@ mail_paned_view_set_folder (EMailReader *reader,
/* Restore the folder's preview and threaded state. */
+ folder_uri = camel_folder_get_uri (folder);
key_file = e_shell_view_get_state_key_file (shell_view);
group_name = g_strdup_printf ("Folder %s", folder_uri);
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index c74caad..7f7d57d 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -294,7 +294,7 @@ e_mail_reader_open_selected (EMailReader *reader)
browser = e_mail_browser_new (backend);
e_mail_reader_set_folder (
- E_MAIL_READER (browser), folder, folder_uri);
+ E_MAIL_READER (browser), folder);
e_mail_reader_set_message (E_MAIL_READER (browser), uid);
copy_tree_state (reader, E_MAIL_READER (browser));
e_mail_reader_set_group_by_threads (
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index f26921c..c9a4386 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -1697,11 +1697,9 @@ action_mail_show_source_cb (GtkAction *action,
CamelFolder *folder;
GtkWidget *browser;
GPtrArray *uids;
- const gchar *folder_uri;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
- folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids->len > 0);
@@ -1714,7 +1712,7 @@ action_mail_show_source_cb (GtkAction *action,
em_format_set_mode (
EM_FORMAT (formatter), EM_FORMAT_MODE_SOURCE);
- e_mail_reader_set_folder (reader, folder, folder_uri);
+ e_mail_reader_set_folder (reader, folder);
e_mail_reader_set_message (reader, uids->pdata[0]);
gtk_widget_show (browser);
@@ -2899,8 +2897,7 @@ mail_reader_get_enable_show_folder (EMailReader *reader)
static void
mail_reader_set_folder (EMailReader *reader,
- CamelFolder *folder,
- const gchar *folder_uri)
+ CamelFolder *folder)
{
EMailReaderPrivate *priv;
EMFormatHTML *formatter;
@@ -2908,7 +2905,7 @@ mail_reader_set_folder (EMailReader *reader,
GtkWidget *message_list;
EMailBackend *backend;
EShell *shell;
- const gchar *previous_folder_uri;
+ const gchar *folder_uri = NULL;
gboolean outgoing;
priv = E_MAIL_READER_GET_PRIVATE (reader);
@@ -2918,7 +2915,6 @@ mail_reader_set_folder (EMailReader *reader,
message_list = e_mail_reader_get_message_list (reader);
previous_folder = e_mail_reader_get_folder (reader);
- previous_folder_uri = e_mail_reader_get_folder_uri (reader);
shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
@@ -2927,9 +2923,12 @@ mail_reader_set_folder (EMailReader *reader,
mail_sync_folder (previous_folder, NULL, NULL);
/* Skip the rest if we're already viewing the folder. */
- if (g_strcmp0 (folder_uri, previous_folder_uri) == 0)
+ if (folder == previous_folder)
return;
+ if (folder != NULL)
+ folder_uri = camel_folder_get_uri (folder);
+
outgoing = folder != NULL && folder_uri != NULL && (
em_utils_folder_is_drafts (folder, folder_uri) ||
em_utils_folder_is_outbox (folder, folder_uri) ||
@@ -4109,8 +4108,7 @@ e_mail_reader_get_folder_uri (EMailReader *reader)
void
e_mail_reader_set_folder (EMailReader *reader,
- CamelFolder *folder,
- const gchar *folder_uri)
+ CamelFolder *folder)
{
EMailReaderInterface *interface;
@@ -4119,7 +4117,7 @@ e_mail_reader_set_folder (EMailReader *reader,
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_if_fail (interface->set_folder != NULL);
- interface->set_folder (reader, folder, folder_uri);
+ interface->set_folder (reader, folder);
}
/* Helper for e_mail_reader_set_folder_uri () */
@@ -4130,7 +4128,7 @@ mail_reader_got_folder_cb (gchar *folder_uri,
{
EMailReader *reader = user_data;
- e_mail_reader_set_folder (reader, folder, folder_uri);
+ e_mail_reader_set_folder (reader, folder);
}
void
diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h
index d9a78f2..8076b08 100644
--- a/mail/e-mail-reader.h
+++ b/mail/e-mail-reader.h
@@ -98,8 +98,7 @@ struct _EMailReaderInterface {
CamelFolder * (*get_folder) (EMailReader *reader);
const gchar * (*get_folder_uri) (EMailReader *reader);
void (*set_folder) (EMailReader *reader,
- CamelFolder *folder,
- const gchar *folder_uri);
+ CamelFolder *folder);
void (*set_message) (EMailReader *reader,
const gchar *uid);
guint (*open_selected_mail) (EMailReader *reader);
@@ -136,8 +135,7 @@ GtkWindow * e_mail_reader_get_window (EMailReader *reader);
CamelFolder * e_mail_reader_get_folder (EMailReader *reader);
const gchar * e_mail_reader_get_folder_uri (EMailReader *reader);
void e_mail_reader_set_folder (EMailReader *reader,
- CamelFolder *folder,
- const gchar *folder_uri);
+ CamelFolder *folder);
void e_mail_reader_set_folder_uri (EMailReader *reader,
const gchar *folder_uri);
void e_mail_reader_set_message (EMailReader *reader,
diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c
index 5144936..ae3092d 100644
--- a/mail/em-folder-selector.c
+++ b/mail/em-folder-selector.c
@@ -139,16 +139,24 @@ emfs_create_name_changed (GtkEntry *entry, EMFolderSelector *emfs)
}
static void
-folder_selected_cb (EMFolderTree *emft, const gchar *path, const gchar *uri, guint32 flags, EMFolderSelector *emfs)
+folder_selected_cb (EMFolderTree *emft,
+ CamelStore *store,
+ const gchar *folder_name,
+ CamelFolderInfoFlags flags,
+ EMFolderSelector *emfs)
{
if (emfs->name_entry)
emfs_create_name_changed (emfs->name_entry, emfs);
else
- gtk_dialog_set_response_sensitive (GTK_DIALOG (emfs), GTK_RESPONSE_OK, TRUE);
+ gtk_dialog_set_response_sensitive (
+ GTK_DIALOG (emfs), GTK_RESPONSE_OK, TRUE);
}
static void
-folder_activated_cb (EMFolderTree *emft, const gchar *path, const gchar *uri, EMFolderSelector *emfs)
+folder_activated_cb (EMFolderTree *emft,
+ CamelStore *store,
+ const gchar *folder_name,
+ EMFolderSelector *emfs)
{
gtk_dialog_response ((GtkDialog *) emfs, GTK_RESPONSE_OK);
}
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index e0ce87b..849fb87 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -672,11 +672,11 @@ folder_tree_selection_changed_cb (EMFolderTree *folder_tree,
GtkTreeModel *model;
GtkTreeIter iter;
GList *list;
- guint32 flags = 0;
+ CamelStore *store = NULL;
+ CamelFolderInfoFlags flags = 0;
guint unread = 0;
guint old_unread = 0;
- gchar *full_name = NULL;
- gchar *uri = NULL;
+ gchar *folder_name = NULL;
list = gtk_tree_selection_get_selected_rows (selection, &model);
@@ -687,10 +687,11 @@ folder_tree_selection_changed_cb (EMFolderTree *folder_tree,
gtk_tree_model_get (
model, &iter,
- COL_STRING_FULL_NAME, &full_name,
- COL_STRING_URI, &uri, COL_UINT_FLAGS, &flags,
- COL_UINT_UNREAD, &unread, COL_UINT_UNREAD_LAST_SEL,
- &old_unread, -1);
+ COL_POINTER_CAMEL_STORE, &store,
+ COL_STRING_FULL_NAME, &folder_name,
+ COL_UINT_FLAGS, &flags,
+ COL_UINT_UNREAD, &unread,
+ COL_UINT_UNREAD_LAST_SEL, &old_unread, -1);
/* Sync unread counts to distinguish new incoming mail. */
if (unread != old_unread)
@@ -700,10 +701,10 @@ folder_tree_selection_changed_cb (EMFolderTree *folder_tree,
exit:
g_signal_emit (
- folder_tree, signals[FOLDER_SELECTED], 0, full_name, uri, flags);
+ folder_tree, signals[FOLDER_SELECTED], 0,
+ store, folder_name, flags);
- g_free (full_name);
- g_free (uri);
+ g_free (folder_name);
g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
g_list_free (list);
@@ -972,9 +973,10 @@ folder_tree_row_activated (GtkTreeView *tree_view,
{
EMFolderTreePrivate *priv;
GtkTreeModel *model;
- gchar *full_name, *uri;
+ gchar *folder_name;
GtkTreeIter iter;
- guint32 flags;
+ CamelStore *store;
+ CamelFolderInfoFlags flags;
priv = EM_FOLDER_TREE (tree_view)->priv;
@@ -987,19 +989,22 @@ folder_tree_row_activated (GtkTreeView *tree_view,
return;
gtk_tree_model_get (
- model, &iter, COL_STRING_FULL_NAME, &full_name,
- COL_STRING_URI, &uri, COL_UINT_FLAGS, &flags, -1);
+ model, &iter,
+ COL_POINTER_CAMEL_STORE, &store,
+ COL_STRING_FULL_NAME, &folder_name,
+ COL_UINT_FLAGS, &flags, -1);
folder_tree_clear_selected_list (EM_FOLDER_TREE (tree_view));
g_signal_emit (
- tree_view, signals[FOLDER_SELECTED], 0, full_name, uri, flags);
+ tree_view, signals[FOLDER_SELECTED], 0,
+ store, folder_name, flags);
g_signal_emit (
- tree_view, signals[FOLDER_ACTIVATED], 0, full_name, uri);
+ tree_view, signals[FOLDER_ACTIVATED], 0,
+ store, folder_name);
- g_free (full_name);
- g_free (uri);
+ g_free (folder_name);
}
static gboolean
@@ -1132,9 +1137,9 @@ folder_tree_class_init (EMFolderTreeClass *class)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EMFolderTreeClass, folder_selected),
NULL, NULL,
- e_marshal_VOID__STRING_STRING_UINT,
+ e_marshal_VOID__OBJECT_STRING_UINT,
G_TYPE_NONE, 3,
- G_TYPE_STRING,
+ CAMEL_TYPE_STORE,
G_TYPE_STRING,
G_TYPE_UINT);
@@ -1144,9 +1149,9 @@ folder_tree_class_init (EMFolderTreeClass *class)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EMFolderTreeClass, folder_activated),
NULL, NULL,
- e_marshal_VOID__STRING_STRING,
+ e_marshal_VOID__OBJECT_STRING,
G_TYPE_NONE, 2,
- G_TYPE_STRING,
+ CAMEL_TYPE_STORE,
G_TYPE_STRING);
signals[POPUP_EVENT] = g_signal_new (
diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h
index c824e86..4cb032b 100644
--- a/mail/em-folder-tree.h
+++ b/mail/em-folder-tree.h
@@ -78,12 +78,12 @@ struct _EMFolderTreeClass {
/* signals */
void (*folder_activated) (EMFolderTree *folder_tree,
- const gchar *full_name,
- const gchar *uri);
+ CamelStore *store,
+ const gchar *folder_name);
void (*folder_selected) (EMFolderTree *folder_tree,
- const gchar *full_name,
- const gchar *uri,
- guint32 flags);
+ CamelStore *store,
+ const gchar *folder_name,
+ CamelFolderInfoFlags flags);
void (*popup_event) (EMFolderTree *folder_tree);
void (*hidden_key_event) (EMFolderTree *emft, GdkEvent *event);
};
diff --git a/mail/mail.error.xml b/mail/mail.error.xml
index 4b9b986..67b7e09 100644
--- a/mail/mail.error.xml
+++ b/mail/mail.error.xml
@@ -504,5 +504,11 @@ An mbox account will be created to preserve the old mbox folders. You can delete
<_primary>Unable to retrieve message.</_primary>
<_secondary xml:space="preserve">{0}</_secondary>
</error>
+
+ <error id="folder-open" type="error">
+ <_primary>Failed to open folder.</_primary>
+ <_secondary>The reported error was "{0}".</_secondary>
+ </error>
+
</error-list>
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 1de34a9..609e483 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -315,7 +315,7 @@ mail_shell_backend_handle_email_uri_cb (gchar *folder_uri,
/* FIXME Should pass in the shell module. */
browser = e_mail_browser_new (backend);
e_mail_reader_set_folder (
- E_MAIL_READER (browser), folder, folder_uri);
+ E_MAIL_READER (browser), folder);
e_mail_reader_set_message (E_MAIL_READER (browser), uid);
gtk_widget_show (browser);
}
diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c
index c3b6cf9..57d1663 100644
--- a/modules/mail/e-mail-shell-content.c
+++ b/modules/mail/e-mail-shell-content.c
@@ -361,8 +361,7 @@ mail_shell_content_get_window (EMailReader *reader)
static void
mail_shell_content_set_folder (EMailReader *reader,
- CamelFolder *folder,
- const gchar *folder_uri)
+ CamelFolder *folder)
{
EMailShellContentPrivate *priv;
@@ -372,7 +371,7 @@ mail_shell_content_set_folder (EMailReader *reader,
* also implements the EMailReader interface. */
reader = E_MAIL_READER (priv->mail_view);
- return e_mail_reader_set_folder (reader, folder, folder_uri);
+ return e_mail_reader_set_folder (reader, folder);
}
static void
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index ac13439..c67dc76 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -26,36 +26,125 @@
#include "e-util/e-util-private.h"
+typedef struct _AsyncContext AsyncContext;
+
+struct _AsyncContext {
+ EActivity *activity;
+ EMailReader *reader;
+ EShellView *shell_view;
+};
+
+static void
+async_context_free (AsyncContext *context)
+{
+ if (context->activity != NULL)
+ g_object_unref (context->activity);
+
+ if (context->reader != NULL)
+ g_object_unref (context->reader);
+
+ if (context->shell_view != NULL)
+ g_object_unref (context->shell_view);
+
+ g_slice_free (AsyncContext, context);
+}
+
+static void
+mail_shell_view_got_folder_cb (CamelStore *store,
+ GAsyncResult *result,
+ AsyncContext *context)
+{
+ EAlertSink *alert_sink;
+ CamelFolder *folder;
+ GError *error = NULL;
+
+ alert_sink = e_activity_get_alert_sink (context->activity);
+
+ folder = camel_store_get_folder_finish (store, result, &error);
+
+ /* Ignore cancellations. */
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_warn_if_fail (folder == NULL);
+ async_context_free (context);
+ g_error_free (error);
+ return;
+
+ } else if (error != NULL) {
+ g_warn_if_fail (folder == NULL);
+ e_alert_submit (
+ alert_sink, "folder-open",
+ error->message, NULL);
+ async_context_free (context);
+ g_error_free (error);
+ return;
+ }
+
+ e_mail_reader_set_folder (context->reader, folder);
+ e_shell_view_update_actions (context->shell_view);
+
+ g_object_unref (folder);
+
+ async_context_free (context);
+}
+
static void
mail_shell_view_folder_tree_selected_cb (EMailShellView *mail_shell_view,
- const gchar *full_name,
- const gchar *uri,
- guint32 flags,
+ CamelStore *store,
+ const gchar *folder_name,
+ CamelFolderInfoFlags flags,
EMFolderTree *folder_tree)
{
EMailShellContent *mail_shell_content;
+ EShellBackend *shell_backend;
EShellView *shell_view;
EMailReader *reader;
EMailView *mail_view;
- gboolean folder_selected;
+ GCancellable *cancellable;
+ EAlertSink *alert_sink;
+ AsyncContext *context;
shell_view = E_SHELL_VIEW (mail_shell_view);
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
mail_shell_content = mail_shell_view->priv->mail_shell_content;
mail_view = e_mail_shell_content_get_mail_view (mail_shell_content);
reader = E_MAIL_READER (mail_view);
- folder_selected =
- !(flags & CAMEL_FOLDER_NOSELECT) &&
- full_name != NULL;
+ /* Cancel any unfinished open folder operations. */
+ if (mail_shell_view->priv->opening_folder != NULL) {
+ g_cancellable_cancel (mail_shell_view->priv->opening_folder);
+ mail_shell_view->priv->opening_folder = NULL;
+ }
- if (folder_selected)
- e_mail_reader_set_folder_uri (reader, uri);
- else
- e_mail_reader_set_folder (reader, NULL, NULL);
+ /* If we are to clear the message list, do so immediately. */
+ if ((flags & CAMEL_FOLDER_NOSELECT) || folder_name == NULL) {
+ e_mail_reader_set_folder (reader, NULL);
+ e_shell_view_update_actions (shell_view);
+ return;
+ }
- e_shell_view_update_actions (shell_view);
+ g_warn_if_fail (CAMEL_IS_STORE (store));
+
+ /* Open the selected folder asynchronously. */
+
+ context = g_slice_new0 (AsyncContext);
+ context->activity = e_activity_new ();
+ context->reader = g_object_ref (reader);
+ context->shell_view = g_object_ref (shell_view);
+
+ alert_sink = E_ALERT_SINK (mail_shell_content);
+ e_activity_set_alert_sink (context->activity, alert_sink);
+
+ cancellable = camel_operation_new ();
+ e_activity_set_cancellable (context->activity, cancellable);
+ mail_shell_view->priv->opening_folder = cancellable;
+
+ e_shell_backend_add_activity (shell_backend, context->activity);
+
+ camel_store_get_folder (
+ store, folder_name, 0, G_PRIORITY_DEFAULT, cancellable,
+ (GAsyncReadyCallback) mail_shell_view_got_folder_cb, context);
}
static gboolean
@@ -748,6 +837,12 @@ e_mail_shell_view_private_dispose (EMailShellView *mail_shell_view)
for (ii = 0; ii < MAIL_NUM_SEARCH_RULES; ii++)
DISPOSE (priv->search_rules[ii]);
+ if (priv->opening_folder != NULL) {
+ g_cancellable_cancel (priv->opening_folder);
+ g_object_unref (priv->opening_folder);
+ priv->opening_folder = NULL;
+ }
+
if (priv->search_account_all != NULL) {
g_object_unref (priv->search_account_all);
priv->search_account_all = NULL;
diff --git a/modules/mail/e-mail-shell-view-private.h b/modules/mail/e-mail-shell-view-private.h
index ac460a7..0109705 100644
--- a/modules/mail/e-mail-shell-view-private.h
+++ b/modules/mail/e-mail-shell-view-private.h
@@ -149,6 +149,9 @@ struct _EMailShellViewPrivate {
/* EShell::prepare-for-quit */
gulong prepare_for_quit_handler_id;
+ /* For opening the selected folder. */
+ GCancellable *opening_folder;
+
/* Search folders for interactive search. */
CamelVeeFolder *search_account_all;
CamelVeeFolder *search_account_current;
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 4af7de5..0b0f13e 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -116,8 +116,7 @@ mail_shell_view_setup_search_results_folder (CamelFolder *folder,
static void
mail_shell_view_show_search_results_folder (EMailShellView *mail_shell_view,
- CamelFolder *folder,
- const gchar *folder_uri)
+ CamelFolder *folder)
{
EMailShellContent *mail_shell_content;
GtkWidget *message_list;
@@ -132,7 +131,7 @@ mail_shell_view_show_search_results_folder (EMailShellView *mail_shell_view,
message_list_freeze (MESSAGE_LIST (message_list));
- e_mail_reader_set_folder (reader, folder, folder_uri);
+ e_mail_reader_set_folder (reader, folder);
e_tree_set_state (E_TREE (message_list), SEARCH_RESULTS_STATE);
message_list_thaw (MESSAGE_LIST (message_list));
@@ -240,7 +239,6 @@ mail_shell_view_execute_search (EShellView *shell_view)
gchar *query;
gchar *temp;
gchar *tag;
- gchar *uri;
const gchar *use_tag;
gint value;
@@ -519,9 +517,7 @@ all_accounts:
* folder URI and let the asynchronous callbacks run
* after we've already kicked off the search. */
folder = em_folder_tree_get_selected_folder (folder_tree);
- uri = em_folder_tree_get_selected_uri (folder_tree);
- e_mail_reader_set_folder (reader, folder, uri);
- g_free (uri);
+ e_mail_reader_set_folder (reader, folder);
gtk_widget_set_sensitive (GTK_WIDGET (combo_box), TRUE);
@@ -606,11 +602,9 @@ all_accounts:
CAMEL_FOLDER (search_folder), list,
priv->search_account_cancel);
- folder_uri = camel_folder_get_uri (CAMEL_FOLDER (search_folder));
-
mail_shell_view_show_search_results_folder (
E_MAIL_SHELL_VIEW (shell_view),
- CAMEL_FOLDER (search_folder), folder_uri);
+ CAMEL_FOLDER (search_folder));
goto execute;
@@ -639,9 +633,7 @@ current_account:
* folder URI and let the asynchronous callbacks run
* after we've already kicked off the search. */
folder = em_folder_tree_get_selected_folder (folder_tree);
- uri = em_folder_tree_get_selected_uri (folder_tree);
- e_mail_reader_set_folder (reader, folder, uri);
- g_free (uri);
+ e_mail_reader_set_folder (reader, folder);
gtk_widget_set_sensitive (GTK_WIDGET (combo_box), TRUE);
@@ -758,11 +750,9 @@ current_account:
CAMEL_FOLDER (search_folder), list,
priv->search_account_cancel);
- folder_uri = camel_folder_get_uri (CAMEL_FOLDER (search_folder));
-
mail_shell_view_show_search_results_folder (
E_MAIL_SHELL_VIEW (shell_view),
- CAMEL_FOLDER (search_folder), folder_uri);
+ CAMEL_FOLDER (search_folder));
execute:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]