diff options
-rw-r--r-- | libsylph/prefs_common.c | 1 | ||||
-rw-r--r-- | libsylph/prefs_common.h | 2 | ||||
-rw-r--r-- | src/prefs_common_dialog.c | 7 | ||||
-rw-r--r-- | src/textview.c | 43 |
4 files changed, 42 insertions, 11 deletions
diff --git a/libsylph/prefs_common.c b/libsylph/prefs_common.c index 0c3de0bc..532d1c6d 100644 --- a/libsylph/prefs_common.c +++ b/libsylph/prefs_common.c @@ -337,6 +337,7 @@ static PrefParam param[] = { P_INT}, {"display_header", "TRUE", &prefs_common.display_header, P_BOOL}, {"render_html", "TRUE", &prefs_common.render_html, P_BOOL}, + {"alt_prefer_html", "FALSE", &prefs_common.alt_prefer_html, P_BOOL}, {"html_only_as_attach", "FALSE", &prefs_common.html_only_as_attach, P_BOOL}, {"line_space", "2", &prefs_common.line_space, P_INT}, diff --git a/libsylph/prefs_common.h b/libsylph/prefs_common.h index 266ae13d..e94bc540 100644 --- a/libsylph/prefs_common.h +++ b/libsylph/prefs_common.h @@ -345,6 +345,8 @@ struct _PrefsCommon gboolean enable_newmsg_notify_window; /* Receive */ gboolean nofilter_junk_sender_in_book; /* Junk Mail */ + + gboolean alt_prefer_html; /* Message */ }; extern PrefsCommon prefs_common; diff --git a/src/prefs_common_dialog.c b/src/prefs_common_dialog.c index a917fa32..598c6393 100644 --- a/src/prefs_common_dialog.c +++ b/src/prefs_common_dialog.c @@ -162,6 +162,7 @@ static struct Message { GtkWidget *chkbtn_disphdrpane; GtkWidget *chkbtn_disphdr; GtkWidget *chkbtn_html; + GtkWidget *chkbtn_prefer_html; GtkWidget *chkbtn_htmlonly; GtkWidget *spinbtn_linespc; GtkObject *spinbtn_linespc_adj; @@ -463,6 +464,8 @@ static PrefsUIData ui_data[] = { prefs_set_data_from_toggle, prefs_set_toggle}, {"render_html", &message.chkbtn_html, prefs_set_data_from_toggle, prefs_set_toggle}, + {"alt_prefer_html", &message.chkbtn_prefer_html, + prefs_set_data_from_toggle, prefs_set_toggle}, {"html_only_as_attach", &message.chkbtn_htmlonly, prefs_set_data_from_toggle, prefs_set_toggle}, {"line_space", &message.spinbtn_linespc, @@ -1873,6 +1876,7 @@ static GtkWidget *prefs_message_create(void) GtkWidget *chkbtn_disphdr; GtkWidget *button_edit_disphdr; GtkWidget *chkbtn_html; + GtkWidget *chkbtn_prefer_html; GtkWidget *chkbtn_htmlonly; GtkWidget *hbox_linespc; GtkWidget *label_linespc; @@ -1942,6 +1946,8 @@ static GtkWidget *prefs_message_create(void) PACK_CHECK_BUTTON(vbox2, chkbtn_html, _("Render HTML messages as text")); + PACK_CHECK_BUTTON(vbox2, chkbtn_prefer_html, + _("Prefer HTML in multipart/alternative for display")); PACK_CHECK_BUTTON(vbox2, chkbtn_htmlonly, _("Treat HTML only messages as attachment")); @@ -2023,6 +2029,7 @@ static GtkWidget *prefs_message_create(void) message.chkbtn_disphdrpane = chkbtn_disphdrpane; message.chkbtn_disphdr = chkbtn_disphdr; message.chkbtn_html = chkbtn_html; + message.chkbtn_prefer_html = chkbtn_prefer_html; message.chkbtn_htmlonly = chkbtn_htmlonly; message.spinbtn_linespc = spinbtn_linespc; diff --git a/src/textview.c b/src/textview.c index b40ca56a..627fcdbf 100644 --- a/src/textview.c +++ b/src/textview.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2012 Hiroyuki Yamamoto + * Copyright (C) 1999-2013 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1076,9 +1076,9 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp) } else { /* text part */ gtk_text_buffer_insert(buffer, &iter, "\n", 1); - if (!mimeinfo->main && - mimeinfo->parent && - mimeinfo->parent->children != mimeinfo) + if (mimeinfo->mime_type == MIME_TEXT_HTML || + (!mimeinfo->main && mimeinfo->parent && + mimeinfo->parent->children != mimeinfo)) textview_add_part_widget(textview, &iter, mimeinfo, buf); textview_write_body(textview, mimeinfo, fp, charset); } @@ -1142,13 +1142,34 @@ static void textview_add_parts(TextView *textview, MimeInfo *mimeinfo, FILE *fp) level = mimeinfo->level; for (;;) { - textview_add_part(textview, mimeinfo, fp); - if (mimeinfo->parent && mimeinfo->parent->content_type && - !g_ascii_strcasecmp(mimeinfo->parent->content_type, - "multipart/alternative")) - mimeinfo = mimeinfo->parent->next; - else - mimeinfo = procmime_mimeinfo_next(mimeinfo); + if (mimeinfo->mime_type == MIME_MULTIPART && + mimeinfo->content_type && + !g_ascii_strcasecmp(mimeinfo->content_type, + "multipart/alternative")) { + MimeInfo *preferred_part = mimeinfo->children; + MimeInfo *child; + + if (prefs_common.alt_prefer_html) { + for (child = mimeinfo->children; child != NULL; child = child->next) { + if (child->mime_type == MIME_TEXT_HTML) { + preferred_part = child; + break; + } + } + } + + if (preferred_part) { + textview_add_part(textview, preferred_part, fp); + mimeinfo = preferred_part; + while (mimeinfo->next) + mimeinfo = mimeinfo->next; + } + } else { + textview_add_part(textview, mimeinfo, fp); + } + + mimeinfo = procmime_mimeinfo_next(mimeinfo); + if (!mimeinfo || mimeinfo->level <= level) break; } |