aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-05 04:09:47 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-06-05 04:12:36 +0800
commitd54a3443d8bf8bb97a0de108d3eb8216b01846b5 (patch)
treeb6e76a6bdbb160719efd90b7061b0df2b0e9c5e7 /mail
parent5794c63f4ff48ad4abc677954fcd5e9bb578aacc (diff)
downloadgsoc2013-evolution-d54a3443d8bf8bb97a0de108d3eb8216b01846b5.tar
gsoc2013-evolution-d54a3443d8bf8bb97a0de108d3eb8216b01846b5.tar.gz
gsoc2013-evolution-d54a3443d8bf8bb97a0de108d3eb8216b01846b5.tar.bz2
gsoc2013-evolution-d54a3443d8bf8bb97a0de108d3eb8216b01846b5.tar.lz
gsoc2013-evolution-d54a3443d8bf8bb97a0de108d3eb8216b01846b5.tar.xz
gsoc2013-evolution-d54a3443d8bf8bb97a0de108d3eb8216b01846b5.tar.zst
gsoc2013-evolution-d54a3443d8bf8bb97a0de108d3eb8216b01846b5.zip
Bug 684302 - Prompt to close message window on reply should be inline
Pop-up dialog is far too intrusive. Instead ask the question as an inline alert in the message window, which does not interrupt the user.
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-browser.c123
-rw-r--r--mail/e-mail-browser.h2
-rw-r--r--mail/mail.error.xml11
3 files changed, 88 insertions, 48 deletions
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index 030b7e4801..8c5e4bb1fd 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -59,6 +59,9 @@ struct _EMailBrowserPrivate {
GtkWidget *preview_pane;
GtkWidget *statusbar;
+ EAlert *close_on_reply_alert;
+ gulong close_on_reply_response_handler_id;
+
guint show_deleted : 1;
};
@@ -359,6 +362,30 @@ mail_browser_status_message_cb (EMailBrowser *browser,
}
static void
+mail_browser_close_on_reply_response_cb (EAlert *alert,
+ gint response_id,
+ EMailBrowser *browser)
+{
+ /* Disconnect the signal handler, but leave the EAlert
+ * itself in place so we know it's already been presented. */
+ g_signal_handler_disconnect (
+ browser->priv->close_on_reply_alert,
+ browser->priv->close_on_reply_response_handler_id);
+ browser->priv->close_on_reply_response_handler_id = 0;
+
+ if (response_id == GTK_RESPONSE_YES) {
+ e_mail_browser_set_close_on_reply_policy (
+ browser, E_AUTOMATIC_ACTION_POLICY_ALWAYS);
+ e_mail_browser_close (browser);
+ }
+
+ if (response_id == GTK_RESPONSE_NO) {
+ e_mail_browser_set_close_on_reply_policy (
+ browser, E_AUTOMATIC_ACTION_POLICY_NEVER);
+ }
+}
+
+static void
mail_browser_set_backend (EMailBrowser *browser,
EMailBackend *backend)
{
@@ -509,6 +536,13 @@ mail_browser_dispose (GObject *object)
priv = E_MAIL_BROWSER_GET_PRIVATE (object);
+ if (priv->close_on_reply_response_handler_id > 0) {
+ g_signal_handler_disconnect (
+ priv->close_on_reply_alert,
+ priv->close_on_reply_response_handler_id);
+ priv->close_on_reply_response_handler_id = 0;
+ }
+
g_clear_object (&priv->backend);
g_clear_object (&priv->ui_manager);
g_clear_object (&priv->focus_tracker);
@@ -516,6 +550,7 @@ mail_browser_dispose (GObject *object)
g_clear_object (&priv->main_toolbar);
g_clear_object (&priv->preview_pane);
g_clear_object (&priv->statusbar);
+ g_clear_object (&priv->close_on_reply_alert);
if (priv->message_list != NULL) {
/* This will cancel a regen operation. */
@@ -801,15 +836,18 @@ mail_browser_set_message (EMailReader *reader,
const gchar *uid)
{
EMailReaderInterface *interface;
+ EMailBrowser *browser;
CamelMessageInfo *info;
CamelFolder *folder;
+ browser = E_MAIL_BROWSER (reader);
+
/* Chain up to parent's set_message() method. */
interface = g_type_default_interface_peek (E_TYPE_MAIL_READER);
interface->set_message (reader, uid);
if (uid == NULL) {
- e_mail_browser_close (E_MAIL_BROWSER (reader));
+ e_mail_browser_close (browser);
return;
}
@@ -831,7 +869,6 @@ mail_browser_composer_created (EMailReader *reader,
{
EMailBrowser *browser;
EAutomaticActionPolicy policy;
- gboolean close_browser;
/* Do not prompt if there is no source message. It means
* the user wants to start a brand new message, presumably
@@ -842,46 +879,19 @@ mail_browser_composer_created (EMailReader *reader,
browser = E_MAIL_BROWSER (reader);
policy = e_mail_browser_get_close_on_reply_policy (browser);
- if (policy == E_AUTOMATIC_ACTION_POLICY_ALWAYS) {
- close_browser = TRUE;
- } else if (policy == E_AUTOMATIC_ACTION_POLICY_NEVER) {
- close_browser = FALSE;
- } else {
- GtkWidget *dialog;
- GtkWindow *parent;
- EShell *shell;
- EMailBackend *backend;
- EShellBackend *shell_backend;
- gint response;
-
- backend = e_mail_reader_get_backend (reader);
-
- shell_backend = E_SHELL_BACKEND (backend);
- shell = e_shell_backend_get_shell (shell_backend);
-
- parent = e_shell_get_active_window (shell);
- if (parent == NULL)
- parent = e_mail_reader_get_window (reader);
-
- dialog = e_alert_dialog_new_for_args (
- parent, "mail:ask-reply-close-browser", NULL);
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- close_browser =
- (response == GTK_RESPONSE_YES) ||
- (response == GTK_RESPONSE_OK);
-
- if (response == GTK_RESPONSE_OK)
- e_mail_browser_set_close_on_reply_policy (
- browser, E_AUTOMATIC_ACTION_POLICY_ALWAYS);
- else if (response == GTK_RESPONSE_CANCEL)
- e_mail_browser_set_close_on_reply_policy (
- browser, E_AUTOMATIC_ACTION_POLICY_NEVER);
- }
+ switch (policy) {
+ case E_AUTOMATIC_ACTION_POLICY_ALWAYS:
+ e_mail_browser_close (browser);
+ break;
- if (close_browser)
- e_mail_browser_close (E_MAIL_BROWSER (reader));
+ case E_AUTOMATIC_ACTION_POLICY_NEVER:
+ /* do nothing */
+ break;
+
+ case E_AUTOMATIC_ACTION_POLICY_ASK:
+ e_mail_browser_ask_close_on_reply (browser);
+ break;
+ }
}
static void
@@ -1045,6 +1055,37 @@ e_mail_browser_close (EMailBrowser *browser)
gtk_widget_destroy (GTK_WIDGET (browser));
}
+void
+e_mail_browser_ask_close_on_reply (EMailBrowser *browser)
+{
+ EAlertSink *alert_sink;
+ EAlert *alert;
+ gulong handler_id;
+
+ g_return_if_fail (E_IS_MAIL_BROWSER (browser));
+
+ /* Do nothing if the question has already been presented, even if
+ * the user dismissed it without answering. We only present the
+ * question once per browser window, lest it become annoying. */
+ if (browser->priv->close_on_reply_alert != NULL)
+ return;
+
+ alert = e_alert_new ("mail:browser-close-on-reply", NULL);
+
+ handler_id = g_signal_connect (
+ alert, "response",
+ G_CALLBACK (mail_browser_close_on_reply_response_cb),
+ browser);
+
+ browser->priv->close_on_reply_alert = g_object_ref (alert);
+ browser->priv->close_on_reply_response_handler_id = handler_id;
+
+ alert_sink = e_mail_reader_get_alert_sink (E_MAIL_READER (browser));
+ e_alert_sink_submit_alert (alert_sink, alert);
+
+ g_object_unref (alert);
+}
+
EAutomaticActionPolicy
e_mail_browser_get_close_on_reply_policy (EMailBrowser *browser)
{
diff --git a/mail/e-mail-browser.h b/mail/e-mail-browser.h
index dce6922be8..1d32042ab8 100644
--- a/mail/e-mail-browser.h
+++ b/mail/e-mail-browser.h
@@ -66,6 +66,8 @@ GtkWidget * e_mail_browser_new (EMailBackend *backend,
const gchar *message_uid,
EMailFormatterMode display_mode);
void e_mail_browser_close (EMailBrowser *browser);
+void e_mail_browser_ask_close_on_reply
+ (EMailBrowser *browser);
EAutomaticActionPolicy
e_mail_browser_get_close_on_reply_policy
(EMailBrowser *browser);
diff --git a/mail/mail.error.xml b/mail/mail.error.xml
index d523b543af..f067ed3b9d 100644
--- a/mail/mail.error.xml
+++ b/mail/mail.error.xml
@@ -393,13 +393,10 @@ An mbox account will be created to preserve the old mbox folders. You can delete
<button _label="In Current _Folder Only" response="GTK_RESPONSE_NO"/>
</error>
- <error id="ask-reply-close-browser" type="question" default="GTK_RESPONSE_NO">
- <_primary>Close message window.</_primary>
- <_secondary xml:space="preserve">Would you like to close the message window?</_secondary>
- <button _label="_Yes" response="GTK_RESPONSE_YES"/>
- <button _label="_No" response="GTK_RESPONSE_NO"/>
- <button _label="_Always" response="GTK_RESPONSE_OK"/>
- <button _label="N_ever" response="GTK_RESPONSE_CANCEL"/>
+ <error id="browser-close-on-reply" type="question" default="GTK_RESPONSE_NO">
+ <_secondary>Should Evolution close this window when replying or forwarding?</_secondary>
+ <button _label="_Yes, Always" response="GTK_RESPONSE_YES"/>
+ <button _label="_No, Never" response="GTK_RESPONSE_NO"/>
</error>
<error id="ask-folder-drop-copy" type="question" default="GTK_RESPONSE_YES">