aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-07-09 19:13:07 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-07-09 20:44:22 +0800
commit0a359ba9826d52378e64e4a9a9c96588255a1ad9 (patch)
tree378ed270591e45f6d8736d42b6645fb7ce2cf46c
parentc44c65e85fe6413b69d26ae600be6bfb4952367c (diff)
downloadgsoc2013-evolution-0a359ba9826d52378e64e4a9a9c96588255a1ad9.tar
gsoc2013-evolution-0a359ba9826d52378e64e4a9a9c96588255a1ad9.tar.gz
gsoc2013-evolution-0a359ba9826d52378e64e4a9a9c96588255a1ad9.tar.bz2
gsoc2013-evolution-0a359ba9826d52378e64e4a9a9c96588255a1ad9.tar.lz
gsoc2013-evolution-0a359ba9826d52378e64e4a9a9c96588255a1ad9.tar.xz
gsoc2013-evolution-0a359ba9826d52378e64e4a9a9c96588255a1ad9.tar.zst
gsoc2013-evolution-0a359ba9826d52378e64e4a9a9c96588255a1ad9.zip
Add e_mail_reader_expunge_folder().
Wraps e_mail_folder_expunge() with EActivity/EAlert stuff and also prompt for confirmation.
-rw-r--r--mail/e-mail-reader-utils.c70
-rw-r--r--mail/e-mail-reader-utils.h2
-rw-r--r--mail/mail.error.xml5
3 files changed, 77 insertions, 0 deletions
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index e88d2c6bb3..eed03f30c6 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -377,6 +377,76 @@ e_mail_reader_delete_folder_name (EMailReader *reader,
context);
}
+/* Helper for e_mail_reader_expunge_folder() */
+static void
+mail_reader_expunge_folder_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ CamelFolder *folder;
+ AsyncContext *context;
+ EAlertSink *alert_sink;
+ GError *error = NULL;
+
+ folder = CAMEL_FOLDER (source_object);
+ context = (AsyncContext *) user_data;
+
+ alert_sink = e_activity_get_alert_sink (context->activity);
+
+ if (e_activity_handle_cancellation (context->activity, error)) {
+ g_error_free (error);
+
+ } else if (error != NULL) {
+ e_alert_submit (
+ alert_sink, "mail:no-expunge-folder",
+ camel_folder_get_display_name (folder),
+ error->message, NULL);
+ g_error_free (error);
+
+ } else {
+ e_activity_set_state (
+ context->activity, E_ACTIVITY_COMPLETED);
+ }
+
+ async_context_free (context);
+}
+
+void
+e_mail_reader_expunge_folder (EMailReader *reader,
+ CamelFolder *folder)
+{
+ GtkWindow *window;
+ const gchar *display_name;
+ gboolean proceed;
+
+ g_return_if_fail (E_IS_MAIL_READER (reader));
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
+
+ window = e_mail_reader_get_window (reader);
+ display_name = camel_folder_get_display_name (folder);
+
+ proceed = em_utils_prompt_user (
+ window, "prompt-on-expunge",
+ "mail:ask-expunge", display_name, NULL);
+
+ if (proceed) {
+ EActivity *activity;
+ AsyncContext *context;
+ GCancellable *cancellable;
+
+ 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);
+
+ e_mail_folder_expunge (
+ folder, G_PRIORITY_DEFAULT, cancellable,
+ mail_reader_expunge_folder_cb, context);
+ }
+}
+
/* Helper for e_mail_reader_refresh_folder() */
static void
mail_reader_refresh_folder_cb (GObject *source_object,
diff --git a/mail/e-mail-reader-utils.h b/mail/e-mail-reader-utils.h
index ee1f8394bb..3f1d9243fe 100644
--- a/mail/e-mail-reader-utils.h
+++ b/mail/e-mail-reader-utils.h
@@ -43,6 +43,8 @@ void e_mail_reader_delete_folder_name
(EMailReader *reader,
CamelStore *store,
const gchar *folder_name);
+void e_mail_reader_expunge_folder (EMailReader *reader,
+ CamelFolder *folder);
void e_mail_reader_refresh_folder (EMailReader *reader,
CamelFolder *folder);
void e_mail_reader_refresh_folder_name
diff --git a/mail/mail.error.xml b/mail/mail.error.xml
index a41d4a4458..3ff85ade1d 100644
--- a/mail/mail.error.xml
+++ b/mail/mail.error.xml
@@ -195,6 +195,11 @@ Many email systems add an Apparently-To header to messages that only have BCC re
<_secondary xml:space="preserve">System folders are required for Evolution to function correctly and cannot be renamed, moved, or deleted.</_secondary>
</error>
+ <error id="no-expunge-folder" type="warning">
+ <_primary>Failed to expunge folder &quot;{0}&quot;.</_primary>
+ <_secondary>The reported error was &quot;{1}&quot;.</_secondary>
+ </error>
+
<error id="no-refresh-folder" type="warning">
<_primary>Failed to refresh folder &quot;{0}&quot;.</_primary>
<_secondary>The reported error was &quot;{1}&quot;.</_secondary>