aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/e-mail-local.h5
-rw-r--r--modules/mail/e-mail-shell-backend.c48
2 files changed, 51 insertions, 2 deletions
diff --git a/mail/e-mail-local.h b/mail/e-mail-local.h
index 1bd34e4273..b8dda29857 100644
--- a/mail/e-mail-local.h
+++ b/mail/e-mail-local.h
@@ -28,8 +28,9 @@
G_BEGIN_DECLS
-/* XXX E_MAIL_FOLDER_TEMPLATES is a prime example of why
- * templates should be a core feature, not a plugin. */
+/* XXX E_MAIL_FOLDER_TEMPLATES is a prime example of why templates
+ * should be a core feature: the mailer now has to know about
+ * this specific plugin, which defeats the purpose of plugins. */
typedef enum {
E_MAIL_FOLDER_INBOX,
E_MAIL_FOLDER_DRAFTS,
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 76aeb0daaa..43a272069a 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -43,6 +43,7 @@
#include "e-attachment-handler-mail.h"
#include "e-mail-browser.h"
+#include "e-mail-local.h"
#include "e-mail-reader.h"
#include "e-mail-store.h"
#include "em-account-editor.h"
@@ -472,6 +473,48 @@ mail_shell_backend_prepare_for_online_cb (EShell *shell,
}
static void
+mail_shell_backend_quit_requested_cb (EShell *shell,
+ EShellBackend *shell_backend)
+{
+ CamelFolder *folder;
+ GList *watched_windows;
+ GtkWindow *parent = NULL;
+ guint32 unsent;
+ gint response;
+
+ g_debug ("Quit requested for mail backend");
+
+ /* We can quit immediately if offline. */
+ if (!camel_session_is_online (session))
+ return;
+
+ /* Check Outbox for any unsent messages. */
+
+ folder = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX);
+ if (folder == NULL)
+ return;
+
+ if (camel_object_get (
+ folder, NULL, CAMEL_FOLDER_VISIBLE, &unsent, 0) != 0)
+ return;
+
+ if (unsent == 0)
+ return;
+
+ /* Try to find a parent window for the dialog.
+ * First list item is what's currently focused. */
+ watched_windows = e_shell_get_watched_windows (shell);
+ if (watched_windows != NULL)
+ parent = GTK_WINDOW (watched_windows->data);
+ response = e_error_run (parent, "mail:exit-unsaved", NULL);
+
+ if (response == GTK_RESPONSE_YES)
+ return;
+
+ e_shell_cancel_quit (shell);
+}
+
+static void
mail_shell_backend_send_receive_cb (EShell *shell,
GtkWindow *parent,
EShellBackend *shell_backend)
@@ -599,6 +642,11 @@ mail_shell_backend_constructed (GObject *object)
shell_backend);
g_signal_connect (
+ shell, "quit-requested",
+ G_CALLBACK (mail_shell_backend_quit_requested_cb),
+ shell_backend);
+
+ g_signal_connect (
shell, "send-receive",
G_CALLBACK (mail_shell_backend_send_receive_cb),
shell_backend);