aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2013-05-14 09:17:37 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2013-05-14 09:17:37 +0000
commit3b87da252f54406f6ded41f0b45f6f6d7dacc15b (patch)
tree0047c8d4b0f462f50e501448eda5772a6dd7a049 /src
parent0efce4ac1ec396cd9d389a607c2a69bbd505dd8a (diff)
added an option to prefer HTML part in multipart/alternative.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3253 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/prefs_common_dialog.c7
-rw-r--r--src/textview.c43
2 files changed, 39 insertions, 11 deletions
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;
}