[balsa] Improve display, printing of text/rfc822-headers



commit b9b17943f08fb5d08cab883cf02109971f6c3ca2
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Mar 3 20:31:10 2015 -0500

    Improve display, printing of text/rfc822-headers
    
        * src/balsa-mime-widget-message.h: add gboolean show_all_headers
        to the API.
        * src/balsa-message.c (balsa_message_set_embedded_hdr),
        (display_headers): use it.
        * src/balsa-mime-widget-message.c (add_header_gchar),
        (add_header_address_list), (balsa_mime_widget_message_set_headers),
        (balsa_mime_widget_message_set_headers_d): respect it.
        * src/balsa-print-object-header.c
        (balsa_print_object_header_new_real),
        (balsa_print_object_header_from_message),
        (balsa_print_object_header_from_body), (header_add_string),
        (header_add_list): new parameter gboolean print_all_headers.

 ChangeLog                       |   17 ++++++++++++++
 src/balsa-message.c             |    6 +++-
 src/balsa-mime-widget-message.c |   29 +++++++++++++-----------
 src/balsa-mime-widget-message.h |    3 +-
 src/balsa-print-object-header.c |   46 ++++++++++++++++++++++----------------
 5 files changed, 66 insertions(+), 35 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 27ca1bd..a7bb402 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2015-03-03  Albrecht Dreß
+
+       Improve display and printing of text/rfc822-headers parts
+
+       * src/balsa-mime-widget-message.h: add gboolean show_all_headers
+       to the API.
+       * src/balsa-message.c (balsa_message_set_embedded_hdr),
+       (display_headers): use it.
+       * src/balsa-mime-widget-message.c (add_header_gchar),
+       (add_header_address_list), (balsa_mime_widget_message_set_headers),
+       (balsa_mime_widget_message_set_headers_d): respect it.
+       * src/balsa-print-object-header.c
+       (balsa_print_object_header_new_real),
+       (balsa_print_object_header_from_message),
+       (balsa_print_object_header_from_body), (header_add_string),
+       (header_add_list): new parameter gboolean print_all_headers.
+
 2015-03-01  Albrecht Dreß
 
        Display and print text/rfc822-headers parts
diff --git a/src/balsa-message.c b/src/balsa-message.c
index e59361e..a9c2159 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -1236,7 +1236,8 @@ balsa_message_set_embedded_hdr(GtkTreeModel * model, GtkTreePath * path,
            balsa_mime_widget_message_set_headers_d(bm, info->mime_widget,
                                                     info->body->embhdrs,
                                                     info->body->parts,
-                                                    info->body->embhdrs->subject);
+                                                    info->body->embhdrs->subject,
+                                                    info->body->body_type == 
LIBBALSA_MESSAGE_BODY_TYPE_TEXT);
        g_object_unref(G_OBJECT(info));
     }
     
