2006-02-05 [colin] 2.0.0cvs13
authorColin Leroy <colin@colino.net>
Sun, 5 Feb 2006 17:56:40 +0000 (17:56 +0000)
committerColin Leroy <colin@colino.net>
Sun, 5 Feb 2006 17:56:40 +0000 (17:56 +0000)
* src/headerview.c
* src/procheader.c
* src/procmsg.c
* src/procmsg.h
* src/textview.c
Show Face headers - patch partially by Klaus Flittner

ChangeLog
PATCHSETS
configure.ac
src/headerview.c
src/procheader.c
src/procmsg.c
src/procmsg.h
src/textview.c

index adac77e5566da2b543bbbabfad7a1a667f5749af..e0b9c7dc9d473ec3472cb19c95209f6132482436 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-02-05 [colin]     2.0.0cvs13
+
+       * src/headerview.c
+       * src/procheader.c
+       * src/procmsg.c
+       * src/procmsg.h
+       * src/textview.c
+               Show Face headers - patch partially by Klaus Flittner
+
 2006-02-05 [colin]     2.0.0cvs12
 
        * src/folderview.c
index bf5b7876b357ca2696196b500799db4d73c91434..60e652ed8363ac970df3c8387d553b09dfa8eff9 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.382.2.233 -r 1.382.2.234 src/compose.c;  cvs diff -u -r 1.207.2.85 -r 1.207.2.86 src/folderview.c;  cvs diff -u -r 1.83.2.61 -r 1.83.2.62 src/mimeview.c;  cvs diff -u -r 1.395.2.160 -r 1.395.2.161 src/summaryview.c;  cvs diff -u -r 1.68.2.14 -r 1.68.2.15 src/summaryview.h;  ) > 2.0.0cvs10.patchset
 ( cvs diff -u -r 1.395.2.161 -r 1.395.2.162 src/summaryview.c;  cvs diff -u -r 1.83.2.62 -r 1.83.2.63 src/mimeview.c;  ) > 2.0.0cvs11.patchset
 ( cvs diff -u -r 1.207.2.86 -r 1.207.2.87 src/folderview.c;  cvs diff -u -r 1.395.2.162 -r 1.395.2.163 src/summaryview.c;  cvs diff -u -r 1.36.2.53 -r 1.36.2.54 src/common/utils.c;  cvs diff -u -r 1.20.2.31 -r 1.20.2.32 src/common/utils.h;  ) > 2.0.0cvs12.patchset
+( cvs diff -u -r 1.8.2.13 -r 1.8.2.14 src/headerview.c;  cvs diff -u -r 1.47.2.25 -r 1.47.2.26 src/procheader.c;  cvs diff -u -r 1.150.2.49 -r 1.150.2.50 src/procmsg.c;  cvs diff -u -r 1.60.2.20 -r 1.60.2.21 src/procmsg.h;  cvs diff -u -r 1.96.2.91 -r 1.96.2.92 src/textview.c;  ) > 2.0.0cvs13.patchset
index 5a7c575ee08006212647630ffaa82ac13811b503..7d1a77aa11db7dd03e0ad8684eeaff8fca72d6dc 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=12
+EXTRA_VERSION=13
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 2dd88369d59202902fbf98b4554edba586a3f357..c1c1cea408fa40e3a0994dd0a57ebec46d3887d2 100644 (file)
 #  include <compface.h>
 #endif
 
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
 #include "headerview.h"
 #include "prefs_common.h"
 #include "codeconv.h"
 #include "gtkutils.h"
 #include "utils.h"
+#include "base64.h"
 
 #define TR(str)        (prefs_common.trans_hdr ? gettext(str) : str)
 
@@ -64,6 +67,9 @@ static void headerview_show_xface     (HeaderView     *headerview,
                                         MsgInfo        *msginfo);
 #endif
 
+static gint headerview_show_face       (HeaderView     *headerview,
+                                        MsgInfo        *msginfo);
+
 HeaderView *headerview_create(void)
 {
        HeaderView *headerview;
@@ -211,6 +217,9 @@ void headerview_show(HeaderView *headerview, MsgInfo *msginfo)
                           msginfo->subject ? msginfo->subject :
                           _("(No Subject)"));
 
+       if (!headerview_show_face(headerview, msginfo))
+               return;
+
 #if HAVE_LIBCOMPFACE
        headerview_show_xface(headerview, msginfo);
 #endif
@@ -264,6 +273,68 @@ static void headerview_show_xface(HeaderView *headerview, MsgInfo *msginfo)
 }
 #endif
 
