diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-07-17 04:37:44 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-07-17 04:37:44 +0800 |
commit | 0f35ef8d0e88b2f7223638d414580537cd91d206 (patch) | |
tree | 27e10f476bffcade8b68995096c5070665db6492 | |
parent | e5b7a6d28cc37cb037a4a80481bbd23d99c558d0 (diff) | |
download | gsoc2013-evolution-0f35ef8d0e88b2f7223638d414580537cd91d206.tar gsoc2013-evolution-0f35ef8d0e88b2f7223638d414580537cd91d206.tar.gz gsoc2013-evolution-0f35ef8d0e88b2f7223638d414580537cd91d206.tar.bz2 gsoc2013-evolution-0f35ef8d0e88b2f7223638d414580537cd91d206.tar.lz gsoc2013-evolution-0f35ef8d0e88b2f7223638d414580537cd91d206.tar.xz gsoc2013-evolution-0f35ef8d0e88b2f7223638d414580537cd91d206.tar.zst gsoc2013-evolution-0f35ef8d0e88b2f7223638d414580537cd91d206.zip |
Prompt when exiting with unsent messages.
-rw-r--r-- | mail/e-mail-local.h | 5 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-backend.c | 48 |
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); |