Fixes NB#138240, do not delete content of the email body when switching between from...
[modest] / src / hildon2 / modest-msg-edit-window.c
index b9e5022..b7d2d78 100644 (file)
@@ -4059,6 +4059,8 @@ update_signature (ModestMsgEditWindow *self,
                                                                 &match_start, &match_end, NULL)) {
                                iter = match_start;
                        }
+               } else {
+                       gtk_text_buffer_get_end_iter (priv->text_buffer, &iter);
                }
                g_free (signature);
        }
@@ -4066,7 +4068,9 @@ update_signature (ModestMsgEditWindow *self,
        priv->last_from_account = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->from_field));
        signature = modest_account_mgr_get_signature_from_recipient (mgr, new_account, &has_new_signature);
        if (has_new_signature) {
-               gchar *full_signature = g_strconcat (MODEST_TEXT_UTILS_SIGNATURE_MARKER, "\n",
+
+               gchar *full_signature = g_strconcat ((gtk_text_iter_starts_line (&iter)) ? "" : "\n",
+                                                    MODEST_TEXT_UTILS_SIGNATURE_MARKER, "\n",
                                                     signature, NULL);
                gtk_text_buffer_insert (priv->text_buffer, &iter, full_signature, -1);
                g_free (full_signature);