[evolution] I#906 - composer-plain-text-starts-preformatted is not followed when replying to HTML emails
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#906 - composer-plain-text-starts-preformatted is not followed when replying to HTML emails
- Date: Wed, 20 May 2020 10:28:55 +0000 (UTC)
commit 5397b37024134506eb2c7f0d197a12066b7e55a8
Author: Milan Crha <mcrha redhat com>
Date: Wed May 20 12:29:15 2020 +0200
I#906 - composer-plain-text-starts-preformatted is not followed when replying to HTML emails
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/906
src/mail/e-mail-notes.c | 25 ++++++++++++++-----------
src/modules/mail/e-mail-shell-backend.c | 24 ++++++++++++++----------
2 files changed, 28 insertions(+), 21 deletions(-)
---
diff --git a/src/mail/e-mail-notes.c b/src/mail/e-mail-notes.c
index d99e4b960e..fa192cd6e6 100644
--- a/src/mail/e-mail-notes.c
+++ b/src/mail/e-mail-notes.c
@@ -968,16 +968,20 @@ e_mail_notes_editor_init (EMailNotesEditor *notes_editor)
{
}
-static gboolean
-set_preformatted_block_format_on_idle_cb (gpointer user_data)
+static void
+set_preformatted_block_format_on_load_finished_cb (EContentEditor *cnt_editor,
+ gpointer user_data)
{
- EContentEditor *cnt_editor = user_data;
-
- g_return_val_if_fail (E_IS_CONTENT_EDITOR (cnt_editor), FALSE);
+ g_return_if_fail (E_IS_CONTENT_EDITOR (cnt_editor));
- e_content_editor_set_block_format (cnt_editor, E_CONTENT_EDITOR_BLOCK_FORMAT_PRE);
+ if (!e_content_editor_get_html_mode (cnt_editor)) {
+ e_content_editor_set_block_format (cnt_editor, E_CONTENT_EDITOR_BLOCK_FORMAT_PRE);
+ e_content_editor_set_changed (cnt_editor, FALSE);
+ e_content_editor_clear_undo_redo_history (cnt_editor);
+ }
- return FALSE;
+ g_signal_handlers_disconnect_by_func (cnt_editor,
+ G_CALLBACK (set_preformatted_block_format_on_load_finished_cb), NULL);
}
static EMailNotesEditor *
@@ -1133,10 +1137,9 @@ e_mail_notes_editor_new_with_editor (EHTMLEditor *html_editor,
settings = e_util_ref_settings ("org.gnome.evolution.mail");
e_content_editor_set_html_mode (cnt_editor, g_settings_get_boolean (settings, "composer-send-html"));
- if (!g_settings_get_boolean (settings, "composer-send-html") &&
- g_settings_get_boolean (settings, "composer-plain-text-starts-preformatted")) {
- g_idle_add_full (G_PRIORITY_LOW, set_preformatted_block_format_on_idle_cb,
- g_object_ref (cnt_editor), g_object_unref);
+ if (g_settings_get_boolean (settings, "composer-plain-text-starts-preformatted")) {
+ g_signal_connect (cnt_editor, "load-finished",
+ G_CALLBACK (set_preformatted_block_format_on_load_finished_cb), NULL);
}
g_object_unref (settings);
diff --git a/src/modules/mail/e-mail-shell-backend.c b/src/modules/mail/e-mail-shell-backend.c
index 277e59b215..b1c756bd67 100644
--- a/src/modules/mail/e-mail-shell-backend.c
+++ b/src/modules/mail/e-mail-shell-backend.c
@@ -518,16 +518,20 @@ mail_shell_backend_window_weak_notify_cb (EShell *shell,
where_the_object_was);
}
-static gboolean
-set_preformatted_block_format_on_idle_cb (gpointer user_data)
+static void
+set_preformatted_block_format_on_load_finished_cb (EContentEditor *cnt_editor,
+ gpointer user_data)
{
- EContentEditor *cnt_editor = user_data;
+ g_return_if_fail (E_IS_CONTENT_EDITOR (cnt_editor));
- g_return_val_if_fail (E_IS_CONTENT_EDITOR (cnt_editor), FALSE);
-
- e_content_editor_set_block_format (cnt_editor, E_CONTENT_EDITOR_BLOCK_FORMAT_PRE);
+ if (!e_content_editor_get_html_mode (cnt_editor)) {
+ e_content_editor_set_block_format (cnt_editor, E_CONTENT_EDITOR_BLOCK_FORMAT_PRE);
+ e_content_editor_set_changed (cnt_editor, FALSE);
+ e_content_editor_clear_undo_redo_history (cnt_editor);
+ }
- return FALSE;
+ g_signal_handlers_disconnect_by_func (cnt_editor,
+ G_CALLBACK (set_preformatted_block_format_on_load_finished_cb), NULL);
}
static void
@@ -568,9 +572,9 @@ mail_shell_backend_window_added_cb (GtkApplication *application,
e_content_editor_set_html_mode (cnt_editor, use_html);
- if (!use_html && use_preformatted) {
- g_idle_add_full (G_PRIORITY_LOW, set_preformatted_block_format_on_idle_cb,
- g_object_ref (cnt_editor), g_object_unref);
+ if (use_preformatted) {
+ g_signal_connect (cnt_editor, "load-finished",
+ G_CALLBACK (set_preformatted_block_format_on_load_finished_cb), NULL);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]