0.9.9claws1
[claws.git] / src / mimeview.c
index d196550ec1e37ec697454d2a4f2d84f51a71ef81..121a0d3d40926117cc1991688d8fa6826e67633b 100644 (file)
@@ -347,8 +347,6 @@ void mimeview_show_message(MimeView *mimeview, MimeInfo *mimeinfo,
                icon_list_toggle_by_mime_info
                        (mimeview, gtk_ctree_node_get_row_data(ctree, node));
                gtkut_ctree_set_focus_row(ctree, node);
-               if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mimeview->mime_toggle)))
-                       gtk_widget_grab_focus(mimeview->ctree);
        }
 }
 
@@ -396,25 +394,25 @@ static void mimeview_set_multipart_tree(MimeView *mimeview,
        }
 }
 
-static gchar *get_part_name(MimeInfo *partinfo)
+static const gchar *get_part_name(MimeInfo *partinfo)
 {
-       gchar *name;
+       const gchar *name;
 
-       name = g_hash_table_lookup(partinfo->parameters, "name");
-       if(name == NULL)
+       name = procmime_mimeinfo_get_parameter(partinfo, "filename");
+       if (name == NULL)
+               name = procmime_mimeinfo_get_parameter(partinfo, "name");
+       if (name == NULL)
                name = "";
 
        return name;
 }
 
