aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-02 23:39:56 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-06-03 04:19:32 +0800
commite1faf763eb8256bfa43071b96bcd83d789b59002 (patch)
tree2b316984db3fa17760792978bac3ee7d0096caea /mail
parent98dd0ac727e7bff5ad056427fa04d579f838ba75 (diff)
downloadgsoc2013-evolution-e1faf763eb8256bfa43071b96bcd83d789b59002.tar
gsoc2013-evolution-e1faf763eb8256bfa43071b96bcd83d789b59002.tar.gz
gsoc2013-evolution-e1faf763eb8256bfa43071b96bcd83d789b59002.tar.bz2
gsoc2013-evolution-e1faf763eb8256bfa43071b96bcd83d789b59002.tar.lz
gsoc2013-evolution-e1faf763eb8256bfa43071b96bcd83d789b59002.tar.xz
gsoc2013-evolution-e1faf763eb8256bfa43071b96bcd83d789b59002.tar.zst
gsoc2013-evolution-e1faf763eb8256bfa43071b96bcd83d789b59002.zip
Move "ask-reply-close-browser" prompt to EMailBrowser.
EMailReader is an interface and should not know about specific classes that implement its interface. Instead, EMailBrowser itself will prompt in response to "composer-created" signals that include a source message. This also removes the "destroy_when_done" parameter from em_utils_forward_messages() since it's no longer needed. (cherry picked from commit 43610e343194912394e5097655403f6ab7993ab0) Conflicts: mail/em-composer-utils.c
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-browser.c65
-rw-r--r--mail/e-mail-reader.c94
-rw-r--r--mail/em-composer-utils.c12
-rw-r--r--mail/em-composer-utils.h3
4 files changed, 71 insertions, 103 deletions
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index bdebf269aa..36aa126443 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -832,6 +832,70 @@ mail_browser_set_message (EMailReader *reader,
}
static void
+mail_browser_composer_created (EMailReader *reader,
+ EMsgComposer *composer,
+ CamelMimeMessage *message)
+{
+ GSettings *settings;
+ const gchar *key;
+ gchar *value;
+ gboolean close_browser;
+
+ /* Do not prompt if there is no source message. It means
+ * the user wants to start a brand new message, presumably
+ * unrelated to the message shown in the browser window. */
+ if (message == NULL)
+ return;
+
+ settings = g_settings_new ("org.gnome.evolution.mail");
+
+ key = "prompt-on-reply-close-browser";
+ value = g_settings_get_string (settings, key);
+
+ if (g_strcmp0 (value, "always") == 0) {
+ close_browser = TRUE;
+ } else if (g_strcmp0 (value, "never") == 0) {
+ 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)
+ g_settings_set_string (settings, key, "always");
+ else if (response == GTK_RESPONSE_CANCEL)
+ g_settings_set_string (settings, key, "never");
+ }
+
+ g_free (value);
+ g_object_unref (settings);
+
+ if (close_browser)
+ e_mail_browser_close (E_MAIL_BROWSER (reader));
+}
+
+static void
e_mail_browser_class_init (EMailBrowserClass *class)
{
GObjectClass *object_class;
@@ -922,6 +986,7 @@ e_mail_browser_reader_init (EMailReaderInterface *interface)
interface->get_preview_pane = mail_browser_get_preview_pane;
interface->get_window = mail_browser_get_window;
interface->set_message = mail_browser_set_message;
+ interface->composer_created = mail_browser_composer_created;
}
static void
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 8c05d8ae65..d38ef28729 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -633,72 +633,6 @@ action_mail_flag_for_followup_cb (GtkAction *action,
em_utils_flag_for_followup (reader, folder, uids);
}
-static gboolean
-get_close_browser_reader (EMailReader *reader)
-{
- GSettings *settings;
- const gchar *key;
- gchar *value;
- gboolean close_it;
-
- /* only allow closing of a mail browser and nothing else */
- if (!E_IS_MAIL_BROWSER (reader))
- return FALSE;
-
- settings = g_settings_new ("org.gnome.evolution.mail");
-
- key = "prompt-on-reply-close-browser";
- value = g_settings_get_string (settings, key);
-
- if (g_strcmp0 (value, "always") == 0) {
- close_it = TRUE;
- } else if (g_strcmp0 (value, "never") == 0) {
- close_it = FALSE;
- } else {
- GtkWidget *dialog;
- GtkWindow *parent;
- gint response;
- EShell *shell;
- EMailBackend *backend;
- EShellBackend *shell_backend;
-
- 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_it =
- (response == GTK_RESPONSE_YES) ||
- (response == GTK_RESPONSE_OK);
-
- if (response == GTK_RESPONSE_OK)
- g_settings_set_string (settings, key, "always");
- else if (response == GTK_RESPONSE_CANCEL)
- g_settings_set_string (settings, key, "never");
- }
-
- g_free (value);
- g_object_unref (settings);
-
- return close_it;
-}
-
-static void
-check_close_browser_reader (EMailReader *reader)
-{
- if (get_close_browser_reader (reader))
- gtk_widget_destroy (GTK_WIDGET (reader));
-}
-
static void
action_mail_forward_cb (GtkAction *action,
EMailReader *reader)
@@ -706,13 +640,11 @@ action_mail_forward_cb (GtkAction *action,
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
- gboolean close_reader;
folder = e_mail_reader_get_folder (reader);
window = e_mail_reader_get_window (reader);
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids != NULL);
- close_reader = get_close_browser_reader (reader);
/* XXX Either e_mail_reader_get_selected_uids()
* or MessageList should do this itself. */
@@ -721,8 +653,7 @@ action_mail_forward_cb (GtkAction *action,
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
reader, folder, uids,
- e_mail_reader_get_forward_style (reader),
- close_reader ? GTK_WIDGET (reader) : NULL);
+ e_mail_reader_get_forward_style (reader));
g_ptr_array_unref (uids);
}
@@ -734,13 +665,11 @@ action_mail_forward_attached_cb (GtkAction *action,
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
- gboolean close_reader;
folder = e_mail_reader_get_folder (reader);
window = e_mail_reader_get_window (reader);
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids != NULL);
- close_reader = get_close_browser_reader (reader);
/* XXX Either e_mail_reader_get_selected_uids()
* or MessageList should do this itself. */
@@ -749,8 +678,7 @@ action_mail_forward_attached_cb (GtkAction *action,
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
reader, folder, uids,
- E_MAIL_FORWARD_STYLE_ATTACHED,
- close_reader ? GTK_WIDGET (reader) : NULL);
+ E_MAIL_FORWARD_STYLE_ATTACHED);
g_ptr_array_unref (uids);
}
@@ -762,13 +690,11 @@ action_mail_forward_inline_cb (GtkAction *action,
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
- gboolean close_reader;
folder = e_mail_reader_get_folder (reader);
window = e_mail_reader_get_window (reader);
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids != NULL);
- close_reader = get_close_browser_reader (reader);
/* XXX Either e_mail_reader_get_selected_uids()
* or MessageList should do this itself. */
@@ -777,8 +703,7 @@ action_mail_forward_inline_cb (GtkAction *action,
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
reader, folder, uids,
- E_MAIL_FORWARD_STYLE_INLINE,
- close_reader ? GTK_WIDGET (reader) : NULL);
+ E_MAIL_FORWARD_STYLE_INLINE);
g_ptr_array_unref (uids);
}
@@ -790,13 +715,11 @@ action_mail_forward_quoted_cb (GtkAction *action,
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
- gboolean close_reader;
folder = e_mail_reader_get_folder (reader);
window = e_mail_reader_get_window (reader);
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids != NULL);
- close_reader = get_close_browser_reader (reader);
/* XXX Either e_mail_reader_get_selected_uids()
* or MessageList should do this itself. */
@@ -805,8 +728,7 @@ action_mail_forward_quoted_cb (GtkAction *action,
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
reader, folder, uids,
- E_MAIL_FORWARD_STYLE_QUOTED,
- close_reader ? GTK_WIDGET (reader) : NULL);
+ E_MAIL_FORWARD_STYLE_QUOTED);
g_ptr_array_unref (uids);
}
@@ -1265,7 +1187,6 @@ mail_reader_redirect_cb (CamelFolder *folder,
shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
composer = em_utils_redirect_message (shell, message);
- check_close_browser_reader (closure->reader);
e_mail_reader_composer_created (closure->reader, composer, message);
@@ -1397,7 +1318,6 @@ action_mail_reply_all_check (CamelFolder *folder,
}
e_mail_reader_reply_to_message (closure->reader, message, type);
- check_close_browser_reader (closure->reader);
exit:
g_object_unref (message);
@@ -1454,7 +1374,6 @@ action_mail_reply_all_cb (GtkAction *action,
}
e_mail_reader_reply_to_message (reader, NULL, E_MAIL_REPLY_TO_ALL);
- check_close_browser_reader (reader);
}
static void
@@ -1478,7 +1397,6 @@ action_mail_reply_group_cb (GtkAction *action,
if (reply_list && (state & E_MAIL_READER_SELECTION_IS_MAILING_LIST)) {
e_mail_reader_reply_to_message (
reader, NULL, E_MAIL_REPLY_TO_LIST);
- check_close_browser_reader (reader);
} else
action_mail_reply_all_cb (action, reader);
}
@@ -1488,7 +1406,6 @@ action_mail_reply_list_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_reply_to_message (reader, NULL, E_MAIL_REPLY_TO_LIST);
- check_close_browser_reader (reader);
}
static gboolean
@@ -1660,7 +1577,6 @@ action_mail_reply_sender_check (CamelFolder *folder,
}
e_mail_reader_reply_to_message (closure->reader, message, type);
- check_close_browser_reader (closure->reader);
exit:
g_object_unref (settings);
@@ -1725,7 +1641,6 @@ action_mail_reply_sender_cb (GtkAction *action,
}
e_mail_reader_reply_to_message (reader, NULL, E_MAIL_REPLY_TO_SENDER);
- check_close_browser_reader (reader);
}
static void
@@ -1733,7 +1648,6 @@ action_mail_reply_recipient_cb (GtkAction *action,
EMailReader *reader)
{
e_mail_reader_reply_to_message (reader, NULL, E_MAIL_REPLY_TO_RECIPIENT);
- check_close_browser_reader (reader);
}
static void
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 07a378b52d..850cc15de6 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -81,7 +81,6 @@ struct _AsyncContext {
gchar *folder_uri;
gchar *message_uid;
gboolean replace;
- GtkWidget *destroy_when_done;
};
struct _ForwardData {
@@ -103,9 +102,6 @@ async_context_free (AsyncContext *async_context)
if (async_context->ptr_array != NULL)
g_ptr_array_unref (async_context->ptr_array);
- if (async_context->destroy_when_done != NULL)
- gtk_widget_destroy (async_context->destroy_when_done);
-
g_free (async_context->folder_uri);
g_free (async_context->message_uid);
@@ -1973,7 +1969,6 @@ forward_got_messages_cb (GObject *source_object,
((hash_table == NULL) && (local_error != NULL)));
if (e_activity_handle_cancellation (activity, local_error)) {
- async_context->destroy_when_done = NULL;
g_error_free (local_error);
goto exit;
@@ -1982,7 +1977,6 @@ forward_got_messages_cb (GObject *source_object,
alert_sink,
"mail:get-multiple-messages",
local_error->message, NULL);
- async_context->destroy_when_done = NULL;
g_error_free (local_error);
goto exit;
}
@@ -2021,8 +2015,6 @@ exit:
* @folder: folder containing messages to forward
* @uids: uids of messages to forward
* @style: the forward style to use
- * @destroy_when_done: a #GtkWidget to destroy with gtk_widget_destroy()
- * when done; can be NULL
*
* Forwards a group of messages in the given style.
*
@@ -2044,8 +2036,7 @@ void
em_utils_forward_messages (EMailReader *reader,
CamelFolder *folder,
GPtrArray *uids,
- EMailForwardStyle style,
- GtkWidget *destroy_when_done)
+ EMailForwardStyle style)
{
EActivity *activity;
AsyncContext *async_context;
@@ -2063,7 +2054,6 @@ em_utils_forward_messages (EMailReader *reader,
async_context->reader = g_object_ref (reader);
async_context->ptr_array = g_ptr_array_ref (uids);
async_context->style = style;
- async_context->destroy_when_done = destroy_when_done;
switch (style) {
case E_MAIL_FORWARD_STYLE_ATTACHED:
diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h
index 3a47967483..d489f5e025 100644
--- a/mail/em-composer-utils.h
+++ b/mail/em-composer-utils.h
@@ -54,8 +54,7 @@ EMsgComposer * em_utils_forward_message (EMailBackend *backend,
void em_utils_forward_messages (EMailReader *reader,
CamelFolder *folder,
GPtrArray *uids,
- EMailForwardStyle style,
- GtkWidget *destroy_when_done);
+ EMailForwardStyle style);
EMsgComposer * em_utils_redirect_message (EShell *shell,
CamelMimeMessage *message);
gchar * em_utils_construct_composer_text