+static gint headerview_show_face (HeaderView *headerview, MsgInfo *msginfo)
+{
+       gchar face[2048];
+       gchar face_png[2048];
+       gint pngsize;
+       GtkWidget *hbox = headerview->hbox;
+       GdkPixbuf *pixbuf;
+       GError *error = NULL;
+
+       if (!msginfo->face) {
+               if (headerview->image &&
+                   GTK_WIDGET_VISIBLE(headerview->image)) {
+                       gtk_widget_hide(headerview->image);
+                       gtk_widget_queue_resize(hbox);
+               }
+               return -1;
+       }
+       if (!GTK_WIDGET_VISIBLE(headerview->hbox)) return -1;
+
+       strncpy2(face, msginfo->face, sizeof(face));
+
+       unfold_line(face); /* strip all whitespace and linebreaks */
+       remove_space(face);
+
+       pngsize = base64_decode(face_png, face, strlen(face));
+
+       GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
+       if (!gdk_pixbuf_loader_write (loader, face_png, pngsize, &error) ||
+           !gdk_pixbuf_loader_close (loader, &error)) {
+               g_warning("loading face failed\n");
+               g_object_unref(loader);
+               if (headerview->image)
+                       gtk_widget_hide(headerview->image);
+               return;
+       }
+
+       pixbuf = g_object_ref(gdk_pixbuf_loader_get_pixbuf(loader));
+
+       g_object_unref(loader);
+
+       if ((gdk_pixbuf_get_width(pixbuf) != 48) || (gdk_pixbuf_get_height(pixbuf) != 48)) {
+               g_object_unref(pixbuf);
+               return -1;
+       }
+
+       if (!headerview->image) {
+               GtkWidget *image;
+
+               image = gtk_image_new_from_pixbuf(pixbuf);
+               gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
+               gtk_widget_show(image);
+               headerview->image = image;
+       } else {
+               gtk_image_set_from_pixbuf(GTK_IMAGE(headerview->image), pixbuf);
+               gtk_widget_show(headerview->image);
+       }
+
+       g_object_unref(pixbuf);
+
+       return 0;
+}
+
 void headerview_clear(HeaderView *headerview)
 {
        if (headerview == NULL)
index 0621f76844616da0f2165f5b1eb4bb86a7a074a7..3782d6b89db40110255b7cc5764143f16030c602 100644 (file)
@@ -512,12 +512,13 @@ enum
        H_FROM_SPACE    = 13,
        H_SC_PLANNED_DOWNLOAD = 14,
        H_SC_MESSAGE_SIZE = 15,
-       H_X_FACE        = 16,
-       H_DISPOSITION_NOTIFICATION_TO = 17,
-       H_RETURN_RECEIPT_TO = 18,
-       H_SC_PARTIALLY_RETRIEVED = 19,
-       H_SC_ACCOUNT_SERVER = 20,
-       H_SC_ACCOUNT_LOGIN = 21,
+       H_FACE          = 16,
+       H_X_FACE        = 17,
+       H_DISPOSITION_NOTIFICATION_TO = 18,
+       H_RETURN_RECEIPT_TO = 19,
+       H_SC_PARTIALLY_RETRIEVED = 20,
+       H_SC_ACCOUNT_SERVER = 21,
+       H_SC_ACCOUNT_LOGIN = 22,
 };
 
 static HeaderEntry hentry_full[] = {{"Date:",          NULL, FALSE},
@@ -536,6 +537,7 @@ static HeaderEntry hentry_full[] = {{"Date:",               NULL, FALSE},
                                   {"From ",            NULL, FALSE},
                                   {"SC-Marked-For-Download:", NULL, FALSE},
                                   {"SC-Message-Size:", NULL, FALSE},
+                                  {"Face:",            NULL, FALSE},
                                   {"X-Face:",          NULL, FALSE},
                                   {"Disposition-Notification-To:", NULL, FALSE},
                                   {"Return-Receipt-To:", NULL, FALSE},
@@ -691,6 +693,10 @@ static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags,
                        MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW|MSG_UNREAD);
                        break;
 #endif                 
+               case H_FACE:
+                       if (msginfo->face) break;
+                       msginfo->face = g_strdup(hp);
+                       break;
                case H_X_FACE:
                        if (msginfo->xface) break;
                        msginfo->xface = g_strdup(hp);
index ae38b6e2383df77d771c803c31ebcb8b422ef42e..0e0b4895cc86f96822c88db5e35a9d99503dea99 100644 (file)
@@ -1152,6 +1152,7 @@ MsgInfo *procmsg_msginfo_copy(MsgInfo *msginfo)
        MEMBCOPY(folder);
        MEMBCOPY(to_folder);
 
+       MEMBDUP(face);
        MEMBDUP(xface);
        MEMBDUP(dispositionnotificationto);
        MEMBDUP(returnreceiptto);
@@ -1194,6 +1195,8 @@ MsgInfo *procmsg_msginfo_get_full_info(MsgInfo *msginfo)
         * procheader.c::procheader_get_headernames() */
        if (!msginfo->xface)
                msginfo->xface = g_strdup(full_msginfo->xface);
+       if (!msginfo->face)
+               msginfo->face = g_strdup(full_msginfo->face);
        if (!msginfo->dispositionnotificationto)
                msginfo->dispositionnotificationto = 
                        g_strdup(full_msginfo->dispositionnotificationto);
@@ -1233,6 +1236,7 @@ void procmsg_msginfo_free(MsgInfo *msginfo)
        g_free(msginfo->returnreceiptto);
        g_free(msginfo->dispositionnotificationto);
        g_free(msginfo->xface);
+       g_free(msginfo->face);
 
        g_free(msginfo->fromname);
 
@@ -1284,6 +1288,8 @@ guint procmsg_msginfo_memusage(MsgInfo *msginfo)
                memusage += strlen(msginfo->inreplyto);
        if (msginfo->xface)
                memusage += strlen(msginfo->xface);
+       if (msginfo->face)
+               memusage += strlen(msginfo->face);
        if (msginfo->dispositionnotificationto)
                memusage += strlen(msginfo->dispositionnotificationto);
        if (msginfo->returnreceiptto)
index 0d91711265fc0255e27e8e988a06edf91f30b6c6..1140560f1d99ebec89ebd7fb913f4b3c8bbcc45b 100644 (file)
@@ -192,6 +192,7 @@ struct _MsgInfo
        FolderItem *to_folder;
 
        gchar *xface;
+       gchar *face;
 
        gchar *dispositionnotificationto;
        gchar *returnreceiptto;
index 74015770f94c485c8f74fdc22e64d1c8b029df63..27eb5c5c6a5b23274bb14d06f83e4b5a802d50c8 100644 (file)
@@ -61,6 +61,7 @@
 #include "menu.h"
 #include "image_viewer.h"
 #include "filesel.h"
+#include "base64.h"
 
 struct _RemoteURI
 {
@@ -240,7 +241,6 @@ static GtkItemFactoryEntry textview_file_popup_entries[] =
 
 static void scrolled_cb (GtkAdjustment *adj, TextView *textview)
 {
-#if HAVE_LIBCOMPFACE
        if (textview->image) {
                gint x, y, x1;
                x1 = textview->text->allocation.width - WIDTH - 5;
@@ -250,7 +250,6 @@ static void scrolled_cb (GtkAdjustment *adj, TextView *textview)
                gtk_text_view_move_child(GTK_TEXT_VIEW(textview->text), 
                        textview->image, x1, y);
        }
-#endif
 }
 
 static void textview_size_allocate_cb  (GtkWidget      *widget,
@@ -360,7 +359,7 @@ TextView *textview_create(void)
        textview->mail_popup_factory = mail_popupfactory;
        textview->file_popup_menu    = file_popupmenu;
        textview->file_popup_factory = file_popupfactory;
-
+       textview->image              = NULL;
        return textview;
 }
 
@@ -1299,6 +1298,69 @@ static GPtrArray *textview_scan_header(TextView *textview, FILE *fp)
        return sorted_headers;
 }
 
+static void textview_show_face(TextView *textview)
+{
+       gchar face[2048];
+       gchar face_png[2048];
+       gint pngsize;
+       GdkPixbuf *pixbuf;
+       GError *error = NULL;
+       GtkTextView *text = GTK_TEXT_VIEW(textview->text);
+       MsgInfo *msginfo = textview->messageview->msginfo;
+       int x = 0;
+
+       if (!msginfo->face) {
+               goto bail;
+       }
+
+       strncpy2(face, msginfo->face, sizeof(face));
+
+       unfold_line(face); /* strip all whitespace and linebreaks */
+       remove_space(face);
+
+       pngsize = base64_decode(face_png, face, strlen(face));
+
+       GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
+       if (!gdk_pixbuf_loader_write (loader, face_png, pngsize, &error) ||
+           !gdk_pixbuf_loader_close (loader, &error)) {
+               g_warning("loading face failed\n");
+               g_object_unref(loader);
+               goto bail;
+       }
+
+       pixbuf = g_object_ref(gdk_pixbuf_loader_get_pixbuf(loader));
+
+       g_object_unref(loader);
+
+       if ((gdk_pixbuf_get_width(pixbuf) != 48) || (gdk_pixbuf_get_height(pixbuf) != 48)) {
+               g_object_unref(pixbuf);
+               g_warning("wrong_size");
+               goto bail;
+       }
+
+       if (textview->image) 
+               gtk_widget_destroy(textview->image);
+       
+       textview->image = gtk_image_new_from_pixbuf(pixbuf);
+       gtk_widget_show(textview->image);
+       
+       x = textview->text->allocation.width - WIDTH -5;
+
+       gtk_text_view_add_child_in_window(text, textview->image, 
+               GTK_TEXT_WINDOW_TEXT, x, 5);
+
+       g_object_unref(pixbuf);
+       
+       gtk_widget_show_all(textview->text);
+       
+
+       return;
+bail:
+       if (textview->image) 
+               gtk_widget_destroy(textview->image);
+       textview->image = NULL; 
+}
+
 #if HAVE_LIBCOMPFACE
 static void textview_show_xface(TextView *textview)
 {
@@ -1317,6 +1379,9 @@ static void textview_show_xface(TextView *textview)
        if (!msginfo)
                goto bail;
 
+       if (msginfo->face)
+               return;
+       
        if (!msginfo->xface || strlen(msginfo->xface) < 5) {
                goto bail;
        }
@@ -1417,6 +1482,8 @@ static void textview_show_header(TextView *textview, GPtrArray *headers)
                gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "\n", 1,
                                                         "header", NULL);
        }
+       
+       textview_show_face(textview);
 #if HAVE_LIBCOMPFACE
        textview_show_xface(textview);
 #endif