HTML document "attachment" icon



This patch replaces the paper clip icon in the "attachment" column
with a document icon for messages with "Content-Type" of "text/html".

libbalsa/message.c:
	libbalsa_message_has_attachment() now returns FALSE for
	both text/plain and text/html

	libbalsa_message_is_html() added, returns TRUE for
	text/html, FALSE for all others

libbalsa/message.h:
	Added prototype for libbalsa_message_is_html().

src/balsa-icons.c, src/balsa-icons.h, src/pixmaps/html_doc.xpm:
	Create the new "html_doc" icon.

src/balsa-index.c:
	if libbalsa_message_has_attachment() returned FALSE (no
	paper clip icon will be used), call libbalsa_message_is_html()
	to see if an html_doc icon should be used.

Improvements to the icon are welcome...

-- 
Steve Wall
diff -pc ../balsa-1.2.pre3/libbalsa/message.c ./libbalsa/message.c
*** ../balsa-1.2.pre3/libbalsa/message.c	Thu Aug 23 04:22:10 2001
--- ./libbalsa/message.c	Wed Sep  5 15:37:01 2001
*************** libbalsa_message_has_attachment(LibBalsa
*** 903,916 ****
  
      msg_header = CLIENT_CONTEXT(message->mailbox)->hdrs[message->msgno];
  
!     /* FIXME: Can be simplified into 1 if */
!     if (msg_header->content->type != TYPETEXT) {
  	ret = TRUE;
      } else {
! 	if (g_strcasecmp("plain", msg_header->content->subtype) == 0)
! 	    ret = FALSE;
! 	else
! 	    ret = TRUE;
      }
  
      return ret;
--- 903,936 ----
  
      msg_header = CLIENT_CONTEXT(message->mailbox)->hdrs[message->msgno];
  
!     if ((msg_header->content->type == TYPETEXT) &&
! 	((g_strcasecmp("plain", msg_header->content->subtype) == 0) ||
! 	 (g_strcasecmp("html", msg_header->content->subtype) == 0))) {
! 	ret = FALSE;
!     } else {
! 	ret = TRUE;
!     }
! 
!     return ret;
! }
! 
! gboolean
! libbalsa_message_is_html(LibBalsaMessage * message)
! {
!     gboolean ret;
!     HEADER *msg_header;
! 
!     g_return_val_if_fail(LIBBALSA_IS_MESSAGE(message), FALSE);
!     g_return_val_if_fail(message->mailbox, FALSE);
!     g_return_val_if_fail(CLIENT_CONTEXT(message->mailbox)->hdrs, FALSE);
! 
!     msg_header = CLIENT_CONTEXT(message->mailbox)->hdrs[message->msgno];
! 
!     if ((msg_header->content->type == TYPETEXT) &&
! 	(g_strcasecmp("html", msg_header->content->subtype) == 0)) {
  	ret = TRUE;
      } else {
! 	ret = FALSE;
      }
  
      return ret;
diff -pc ../balsa-1.2.pre3/libbalsa/message.h ./libbalsa/message.h
*** ../balsa-1.2.pre3/libbalsa/message.h	Tue Aug 28 04:31:04 2001
--- ./libbalsa/message.h	Wed Sep  5 15:37:01 2001
*************** gchar *libbalsa_message_size_to_gchar(Li
*** 211,216 ****
--- 211,217 ----
  const gchar *libbalsa_message_pathname(LibBalsaMessage * message);
  const gchar *libbalsa_message_charset(LibBalsaMessage * message);
  gboolean libbalsa_message_has_attachment(LibBalsaMessage * message);
+ gboolean libbalsa_message_is_html(LibBalsaMessage * message);
  
  GList *libbalsa_message_user_hdrs(LibBalsaMessage * message);
  
diff -pc ../balsa-1.2.pre3/src/balsa-icons.c ./src/balsa-icons.c
*** ../balsa-1.2.pre3/src/balsa-icons.c	Mon Aug 20 10:14:24 2001
--- ./src/balsa-icons.c	Wed Sep  5 15:37:01 2001
***************
*** 56,61 ****
--- 56,62 ----
  #include "pixmaps/forwarded.xpm"
  #include "pixmaps/envelope.xpm"
  #include "pixmaps/multipart.xpm"
+ #include "pixmaps/html_doc.xpm"
  
  typedef struct _BalsaIcon BalsaIcon;
  struct _BalsaIcon {
*************** static BalsaIcon replied;
*** 79,84 ****
--- 80,86 ----
  static BalsaIcon forwarded;
  static BalsaIcon envelope;
  static BalsaIcon multipart;
+ static BalsaIcon html_doc;
  
  static void
  create_icon(gchar ** data, GdkPixmap ** pmap, GdkBitmap ** bmap)
*************** balsa_icons_init(void)
*** 106,111 ****
--- 108,114 ----
      create_icon(forwarded_xpm, &forwarded.p, &forwarded.b);
      create_icon(envelope_xpm, &envelope.p, &envelope.b);
      create_icon(multipart_xpm, &multipart.p, &multipart.b);
+     create_icon(html_doc_xpm, &html_doc.p, &html_doc.b);
  }
  
  GdkPixmap *
*************** balsa_icon_get_pixmap(BalsaIconName name
*** 128,133 ****
--- 131,137 ----
  	case BALSA_ICON_FORWARDED:	return forwarded.p;
  	case BALSA_ICON_ENVELOPE:	return envelope.p;
  	case BALSA_ICON_MULTIPART:	return multipart.p;
+ 	case BALSA_ICON_HTML_DOC:	return html_doc.p;
      }
  
      return NULL;
*************** balsa_icon_get_bitmap(BalsaIconName name
*** 153,158 ****
--- 157,163 ----
  	case BALSA_ICON_FORWARDED:	return forwarded.b;
  	case BALSA_ICON_ENVELOPE:	return envelope.b;
  	case BALSA_ICON_MULTIPART:	return multipart.b;
+ 	case BALSA_ICON_HTML_DOC:	return html_doc.b;
      }
  
      return NULL;
diff -pc ../balsa-1.2.pre3/src/balsa-icons.h ./src/balsa-icons.h
*** ../balsa-1.2.pre3/src/balsa-icons.h	Mon Aug 20 10:14:24 2001
--- ./src/balsa-icons.h	Wed Sep  5 15:37:01 2001
*************** typedef enum {
*** 56,61 ****
--- 56,62 ----
      BALSA_ICON_FORWARDED,
      BALSA_ICON_ENVELOPE,
      BALSA_ICON_MULTIPART,
+     BALSA_ICON_HTML_DOC,
  } BalsaIconName;
  
  void balsa_icons_init(void);
diff -pc ../balsa-1.2.pre3/src/balsa-index.c ./src/balsa-index.c
*** ../balsa-1.2.pre3/src/balsa-index.c	Tue Aug 28 04:48:14 2001
--- ./src/balsa-index.c	Wed Sep  5 15:37:01 2001
*************** balsa_index_set_col_images(BalsaIndex * 
*** 1075,1080 ****
--- 1075,1086 ----
  	gtk_ctree_node_set_pixmap(ctree, node, 2,
  				  balsa_icon_get_pixmap(BALSA_ICON_MULTIPART),
  				  balsa_icon_get_bitmap(BALSA_ICON_MULTIPART));
+     } else {
+ 	if (libbalsa_message_is_html(message)) {
+ 	    gtk_ctree_node_set_pixmap(ctree, node, 2,
+ 				      balsa_icon_get_pixmap(BALSA_ICON_HTML_DOC),
+ 				      balsa_icon_get_bitmap(BALSA_ICON_HTML_DOC));
+ 	}
      }
  }
  
diff -pc ../balsa-1.2.pre3/src/pixmaps/html_doc.xpm ./src/pixmaps/html_doc.xpm
*** ../balsa-1.2.pre3/src/pixmaps/html_doc.xpm	Wed Sep  5 15:18:11 2001
--- ./src/pixmaps/html_doc.xpm	Wed Sep  5 15:12:47 2001
***************
*** 0 ****
--- 1,28 ----
+ /* XPM */
+ static char *html_doc_xpm[] = {
+ /* width height num_colors chars_per_pixel */
+ "    16    16        5            1",
+ /* colors */
+ "  c None",
+ "# c #000000",
+ "X c #808080",
+ "o c #c0c0c0",
+ ". c #ffffff",
+ /* pixels */
+ "                ",
+ "    ####X       ",
+ "    #...##      ",
+ "    #.Xo#.#     ",
+ "    #...#..X    ",
+ "    #.o.####    ",
+ "    #......#    ",
+ "    #.XooX.#    ",
+ "    #......#    ",
+ "    #.oX.o.#    ",
+ "    #......#    ",
+ "    #.X.Xo.#    ",
+ "    #......#    ",
+ "    #......#    ",
+ "    ########    ",
+ "                "
+ };


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