Subscribed unsubscribe Subscribe Subscribe

SylpheedでHTMLメールと添付ありのメールを区別する

とつぶやいている人がいて、なるほどと思ったので、やってみました。

  • text/plain,text/htmlのみからなるメールについては小さなメールアイコンを表示
  • それ以外は従来通りクリップアイコンを表示

という動作をするようにしてみました。


上記を実現するためのパッチは以下の通りです。

diff -uNr '--exclude=.svn' sylpheed.orig/src/icons/htmlmail.xpm sylpheed.rev/src/icons/htmlmail.xpm
--- sylpheed.orig/src/icons/htmlmail.xpm	1970-01-01 09:00:00.000000000 +0900
+++ sylpheed.rev/src/icons/htmlmail.xpm	2012-08-18 16:29:42.000000000 +0900
@@ -0,0 +1,44 @@
+/* XPM */
+static char *htmlmail_xpm[] = {
+"8 12 28 1",
+" 	c None",
+"B	c #000000",
+"C	c #474747",
+"D	c #F5F5F5",
+"E	c #323232",
+"F	c #F4F4F4",
+"G	c #C1C1C1",
+"H	c #EAEAEA",
+"I	c #EBEBEB",
+"J	c #AAAAAA",
+"K	c #3D3D3D",
+"L	c #EFEFEF",
+"M	c #F3F3F3",
+"N	c #3F3F3F",
+"O	c #464646",
+"P	c #BDBDBD",
+"Q	c #D6D6D6",
+"R	c #A0A0A0",
+"S	c #F2F2F2",
+"T	c #BABABA",
+"U	c #E9E9E9",
+"V	c #8C8C8C",
+"W	c #BFBFBF",
+"X	c #DADADA",
+"Y	c #CDCDCD",
+"Z	c #A7A7A7",
+"a	c #D3D3D3",
+"b	c #282828",
+"        ",
+"        ",
+"        ",
+" BBBBBB ",
+"BBDDDDBB",
+"BDCLDCDB",
+"BDDCCDDB",
+"BDCGGCDB",
+"BCDDDDCB",
+" BBBBBB ",
+"        ",
+"        "
+};
diff -uNr '--exclude=.svn' sylpheed.orig/src/stock_pixmap.c sylpheed.rev/src/stock_pixmap.c
--- sylpheed.orig/src/stock_pixmap.c	2012-08-18 16:28:20.000000000 +0900
+++ sylpheed.rev/src/stock_pixmap.c	2012-08-18 16:29:20.000000000 +0900
@@ -34,6 +34,7 @@
 #include "icons/deleted.xpm"
 #include "icons/error.xpm"
 #include "icons/forwarded.xpm"
+#include "icons/htmlmail.xpm"
 #include "icons/interface.xpm"
 #include "icons/jpilot.xpm"
 #include "icons/ldap.xpm"
@@ -110,6 +111,7 @@
 	{error_xpm	 , NULL, NULL},
 	{forwarded_xpm	 , NULL, NULL},
 	{NULL, NULL, NULL, NULL, group, sizeof(group), "group", 0},
+	{htmlmail_xpm	 , NULL, NULL},
 	{interface_xpm	 , NULL, NULL},
 	{jpilot_xpm	 , NULL, NULL},
 	{ldap_xpm	 , NULL, NULL},
diff -uNr '--exclude=.svn' sylpheed.orig/src/stock_pixmap.h sylpheed.rev/src/stock_pixmap.h
--- sylpheed.orig/src/stock_pixmap.h	2012-08-18 16:28:20.000000000 +0900
+++ sylpheed.rev/src/stock_pixmap.h	2012-08-18 16:29:20.000000000 +0900
@@ -38,6 +38,7 @@
 	STOCK_PIXMAP_ERROR,
 	STOCK_PIXMAP_FORWARDED,
 	STOCK_PIXMAP_GROUP,
+	STOCK_PIXMAP_HTMLMAIL,
 	STOCK_PIXMAP_INTERFACE,
 	STOCK_PIXMAP_JPILOT,
 	STOCK_PIXMAP_LDAP,
diff -uNr '--exclude=.svn' sylpheed.orig/src/summaryview.c sylpheed.rev/src/summaryview.c
--- sylpheed.orig/src/summaryview.c	2012-08-18 16:28:20.000000000 +0900
+++ sylpheed.rev/src/summaryview.c	2012-08-18 16:38:22.000000000 +0900
@@ -139,6 +139,7 @@
 static GdkPixbuf *forwarded_pixbuf;
 
 static GdkPixbuf *clip_pixbuf;
+static GdkPixbuf *htmlmail_pixbuf;
 
 static void summary_clear_list_full	(SummaryView		*summaryview,
 					 gboolean		 is_refresh);
@@ -624,6 +625,8 @@
 			 &forwarded_pixbuf);
 	stock_pixbuf_gdk(summaryview->treeview, STOCK_PIXMAP_CLIP,
 			 &clip_pixbuf);
+	stock_pixbuf_gdk(summaryview->treeview, STOCK_PIXMAP_HTMLMAIL,
+			 &htmlmail_pixbuf);
 
 	font_desc = pango_font_description_new();
 	size = pango_font_description_get_size
@@ -2416,6 +2419,7 @@
 	MsgFlags flags;
 	GdkColor color;
 	gint color_val;
+	MimeInfo *mimeinfo = NULL;
 
 	if (!msginfo) {
 		GET_MSG_INFO(msginfo, iter);
@@ -2473,8 +2477,23 @@
 	else if (MSG_IS_FORWARDED(flags))
 		unread_pix = forwarded_pixbuf;
 
-	if (MSG_IS_MIME(flags))
-		mime_pix = clip_pixbuf;
+	if (MSG_IS_MIME(flags)) {
+		mimeinfo = procmime_scan_message(msginfo);
+		while (mimeinfo) {
+			if (mimeinfo->mime_type != MIME_TEXT &&
+			    mimeinfo->mime_type != MIME_TEXT_HTML &&
+			    mimeinfo->mime_type != MIME_MULTIPART) {
+				break;
+			} else {
+				mimeinfo = procmime_mimeinfo_next(mimeinfo);
+			}
+		}
+		if (mimeinfo) {
+			mime_pix = clip_pixbuf;
+		} else {
+			mime_pix = htmlmail_pixbuf;
+		}
+	}
 
 	if (prefs_common.bold_unread) {
 		if (MSG_IS_UNREAD(flags))