[evolution/gnome-3-22] Bug 772916 - Composer incorrectly warns about switching from HTML to text when a message snippet is



commit 13d7169975c9b9c1967a6282f8dff6760721a8d7
Author: Tomas Popela <tpopela redhat com>
Date:   Mon Oct 17 13:10:39 2016 +0200

    Bug 772916 - Composer incorrectly warns about switching from HTML to text when a message snippet is 
selected
    
    Don't always try to get the currently selected content as text/html, but
    if the currently displayed message is a plain text one then get it as
    text/plain.

 mail/e-mail-reader-utils.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index b23d51d..115533f 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -2393,12 +2393,14 @@ e_mail_reader_reply_to_message (EMailReader *reader,
        EMailDisplay *display;
        EMailPartList *part_list = NULL;
        GtkWidget *message_list;
+       CamelContentType *content_type;
        CamelMimeMessage *new_message;
        CamelInternetAddress *address = NULL;
        CamelFolder *folder;
        EMailReplyStyle reply_style;
        EWebView *web_view;
        struct _camel_header_raw *header;
+       gboolean src_is_html = FALSE;
        const gchar *uid;
        gchar *selection = NULL;
        gint length;
@@ -2501,7 +2503,13 @@ e_mail_reader_reply_to_message (EMailReader *reader,
        if (!e_web_view_is_selection_active (web_view))
                goto whole_message;
 
-       selection = e_web_view_get_selection_content_html_sync (web_view, NULL, NULL);
+       content_type = camel_mime_part_get_content_type (CAMEL_MIME_PART (src_message));
+       src_is_html = camel_content_type_is (content_type, "text", "html");
+
+       if (src_is_html)
+               selection = e_web_view_get_selection_content_html_sync (web_view, NULL, NULL);
+       else
+               selection = g_strdup (e_mail_display_get_selection_plain_text_sync (display, NULL, NULL));
        if (selection == NULL || *selection == '\0')
                goto whole_message;
 
@@ -2532,7 +2540,9 @@ e_mail_reader_reply_to_message (EMailReader *reader,
 
        camel_mime_part_set_content (
                CAMEL_MIME_PART (new_message),
-               selection, length, "text/html; charset=utf-8");
+               selection,
+               length,
+               src_is_html ? "text/html; charset=utf-8" : "text/plain; charset=utf-8");
 
        ccd = g_new0 (CreateComposerData, 1);
        ccd->reader = g_object_ref (reader);


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