@@ -1295,7 +1296,8 @@ display_headers(BalsaMessage * bm)
     balsa_mime_widget_message_set_headers_d(bm, bm->bm_widget, 
                                             bm->message->headers,
                                             bm->message->body_list,
-                                            LIBBALSA_MESSAGE_GET_SUBJECT(bm->message));
+                                            LIBBALSA_MESSAGE_GET_SUBJECT(bm->message),
+                                            FALSE);
 }
 
 
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index af4a9ae..17cfca7 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -559,7 +559,7 @@ bmwm_set_tabs(BalsaMessage * bm, GtkTextView * view,
 static void
 add_header_gchar(BalsaMessage * bm, GtkTextView * view,
                 const gchar * header, const gchar * label,
-                const gchar * value)
+                const gchar * value, gboolean show_all_headers)
 {
     static const gchar * all_tag_const = N_("... [truncated]");
     GtkTextBuffer *buffer;
@@ -567,7 +567,7 @@ add_header_gchar(BalsaMessage * bm, GtkTextView * view,
     const gchar *font;
     GdkRectangle location;
 
-    if (!(bm->shown_headers == HEADERS_ALL ||
+    if (!(show_all_headers || bm->shown_headers == HEADERS_ALL ||
          libbalsa_find_word(header, balsa_app.selected_headers)))
        return;
 
@@ -598,7 +598,7 @@ add_header_gchar(BalsaMessage * bm, GtkTextView * view,
         libbalsa_utf8_sanitize(&sanitized,
                                balsa_app.convert_unknown_8bit, NULL);
 
-        if(bm->shown_headers != HEADERS_ALL) {
+        if(!show_all_headers && bm->shown_headers != HEADERS_ALL) {
             static const gssize MAXLEN = 160;
             ssize_t all_tag_len = g_utf8_strlen(all_tag, -1);
             /* Look far enough into value to be sure that we can tell if
@@ -639,7 +639,7 @@ add_header_address_list(BalsaMessage * bm, GtkTextView * view,
 
     value = internet_address_list_to_string(list, FALSE);
 
-    add_header_gchar(bm, view, header, label, value);
+    add_header_gchar(bm, view, header, label, value, FALSE);
 
     g_free(value);
 }
@@ -654,7 +654,8 @@ balsa_mime_widget_message_set_headers(BalsaMessage * bm, BalsaMimeWidget *mw,
     balsa_mime_widget_message_set_headers_d(bm, mw, part->embhdrs, part->parts,
                                             part->embhdrs
                                             ? part->embhdrs->subject
-                                            : NULL );
+                                            : NULL,
+                                            part->body_type == LIBBALSA_MESSAGE_BODY_TYPE_TEXT);
     if (!(widget = mw->header_widget))
        return;
     view = bm_header_widget_get_text_view(widget);
@@ -693,7 +694,8 @@ balsa_mime_widget_message_set_headers_d(BalsaMessage * bm,
                                         BalsaMimeWidget *mw,
                                         LibBalsaMessageHeaders *headers,
                                         LibBalsaMessageBody *part,
-                                        const gchar *subject)
+                                        const gchar *subject,
+                                        gboolean show_all_headers)
 {
     GtkTextView *view;
     GtkTextBuffer *buffer;
@@ -712,7 +714,8 @@ balsa_mime_widget_message_set_headers_d(BalsaMessage * bm,
     if (!headers) {
         /* Gmail sometimes fails to do that. */
         add_header_gchar(bm, view, "subject", _("Error:"),
-                         _("IMAP server did not report message structure"));
+                         _("IMAP server did not report message structure"),
+                         show_all_headers);
         return;
     }
 
@@ -724,24 +727,24 @@ balsa_mime_widget_message_set_headers_d(BalsaMessage * bm,
 
     bm->tab_position = 0;
 
-    add_header_gchar(bm, view, "subject", _("Subject:"), subject);
+    add_header_gchar(bm, view, "subject", _("Subject:"), subject, show_all_headers);
 
     date = libbalsa_message_headers_date_to_utf8(headers,
                                                 balsa_app.date_string);
-    add_header_gchar(bm, view, "date", _("Date:"), date);
+    add_header_gchar(bm, view, "date", _("Date:"), date, show_all_headers);
     g_free(date);
 
     if (headers->from) {
        gchar *from =
            internet_address_list_to_string(headers->from, FALSE);
-       add_header_gchar(bm, view, "from", _("From:"), from);
+       add_header_gchar(bm, view, "from", _("From:"), from, show_all_headers);
        g_free(from);
     }
 
     if (headers->reply_to) {
        gchar *reply_to =
            internet_address_list_to_string(headers->reply_to, FALSE);
-       add_header_gchar(bm, view, "reply-to", _("Reply-To:"), reply_to);
+       add_header_gchar(bm, view, "reply-to", _("Reply-To:"), reply_to, show_all_headers);
        g_free(reply_to);
     }
     add_header_address_list(bm, view, "to", _("To:"), headers->to_list);
@@ -757,7 +760,7 @@ balsa_mime_widget_message_set_headers_d(BalsaMessage * bm,
        gchar *mdn_to =
            internet_address_list_to_string(headers->dispnotify_to, FALSE);
        add_header_gchar(bm, view, "disposition-notification-to",
-                        _("Disposition-Notification-To:"), mdn_to);
+                        _("Disposition-Notification-To:"), mdn_to, show_all_headers);
        g_free(mdn_to);
     }
 
@@ -767,7 +770,7 @@ balsa_mime_widget_message_set_headers_d(BalsaMessage * bm,
        gchar *hdr;
 
        hdr = g_strconcat(pair[0], ":", NULL);
-       add_header_gchar(bm, view, pair[0], hdr, pair[1]);
+       add_header_gchar(bm, view, pair[0], hdr, pair[1], show_all_headers);
        g_free(hdr);
     }
 
diff --git a/src/balsa-mime-widget-message.h b/src/balsa-mime-widget-message.h
index c0292f4..1fe0d64 100644
--- a/src/balsa-mime-widget-message.h
+++ b/src/balsa-mime-widget-message.h
@@ -45,7 +45,8 @@ void balsa_mime_widget_message_set_headers_d(BalsaMessage * bm,
                                              BalsaMimeWidget *mw,
                                              LibBalsaMessageHeaders *h,
                                              LibBalsaMessageBody *parts,
-                                             const gchar *subject);
+                                             const gchar *subject,
+                                             gboolean show_all_headers);
 
 
 #ifdef __cplusplus
diff --git a/src/balsa-print-object-header.c b/src/balsa-print-object-header.c
index 844176d..c16eaf0 100644
--- a/src/balsa-print-object-header.c
+++ b/src/balsa-print-object-header.c
@@ -1,7 +1,7 @@
 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
 /* Balsa E-Mail Client
  * Copyright (C) 1997-2001 Stuart Parmenter and others
- * Written by (C) Albrecht Dre� <albrecht dress arcor de> 2007
+ * Written by (C) Albrecht Dreß <albrecht dress arcor de> 2007
  *
  * 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
@@ -41,11 +41,13 @@ static void balsa_print_object_header_draw(BalsaPrintObject * self,
 
 static void header_add_string(PangoLayout * layout, GString * header_buf,
                              const gchar * field_id, const gchar * label,
-                             const gchar * value, gint * p_label_width);
+                             const gchar * value, gint * p_label_width,
+                             gboolean print_all_headers);
 static void header_add_list(PangoLayout * layout, GString * header_buf,
                            const gchar * field_id, const gchar * label,
                            InternetAddressList * values,
-                           gint * p_label_width);
+                           gint * p_label_width,
+                           gboolean print_all_headers);
 
 
 static BalsaPrintObjectClass *parent_class = NULL;
@@ -116,7 +118,8 @@ balsa_print_object_header_new_real(GList * list,
                                   LibBalsaMessageBody * sig_body,
                                   LibBalsaMessageHeaders * headers,
                                   const gchar * the_subject,
-                                  BalsaPrintSetup * psetup)
+                                  BalsaPrintSetup * psetup,
+                                  gboolean print_all_headers)
 {
     gchar *subject;
     gchar *date;
@@ -151,7 +154,7 @@ balsa_print_object_header_new_real(GList * list,
     subject = g_strdup(the_subject);
     libbalsa_utf8_sanitize(&subject, balsa_app.convert_unknown_8bit, NULL);
     header_add_string(test_layout, header_buf, "subject", _("Subject:"),
-                     subject, &p_label_width);
+                     subject, &p_label_width, print_all_headers);
     g_free(subject);
 
     /* date */
@@ -159,23 +162,23 @@ balsa_print_object_header_new_real(GList * list,
        libbalsa_message_headers_date_to_utf8(headers,
                                              balsa_app.date_string);
     header_add_string(test_layout, header_buf, "date", _("Date:"), date,
-                     &p_label_width);
+                     &p_label_width, print_all_headers);
     g_free(date);
 
     /* addresses */
     header_add_list(test_layout, header_buf, "from", _("From:"),
-                   headers->from, &p_label_width);
+                   headers->from, &p_label_width, print_all_headers);
     header_add_list(test_layout, header_buf, "to", _("To:"),
-                   headers->to_list, &p_label_width);
+                   headers->to_list, &p_label_width, print_all_headers);
     header_add_list(test_layout, header_buf, "cc", _("Cc:"),
-                   headers->cc_list, &p_label_width);
+                   headers->cc_list, &p_label_width, print_all_headers);
     header_add_list(test_layout, header_buf, "bcc", _("Bcc:"),
-                   headers->bcc_list, &p_label_width);
+                   headers->bcc_list, &p_label_width, print_all_headers);
     header_add_string(test_layout, header_buf, "fcc", _("Fcc:"),
-                     headers->fcc_url, &p_label_width);
+                     headers->fcc_url, &p_label_width, print_all_headers);
     header_add_list(test_layout, header_buf, "disposition-notification-to",
                    _("Disposition-Notification-To:"),
-                   headers->dispnotify_to, &p_label_width);
+                   headers->dispnotify_to, &p_label_width, print_all_headers);
 
     /* user headers */
     p = g_list_first(headers->user_hdrs);
