aboutsummaryrefslogtreecommitdiffstats
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 01:24:33 +0800
commit43610e343194912394e5097655403f6ab7993ab0 (patch)
treeceb1a36a00a46ca0d8d410b2df42b00656016ae7
parentf5e47561f995ca50f2bbd45b940e0a10100281a5 (diff)
downloadgsoc2013-evolution-43610e343194912394e5097655403f6ab7993ab0.tar
gsoc2013-evolution-43610e343194912394e5097655403f6ab7993ab0.tar.gz
gsoc2013-evolution-43610e343194912394e5097655403f6ab7993ab0.tar.bz2
gsoc2013-evolution-43610e343194912394e5097655403f6ab7993ab0.tar.lz
gsoc2013-evolution-43610e343194912394e5097655403f6ab7993ab0.tar.xz
gsoc2013-evolution-43610e343194912394e5097655403f6ab7993ab0.tar.zst
gsoc2013-evolution-43610e343194912394e5097655403f6ab7993ab0.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.
-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 19b74fc311..1843751342 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -828,6 +828,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;
@@ -918,6 +982,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 fd9fefc2b9..fb01182700 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -638,72 +638,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)
@@ -711,13 +645,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. */
@@ -726,8 +658,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);
}
@@ -739,13 +670,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. */
@@ -754,8 +683,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);
}
@@ -767,13 +695,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. */
@@ -782,8 +708,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);
}
@@ -795,13 +720,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. */
@@ -810,8 +733,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);
}
@@ -1270,7 +1192,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);
@@ -1402,7 +1323,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);
@@ -1459,7 +1379,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
@@ -1483,7 +1402,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);
}
@@ -1493,7 +1411,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
@@ -1665,7 +1582,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);
@@ -1730,7 +1646,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
@@ -1738,7 +1653,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 a849f2830f..60c3855d60 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -82,7 +82,6 @@ struct _AsyncContext {
gchar *message_uid;
gboolean replace;
gboolean keep_signature;
- GtkWidget *destroy_when_done;
};
struct _ForwardData {
@@ -104,9 +103,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);
@@ -1997,7 +1993,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;
@@ -2006,7 +2001,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;
}
@@ -2045,8 +2039,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.
*
@@ -2068,8 +2060,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;
@@ -2087,7 +2078,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 7084c37371..924dc79a16 100644
--- a/mail/em-composer-utils.h
+++ b/mail/em-composer-utils.h
@@ -56,8 +56,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