-static gchar *get_part_description(MimeInfo *partinfo)
+static const gchar *get_part_description(MimeInfo *partinfo)
 {
        if (partinfo->description)
                return partinfo->description;
-       else if (g_hash_table_lookup(partinfo->parameters, "name") != NULL)
-               return g_hash_table_lookup(partinfo->parameters, "name");
        else
-               return "";
+               return get_part_name(partinfo);
 }
 
 static GtkCTreeNode *mimeview_append_part(MimeView *mimeview,
@@ -435,9 +433,9 @@ static GtkCTreeNode *mimeview_append_part(MimeView *mimeview,
        str[COL_MIMETYPE] = content_type;
        str[COL_SIZE] = to_human_readable(partinfo->length);
        if (prefs_common.attach_desc)
-               str[COL_NAME] = get_part_description(partinfo);
+               str[COL_NAME] = (gchar *) get_part_description(partinfo);
        else
-               str[COL_NAME] = get_part_name(partinfo);
+               str[COL_NAME] = (gchar *) get_part_name(partinfo);
 
        node = gtk_ctree_insert_node(ctree, parent, NULL, str, 0,
                                     NULL, NULL, NULL, NULL,
@@ -496,8 +494,8 @@ static MimeViewer *get_viewer_for_content_type(MimeView *mimeview, const gchar *
                gint i = 0;
 
                while (curfactory->content_types[i] != NULL) {
-                       debug_print("%s\n", curfactory->content_types[i]);
                        if(!fnmatch(curfactory->content_types[i], content_type, FNM_CASEFOLD)) {
+                               debug_print("%s\n", curfactory->content_types[i]);
                                factory = curfactory;
                                break;
                        }
@@ -530,9 +528,14 @@ static MimeViewer *get_viewer_for_mimeinfo(MimeView *mimeview, MimeInfo *partinf
        MimeViewer *viewer = NULL;
 
        if ((partinfo->type == MIMETYPE_APPLICATION) &&
-            (g_strcasecmp(partinfo->subtype, "octet-stream")) &&
-           (partinfo->name != NULL)) {
-               content_type = procmime_get_mime_type(partinfo->name);
+            (!g_strcasecmp(partinfo->subtype, "octet-stream"))) {
+               const gchar *filename;
+
+               filename = procmime_mimeinfo_get_parameter(partinfo, "filename");
+               if (filename == NULL)
+                       filename = procmime_mimeinfo_get_parameter(partinfo, "name");
+               if (filename != NULL)
+                       content_type = procmime_get_mime_type(filename);
        } else {
                content_type = g_strdup_printf("%s/%s", procmime_get_type_str(partinfo->type), partinfo->subtype);
        }
@@ -617,58 +620,100 @@ void mimeview_clear(MimeView *mimeview)
 }
 
 static void check_signature_cb(GtkWidget *widget, gpointer user_data);
+static void display_full_info_cb(GtkWidget *widget, gpointer user_data);
 
 static void update_signature_noticeview(MimeView *mimeview, MimeInfo *mimeinfo)
 {
-       if (privacy_mimeinfo_is_signed(mimeinfo)) {
-               gchar *text = NULL, *button_text = NULL;
-               GtkSignalFunc func = NULL;
-               StockPixmap icon;
-               
-               switch (privacy_mimeinfo_get_sig_status(mimeinfo)) {
-               case SIGNATURE_UNCHECKED:
-                       button_text = _("Check");
-                       func = check_signature_cb;
-                       icon = STOCK_PIXMAP_PRIVACY_SIGNED;
-                       break;
-               case SIGNATURE_OK:
-                       icon = STOCK_PIXMAP_PRIVACY_PASSED;
-                       break;
-               case SIGNATURE_WARN:
-                       icon = STOCK_PIXMAP_PRIVACY_WARN;
-                       break;
-               case SIGNATURE_INVALID:
-                       icon = STOCK_PIXMAP_PRIVACY_FAILED;
-                       break;
-               case SIGNATURE_CHECK_FAILED:
-                       button_text = _("Check again");
-                       func = check_signature_cb;
-                       icon = STOCK_PIXMAP_PRIVACY_UNKNOWN;
-               default:
-                       break;
-               }
-               text = privacy_mimeinfo_sig_info_short(mimeinfo);
-               noticeview_set_text(mimeview->siginfoview, text);
-               g_free(text);
-               noticeview_set_button_text(mimeview->siginfoview, button_text);
-               noticeview_set_button_press_callback(
-                       mimeview->siginfoview,
-                       func,
-                       (gpointer) mimeview);
-               noticeview_set_icon(mimeview->siginfoview, icon);
-               noticeview_show(mimeview->siginfoview);
-       } else {
-               noticeview_hide(mimeview->siginfoview);
+       gchar *text = NULL, *button_text = NULL;
+       GtkSignalFunc func = NULL;
+       StockPixmap icon = STOCK_PIXMAP_PRIVACY_SIGNED;
+
+       g_return_if_fail(mimeview != NULL);
+       g_return_if_fail(mimeinfo != NULL);
+       
+       switch (privacy_mimeinfo_get_sig_status(mimeinfo)) {
+       case SIGNATURE_UNCHECKED:
+               button_text = _("Check");
+               func = check_signature_cb;
+               icon = STOCK_PIXMAP_PRIVACY_SIGNED;
+               break;
+       case SIGNATURE_OK:
+               button_text = _("Full info");
+               func = display_full_info_cb;
+               icon = STOCK_PIXMAP_PRIVACY_PASSED;
+               break;
+       case SIGNATURE_WARN:
+               button_text = _("Full info");
+               func = display_full_info_cb;
+               icon = STOCK_PIXMAP_PRIVACY_WARN;
+               break;
+       case SIGNATURE_INVALID:
+               button_text = _("Full info");
+               func = display_full_info_cb;
+               icon = STOCK_PIXMAP_PRIVACY_FAILED;
+               break;
+       case SIGNATURE_CHECK_FAILED:
+               button_text = _("Check again");
+               func = check_signature_cb;
+               icon = STOCK_PIXMAP_PRIVACY_UNKNOWN;
+       default:
+               break;
        }
+       text = privacy_mimeinfo_sig_info_short(mimeinfo);
+       noticeview_set_text(mimeview->siginfoview, text);
+       g_free(text);
+       noticeview_set_button_text(mimeview->siginfoview, button_text);
+       noticeview_set_button_press_callback(
+               mimeview->siginfoview,
+               func,
+               (gpointer) mimeview);
+       noticeview_set_icon(mimeview->siginfoview, icon);
 }
 
 static void check_signature_cb(GtkWidget *widget, gpointer user_data)
 {
        MimeView *mimeview = (MimeView *) user_data;
-       MimeInfo *mimeinfo = mimeview_get_selected_part(mimeview);
+       MimeInfo *mimeinfo = mimeview->siginfo;
        
        privacy_mimeinfo_check_signature(mimeinfo);
-       update_signature_noticeview(mimeview, mimeinfo);
+       update_signature_noticeview(mimeview, mimeview->siginfo);
+       icon_list_clear(mimeview);
+       icon_list_create(mimeview, mimeview->mimeinfo);
+}
+
+static void display_full_info_cb(GtkWidget *widget, gpointer user_data)
+{
+       MimeView *mimeview = (MimeView *) user_data;
+       gchar *siginfo;
+
+       siginfo = privacy_mimeinfo_sig_info_full(mimeview->siginfo);
+       textview_set_text(mimeview->textview, siginfo);
+       g_free(siginfo);
+       noticeview_set_button_text(mimeview->siginfoview, NULL);
+}
+
+static void update_signature_info(MimeView *mimeview, MimeInfo *selected)
+{
+       MimeInfo *siginfo;
+
+       g_return_if_fail(mimeview != NULL);
+       g_return_if_fail(selected != NULL);
+       
+       siginfo = selected;
+       while (siginfo != NULL) {
+               if (privacy_mimeinfo_is_signed(siginfo))
+                       break;
+               siginfo = procmime_mimeinfo_parent(siginfo);
+       }
+       mimeview->siginfo = siginfo;
+       
+       if (siginfo == NULL) {
+               noticeview_hide(mimeview->siginfoview);
+               return;
+       }
+       
+       update_signature_noticeview(mimeview, siginfo);
+       noticeview_show(mimeview->siginfoview);
 }
 
 static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column,
@@ -692,7 +737,7 @@ static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column,
        
        mimeview->textview->default_text = FALSE;
 
-       update_signature_noticeview(mimeview, partinfo);
+       update_signature_info(mimeview, partinfo);
 
        if (!mimeview_show_part(mimeview, partinfo)) {
                switch (partinfo->type) {
@@ -720,7 +765,7 @@ static void mimeview_start_drag(GtkWidget *widget, gint button,
        g_return_if_fail(mimeview != NULL);
 
        partinfo = mimeview_get_selected_part(mimeview);
-       if (partinfo->filename == NULL && partinfo->name == NULL) return;
+       if (partinfo->disposition == DISPOSITIONTYPE_INLINE) return;
 
        context = gtk_drag_begin(widget, mimeview->target_list,
                                 GDK_ACTION_COPY, button, event);
@@ -766,7 +811,8 @@ static void part_button_pressed(MimeView *mimeview, GdkEventButton *event,
                        menu_set_sensitive(mimeview->popupfactory,
                                           "/Display as text", TRUE);
                if (partinfo &&
-                   partinfo->type == MIMETYPE_APPLICATION)
+                   partinfo->type == MIMETYPE_APPLICATION &&
+                   !g_strcasecmp(partinfo->subtype, "octet-stream"))
                        menu_set_sensitive(mimeview->popupfactory,
                                           "/Open", FALSE);
                else
@@ -860,6 +906,11 @@ static gint mimeview_key_pressed(GtkWidget *widget, GdkEventKey *event,
                KEY_PRESS_EVENT_STOP();
                mimeview_launch(mimeview);
                return TRUE;
+       case GDK_o:
+               BREAK_ON_MODIFIER_KEY();
+               KEY_PRESS_EVENT_STOP();
+               mimeview_open_with(mimeview);
+               return TRUE;
        default:
                break;
        }
@@ -885,10 +936,8 @@ static void mimeview_drag_data_get(GtkWidget           *widget,
 
        partinfo = mimeview_get_selected_part(mimeview);
        if (!partinfo) return;
-       if (!partinfo->filename && !partinfo->name) return;
 
-       filename = partinfo->filename ? partinfo->filename : partinfo->name;
-       filename = g_basename(filename);
+       filename = g_basename(get_part_name(partinfo));
        if (*filename == '\0') return;
 
        filename = g_strconcat(get_mime_tmp_dir(), G_DIR_SEPARATOR_S,
@@ -910,15 +959,14 @@ static void mimeview_save_all(MimeView *mimeview)
 {
        gchar *dirname;
        gchar *defname = NULL;
-       MimeInfo *partinfo;
        MimeInfo *attachment;
        gchar buf[1024];
 
        if (!mimeview->opened) return;
        if (!mimeview->file) return;
 
-       partinfo = mimeview_get_selected_part(mimeview);
-       g_return_if_fail(partinfo != NULL);
+       attachment = mimeview->mimeinfo;
+       g_return_if_fail(attachment != NULL);
 
        dirname = filesel_select_file(_("Save as"), defname);
        if (!dirname) return;
@@ -927,6 +975,7 @@ static void mimeview_save_all(MimeView *mimeview)
                alertpanel_error(_("`%s' is not a directory."),
                                 dirname);
                g_free (dirname);
+               dirname = NULL;
                return;
        }
        
@@ -941,43 +990,43 @@ static void mimeview_save_all(MimeView *mimeview)
                }
        }
 
-       /* return to first children */
-       if (partinfo->node->parent->children == NULL) return;  /* multipart container? */
-       attachment = partinfo->node->parent->children->next != NULL ?
-           (MimeInfo *) partinfo->node->parent->children->next->data : NULL;
        /* for each attachment, extract it in the selected dir. */
        while (attachment != NULL) {
-               static guint subst_cnt = 1;
-               gchar *attachdir;
-               gchar *attachname = g_strdup(get_part_name(attachment));
-               AlertValue aval = G_ALERTDEFAULT;
-               gchar *res;
-
-               if (!attachname || !strlen(attachname))
-                       attachname = g_strdup_printf("noname.%d",subst_cnt++);
-               subst_chars(attachname, ":?*&|<>\t\r\n", '_');
-               g_snprintf(buf, sizeof(buf), "%s%s",
-                          dirname,
-                          (attachname[0] == G_DIR_SEPARATOR)
-                          ? &attachname[1]
-                          : attachname);
-               subst_chars(buf, "/\\", G_DIR_SEPARATOR);
-               attachdir = g_dirname(buf);
-               make_dir_hier(attachdir);
-               g_free(attachdir);
-
-               if (is_file_exist(buf)) {
-                       res = g_strdup_printf(_("Overwrite existing file '%s'?"),
-                                             attachname);
-                       aval = alertpanel(_("Overwrite"), res, _("OK"), 
-                                         _("Cancel"), NULL);
-                       g_free(res);                                      
+               if (attachment->type != MIMETYPE_MESSAGE &&
+                   attachment->type != MIMETYPE_MULTIPART &&
+                   attachment->disposition != DISPOSITIONTYPE_INLINE) {
+                       static guint subst_cnt = 1;
+                       gchar *attachdir;
+                       gchar *attachname = g_strdup(get_part_name(attachment));
+                       AlertValue aval = G_ALERTDEFAULT;
+                       gchar *res;
+
+                       if (!attachname || !strlen(attachname))
+                               attachname = g_strdup_printf("noname.%d",subst_cnt++);
+                       subst_chars(attachname, ":?*&|<>\t\r\n", '_');
+                       g_snprintf(buf, sizeof(buf), "%s%s",
+                                  dirname,
+                                  (attachname[0] == G_DIR_SEPARATOR)
+                                  ? &attachname[1]
+                                  : attachname);
+                       subst_chars(buf, "/\\", G_DIR_SEPARATOR);
+                       attachdir = g_dirname(buf);
+                       make_dir_hier(attachdir);
+                       g_free(attachdir);
+                       
+                       if (is_file_exist(buf)) {
+                               res = g_strdup_printf(_("Overwrite existing file '%s'?"),
+                                                     attachname);
+                               aval = alertpanel(_("Overwrite"), res, _("OK"), 
+                                                 _("Cancel"), NULL);
+                               g_free(res);                                      
+                       }
+                       g_free(attachname);
+                       
+                       if ((G_ALERTDEFAULT != aval) || (procmime_get_part(buf, attachment) < 0))
+                               alertpanel_error(_("Can't save the part of multipart message."));
                }
-               g_free(attachname);
-
-               if ((G_ALERTDEFAULT != aval) || (procmime_get_part(buf, attachment) < 0))
-                       alertpanel_error(_("Can't save the part of multipart message."));
-               attachment = attachment->node->next != NULL ? (MimeInfo *) attachment->node->next->data : NULL;
+               attachment = procmime_mimeinfo_next(attachment);
        }
 }
 
@@ -1004,15 +1053,12 @@ static void mimeview_save_as(MimeView *mimeview)
 {
        gchar *filename;
        gchar *defname = NULL;
-       MsgInfo *msginfo;
        MimeInfo *partinfo;
        gchar *res;
        const gchar *partname = NULL;
 
        if (!mimeview->opened) return;
        if (!mimeview->file) return;
-       if (!mimeview->messageview->msginfo) return;
-       msginfo = mimeview->messageview->msginfo;
 
        partinfo = mimeview_get_selected_part(mimeview);
        if (!partinfo) { 
@@ -1024,14 +1070,11 @@ static void mimeview_save_as(MimeView *mimeview)
        }                        
        g_return_if_fail(partinfo != NULL);
        
-       if (partname = procmime_mimeinfo_get_parameter(partinfo, "name")) {
+       if ((partname = get_part_name(partinfo)) != NULL) {
                Xstrdup_a(defname, partname, return);
                subst_for_filename(defname);
-       } else if (msginfo->subject) {
-               Xstrdup_a(defname, msginfo->subject, return);
-               subst_for_filename(defname);
        }
-       
+
        filename = filesel_select_file(_("Save as"), defname);
        if (!filename) return;
        if (is_file_exist(filename)) {
@@ -1144,7 +1187,8 @@ static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
        if (cmdline) {
                cmd = cmdline;
                def_cmd = NULL;
-       } else if (MIMETYPE_APPLICATION == partinfo->type) {
+       } else if (MIMETYPE_APPLICATION == partinfo->type &&
+                  !g_strcasecmp(partinfo->subtype, "octet-stream")) {
                return;
        } else if (MIMETYPE_IMAGE == partinfo->type) {
                cmd = prefs_common.mime_image_viewer;
@@ -1221,15 +1265,17 @@ static gboolean icon_clicked_cb (GtkWidget *button, GdkEventButton *event, MimeV
 
        num      = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(button), "icon_number"));
        partinfo = gtk_object_get_data(GTK_OBJECT(button), "partinfo");
-       if (event->button == 1) { 
-               icon_selected(mimeview, num, partinfo);
-               gtk_widget_grab_focus(button);
-               
-               if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
-                       toggle_icon(GTK_TOGGLE_BUTTON(button), mimeview);
-               else
-                       gtk_signal_emit_stop_by_name(GTK_OBJECT(button), "button_press_event");
-       }               
+
+       icon_selected(mimeview, num, partinfo);
+       gtk_widget_grab_focus(button);
+       if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) {
+               toggle_icon(GTK_TOGGLE_BUTTON(button), mimeview);
+               if (event->button == 2 || event->button == 3)
+                       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
+                                                    TRUE);
+       } else {
+               gtk_signal_emit_stop_by_name(GTK_OBJECT(button), "button_press_event");
+       }
 
        part_button_pressed(mimeview, event, partinfo);
 
@@ -1331,6 +1377,11 @@ static gint icon_key_pressed(GtkWidget *button, GdkEventKey *event,
                KEY_PRESS_EVENT_STOP();
                mimeview_launch(mimeview);
                return TRUE;
+       case GDK_o:
+               BREAK_ON_MODIFIER_KEY();
+               KEY_PRESS_EVENT_STOP();
+               mimeview_open_with(mimeview);
+               return TRUE;
        default:
                break;
        }
@@ -1356,13 +1407,158 @@ static void toggle_icon(GtkToggleButton *button, MimeView *mimeview)
        }
 }
 
+static GdkColor nocheck_sig_color = {
+       (gulong)0,
+       (gushort)0,
+       (gushort)0,
+       (gushort)0xcfff
+};
+
+static GdkColor good_sig_color = {
+       (gulong)0,
+       (gushort)0,
+       (gushort)0xbfff,
+       (gushort)0
+};
+
+static GdkColor bad_sig_color = {
+       (gulong)0,
+       (gushort)0xffff,
+       (gushort)0,
+       (gushort)0
+};
+
+#define COLOR_BORDER 3
+
+static gboolean icon_drawing_area_expose_event_cb (GtkWidget *widget, GdkEventExpose *expose,
+                                                  gpointer data) 
+{
+       GdkColor *color = (GdkColor *)data;
+       GdkDrawable *drawable = widget->window; 
+       GdkGC *gc_pix;
+       GdkPixmap *stock_pixmap;
+       GdkBitmap *stock_mask;
+
+       stock_pixmap = (GdkPixmap *)gtk_object_get_data(GTK_OBJECT(widget), "pixmap");
+       stock_mask   = (GdkBitmap *)gtk_object_get_data(GTK_OBJECT(widget), "mask");
+       
+       g_return_val_if_fail(stock_pixmap != NULL, FALSE);
+       g_return_val_if_fail(stock_mask != NULL, FALSE);
+
+       gc_pix = gdk_gc_new((GdkWindow *)drawable);
+                                                
+       gdk_window_clear_area (drawable, expose->area.x, expose->area.y,
+                              expose->area.width, expose->area.height);
+
+       if (color != NULL) {
+               gdk_gc_set_foreground(gc_pix, color);
+               if (color == &good_sig_color) {
+                       gdk_draw_rectangle(drawable, gc_pix, TRUE, 0 , 0, 
+                                          widget->allocation.width,
+                                          widget->allocation.height);
+               } else {
+                       gdk_gc_set_line_attributes(gc_pix, COLOR_BORDER - 1, GDK_LINE_ON_OFF_DASH, 
+                                                  GDK_CAP_BUTT, GDK_JOIN_MITER);
+                       gdk_draw_rectangle(drawable, gc_pix, FALSE, 1 , 1, 
+                                          widget->allocation.width - 2,
+                                          widget->allocation.height - 2);
+               }
+       }
+
+#define LEFT COLOR_BORDER + widget->allocation.width - widget->requisition.width
+#define TOP  COLOR_BORDER + widget->allocation.height - widget->requisition.height   
+
+       gdk_gc_set_tile(gc_pix, stock_pixmap);
+       gdk_gc_set_ts_origin(gc_pix, LEFT, TOP);
+       gdk_gc_set_clip_mask(gc_pix, stock_mask);
+       gdk_gc_set_clip_origin(gc_pix, LEFT, TOP);
+       gdk_gc_set_fill(gc_pix, GDK_TILED);
+       gdk_draw_rectangle(drawable, gc_pix, TRUE, LEFT, TOP, 
+                          widget->requisition.width - COLOR_BORDER * 2,
+                          widget->requisition.height - COLOR_BORDER * 2);
+
+       gdk_gc_destroy(gc_pix);
+       
+       return TRUE;
+
+}
+
+static GtkWidget* icon_stock_pixmap_with_privacy (GtkWidget *window, StockPixmap icon,
+                                                 MimeInfo *mimeinfo)
+{
+       GdkPixmap *stock_pixmap;
+       GdkBitmap *stock_mask;
+       GtkWidget *widget;
+       GtkWidget *stock_wid;
+       GdkColor *color = NULL;
+       MimeInfo *siginfo;
+       gboolean is_signed = FALSE;
+       gint height;
+       gint width;
+
+       siginfo = mimeinfo;
+       while (siginfo != NULL) {
+               if (privacy_mimeinfo_is_signed(siginfo)) {
+                       is_signed = TRUE;
+                       if (prefs_common.auto_check_signatures &&
+                           (privacy_mimeinfo_get_sig_status(siginfo) == SIGNATURE_UNCHECKED))
+                               privacy_mimeinfo_check_signature(siginfo);
+                       break;
+               }
+               siginfo = procmime_mimeinfo_parent(siginfo);
+       }
+       
+       stock_wid = stock_pixmap_widget(window, icon);
+       gtk_pixmap_get(GTK_PIXMAP(stock_wid), &stock_pixmap, &stock_mask);
+       height = stock_wid->requisition.height;
+       width  = stock_wid->requisition.width;
+       gdk_pixmap_ref(stock_pixmap);
+       gdk_pixmap_ref(stock_mask);
+       gtk_widget_destroy(stock_wid);
+
+       widget = gtk_drawing_area_new();
+       gtk_drawing_area_size(GTK_DRAWING_AREA(widget), 
+                             width + COLOR_BORDER * 2, 
+                             height +  COLOR_BORDER * 2);
+       gtk_object_set_data_full(GTK_OBJECT(widget), "pixmap", stock_pixmap,
+                                (GtkDestroyNotify)gdk_pixmap_unref);
+       gtk_object_set_data_full(GTK_OBJECT(widget), "mask", stock_mask,
+                                (GtkDestroyNotify)gdk_pixmap_unref);
+
+       if (is_signed) {
+               switch (privacy_mimeinfo_get_sig_status(siginfo)) {
+               case SIGNATURE_UNCHECKED:
+                       color = &nocheck_sig_color;
+                       break;
+               case SIGNATURE_OK:
+                       color = &good_sig_color;
+                       break;
+               default:
+                       color = &bad_sig_color;
+                       break;
+               }
+               if (!color->pixel) 
+                       gdk_colormap_alloc_color(gtk_widget_get_colormap(widget),
+                                                color, FALSE, TRUE);
+       } else {
+               color = NULL;
+       }
+       gtk_signal_connect(GTK_OBJECT(widget), "expose_event", 
+                          GTK_SIGNAL_FUNC
+                               (icon_drawing_area_expose_event_cb),
+                          color);
+       return widget;
+}
+
+#undef COLOR_BORDER
+
 static void icon_list_append_icon (MimeView *mimeview, MimeInfo *mimeinfo) 
 {
        GtkWidget *pixmap;
        GtkWidget *vbox;
        GtkWidget *button;
        gchar *tip;
-       gchar *desc = NULL;
+       const gchar *desc = NULL;
        StockPixmap stockp;
        
        vbox = mimeview->icon_vbox;
@@ -1401,7 +1597,8 @@ static void icon_list_append_icon (MimeView *mimeview, MimeInfo *mimeinfo)
                break;
        }
        
-       pixmap = stock_pixmap_widget(mimeview->mainwin->window, stockp);
+       pixmap = icon_stock_pixmap_with_privacy(mimeview->mainwin->window, stockp,
+                                                       mimeinfo);
        gtk_container_add(GTK_CONTAINER(button), pixmap);
        
        if (!desc) {