[evolution/gnome-3-30] I#154 - Mail signature is changed when reopening an email in the Drafts/Outbox



commit 56daf41482db8c4ce2f403a34fa65c83ef3e6e7b
Author: Milan Crha <mcrha redhat com>
Date:   Tue Nov 27 14:35:34 2018 +0100

    I#154 - Mail signature is changed when reopening an email in the Drafts/Outbox
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/154

 src/composer/e-composer-private.c | 22 ++++++++++++++++++++--
 src/composer/e-msg-composer.c     |  9 +++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/src/composer/e-composer-private.c b/src/composer/e-composer-private.c
index 5475ae7c68..4e7df769d6 100644
--- a/src/composer/e-composer-private.c
+++ b/src/composer/e-composer-private.c
@@ -705,8 +705,26 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
                &composer->priv->check_if_signature_is_changed,
                &composer->priv->ignore_next_signature_change);
 
-       if (new_signature_id && *new_signature_id)
-               gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo_box), new_signature_id);
+       if (new_signature_id && *new_signature_id) {
+               gboolean been_ignore = composer->priv->ignore_next_signature_change;
+               gboolean signature_changed = g_strcmp0 (gtk_combo_box_get_active_id (GTK_COMBO_BOX 
(combo_box)), new_signature_id) != 0;
+
+               composer->priv->ignore_next_signature_change = been_ignore && signature_changed;
+
+               if (!gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo_box), new_signature_id)) {
+                       signature_changed = g_strcmp0 (gtk_combo_box_get_active_id (GTK_COMBO_BOX 
(combo_box)), "none") != 0;
+
+                       composer->priv->ignore_next_signature_change = been_ignore && signature_changed;
+
+                       gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo_box), "none");
+               }
+
+               if (!signature_changed && composer->priv->check_if_signature_is_changed) {
+                       composer->priv->set_signature_from_message = FALSE;
+                       composer->priv->check_if_signature_is_changed = FALSE;
+                       composer->priv->ignore_next_signature_change = FALSE;
+               }
+       }
 
        g_free (new_signature_id);
        g_free (contents);
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index 97e50738c9..9f56b99426 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -3669,6 +3669,7 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
        gint len, i;
        guint jj, jjlen;
        gboolean is_message_from_draft = FALSE;
+       gboolean is_editor_ready;
 
        g_return_if_fail (E_IS_MSG_COMPOSER (composer));
 
@@ -4028,12 +4029,20 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
 
        priv->set_signature_from_message = TRUE;
 
+       is_editor_ready = e_content_editor_is_ready (cnt_editor);
+
        /* We wait until now to set the body text because we need to
         * ensure that the attachment bar has all the attachments before
         * we request them. */
        e_msg_composer_flush_pending_body (composer);
 
        set_signature_gui (composer);
+
+       /* This makes sure the signature is used from the real message body,
+          not from the empty body when the composer is in the HTML mode */
+       if (!is_editor_ready)
+               priv->set_signature_from_message = TRUE;
+
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]