@@ -186,7 +189,7 @@ balsa_print_object_header_new_real(GList * list,
        pair = p->data;
        curr_hdr = g_strconcat(pair[0], ":", NULL);
        header_add_string(test_layout, header_buf, pair[0], curr_hdr,
-                         pair[1], &p_label_width);
+                         pair[1], &p_label_width, print_all_headers);
        g_free(curr_hdr);
 
        /* check for face and x-face */
@@ -329,7 +332,7 @@ balsa_print_object_header_from_message(GList *list,
     return balsa_print_object_header_new_real(list, context,
                                              message->body_list,
                                              message->headers, subject,
-                                             psetup);
+                                             psetup, FALSE);
 }
 
 
@@ -342,7 +345,8 @@ balsa_print_object_header_from_body(GList *list,
     return balsa_print_object_header_new_real(list, context, body->parts,
                                              body->embhdrs,
                                              body->embhdrs->subject,
-                                             psetup);
+                                             psetup,
+                                             body->body_type == LIBBALSA_MESSAGE_BODY_TYPE_TEXT);
 }
 
 
@@ -489,13 +493,15 @@ balsa_print_object_header_draw(BalsaPrintObject * self,
 static void
 header_add_string(PangoLayout * layout, GString * header_buf,
                  const gchar * field_id, const gchar * label,
-                 const gchar * value, gint * p_label_width)
+                 const gchar * value, gint * p_label_width,
+                 gboolean print_all_headers)
 {
     gchar *_value;
     gint p_width;
 
     if (!value || balsa_app.shown_headers == HEADERS_NONE ||
-       !(balsa_app.show_all_headers ||
+       !(print_all_headers ||
+         balsa_app.show_all_headers ||
          balsa_app.shown_headers == HEADERS_ALL ||
          libbalsa_find_word(field_id, balsa_app.selected_headers)))
        return;
@@ -513,13 +519,15 @@ header_add_string(PangoLayout * layout, GString * header_buf,
 static void
 header_add_list(PangoLayout * layout, GString * header_buf,
                const gchar * field_id, const gchar * label,
-               InternetAddressList * values, gint * p_label_width)
+               InternetAddressList * values, gint * p_label_width,
+               gboolean print_all_headers)
 {
     gchar *_value;
     gint p_width;
 
     if (balsa_app.shown_headers == HEADERS_NONE ||
-       !(balsa_app.show_all_headers ||
+       !(print_all_headers ||
+         balsa_app.show_all_headers ||
          balsa_app.shown_headers == HEADERS_ALL ||
          libbalsa_find_word(field_id, balsa_app.selected_headers)) ||
         !values ||


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