diff options
-rw-r--r-- | mail/e-mail-reader-utils.c | 72 | ||||
-rw-r--r-- | mail/e-mail-reader-utils.h | 4 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 17 |
3 files changed, 89 insertions, 4 deletions
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c index 3710795466..f9d5e2f8e8 100644 --- a/mail/e-mail-reader-utils.c +++ b/mail/e-mail-reader-utils.c @@ -64,6 +64,7 @@ struct _AsyncContext { CamelFolder *folder; EMailReader *reader; CamelInternetAddress *address; + gchar *folder_name; gchar *message_uid; EMailReplyType reply_type; @@ -88,6 +89,7 @@ async_context_free (AsyncContext *context) if (context->address != NULL) g_object_unref (context->address); + g_free (context->folder_name); g_free (context->message_uid); g_slice_free (AsyncContext, context); @@ -189,6 +191,10 @@ mail_reader_delete_folder_cb (CamelFolder *folder, camel_folder_get_full_name (folder), error->message, NULL); g_error_free (error); + + } else { + e_activity_set_state ( + context->activity, E_ACTIVITY_COMPLETED); } async_context_free (context); @@ -305,6 +311,72 @@ e_mail_reader_delete_folder (EMailReader *reader, gtk_widget_destroy (dialog); } +static void +mail_reader_delete_folder_name_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) +{ + CamelStore *store; + CamelFolder *folder; + AsyncContext *context; + EAlertSink *alert_sink; + GError *error = NULL; + + store = CAMEL_STORE (source_object); + context = (AsyncContext *) user_data; + + alert_sink = e_activity_get_alert_sink (context->activity); + + /* XXX The returned CamelFolder is a borrowed reference. */ + folder = camel_store_get_folder_finish (store, result, &error); + + if (e_activity_handle_cancellation (context->activity, error)) { + g_error_free (error); + + } else if (error != NULL) { + e_alert_submit ( + alert_sink, "mail:no-delete-folder", + context->folder_name, error->message, NULL); + g_error_free (error); + + } else { + e_activity_set_state ( + context->activity, E_ACTIVITY_COMPLETED); + e_mail_reader_delete_folder (context->reader, folder); + } + + async_context_free (context); +} + +void +e_mail_reader_delete_folder_name (EMailReader *reader, + CamelStore *store, + const gchar *folder_name) +{ + EActivity *activity; + AsyncContext *context; + GCancellable *cancellable; + + g_return_if_fail (E_IS_MAIL_READER (reader)); + g_return_if_fail (CAMEL_IS_STORE (store)); + g_return_if_fail (folder_name != NULL); + + activity = e_mail_reader_new_activity (reader); + cancellable = e_activity_get_cancellable (activity); + + context = g_slice_new0 (AsyncContext); + context->activity = activity; + context->reader = g_object_ref (reader); + context->folder_name = g_strdup (folder_name); + + camel_store_get_folder ( + store, folder_name, + CAMEL_STORE_FOLDER_INFO_FAST, + G_PRIORITY_DEFAULT, cancellable, + mail_reader_delete_folder_name_cb, + context); +} + guint e_mail_reader_mark_selected (EMailReader *reader, guint32 mask, diff --git a/mail/e-mail-reader-utils.h b/mail/e-mail-reader-utils.h index 7118f0149f..e2a8dee06a 100644 --- a/mail/e-mail-reader-utils.h +++ b/mail/e-mail-reader-utils.h @@ -39,6 +39,10 @@ struct _EMailReaderHeader { gboolean e_mail_reader_confirm_delete (EMailReader *reader); void e_mail_reader_delete_folder (EMailReader *reader, CamelFolder *folder); +void e_mail_reader_delete_folder_name + (EMailReader *reader, + CamelStore *store, + const gchar *folder_name); guint e_mail_reader_mark_selected (EMailReader *reader, guint32 mask, guint32 set); diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index 3468339200..9306704ed7 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -333,17 +333,26 @@ action_mail_folder_delete_cb (GtkAction *action, EMailShellSidebar *mail_shell_sidebar; EMailView *mail_view; EMFolderTree *folder_tree; - CamelFolder *folder; + CamelStore *selected_store = NULL; + gchar *selected_folder_name = NULL; mail_shell_content = mail_shell_view->priv->mail_shell_content; mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); - folder = em_folder_tree_get_selected_folder (folder_tree); - g_return_if_fail (folder != NULL); - e_mail_reader_delete_folder (E_MAIL_READER (mail_view), folder); + em_folder_tree_get_selected ( + folder_tree, &selected_store, &selected_folder_name); + g_return_if_fail (CAMEL_IS_STORE (selected_store)); + g_return_if_fail (selected_folder_name != NULL); + + e_mail_reader_delete_folder_name ( + E_MAIL_READER (mail_view), + selected_store, selected_folder_name); + + g_object_unref (selected_store); + g_free (selected_folder_name); } static void |