[balsa/75-html-display-printing] HTML message display and printing improvements




commit 0506b2a1a9d7b6c1b10d041443f1b2cee97276af
Author: Albrecht Dreß <albrecht dress netcologne de>
Date:   Tue May 3 21:09:03 2022 +0200

    HTML message display and printing improvements
    
    See Gitlab issue #75 for further details.
    
    Basically, the following is implemented in this branch:
    (1) remember for each multipart/alternative if the plain or html part
    has been selected by the user for display,
    (2) remember for each html part if the user decided to load external
    contents, or if it has been loaded due to a rule,
    (3) if a message if opened in a 2nd window display it exactly as in the
    1st view,
    (4) print the message exactly as displayed in the view from which
    printing is initiated, and remove all related config items from the
    print dialogue.
    
    Details:
    - libbalsa/body.[ch]: add flags and a reference to the parent part to
    _LibBalsaMessageBody plus helper setter/getters for (1) and (2);
    - libbalsa/html.[ch]: use the _LibBalsaMessageBody flag re. already
    loaded external content;
    - libbalsa/mime.c, src/balsa-mime-widget-text.c: clarify the use of the
    LibBalsaHTMLType enum
    - src/balsa-message.c: set/use html selection status, clarify the use of
    the LibBalsaHTMLType enum
    - src/balsa-print-object-html.c: modified html print api
    - src/balsa-print-object.h: remove needless html print config items
    - src/print-gtk.c: rework selection of parts to be printed, remove html
    print config items
    
    Signed-off-by: Albrecht Dreß <albrecht dress netcologne de>

 libbalsa/body.c               | 100 +++++++++++++++++++++++-
 libbalsa/body.h               |  14 ++++
 libbalsa/html.c               |  11 +--
 libbalsa/html.h               |   3 +-
 libbalsa/mime.c               |   2 +-
 src/balsa-message.c           |   8 +-
 src/balsa-mime-widget-text.c  |   2 +-
 src/balsa-print-object-html.c |   2 +-
 src/balsa-print-object.h      |   5 --
 src/print-gtk.c               | 171 +++++++++++++++++++-----------------------
 10 files changed, 205 insertions(+), 113 deletions(-)
---
diff --git a/libbalsa/body.c b/libbalsa/body.c
index 11da495d6..a3410497c 100644
--- a/libbalsa/body.c
+++ b/libbalsa/body.c
@@ -35,6 +35,7 @@
 #include <glib/gi18n.h>
 #include "gmime-part-rfc2440.h"
 #include "libbalsa-gpgme.h"
+#include "html.h"
 
 LibBalsaMessageBody *
 libbalsa_message_body_new(LibBalsaMessage * message)
@@ -194,8 +195,10 @@ libbalsa_message_body_set_message_part(LibBalsaMessageBody * body,
         body->embhdrs =
             libbalsa_message_body_extract_embedded_headers
             (embedded_message);
-        if (!*next_part)
+        if (!*next_part) {
             *next_part = libbalsa_message_body_new(body->message);
+            (*next_part)->parent = body;
+        }
         libbalsa_message_body_set_mime_body(*next_part,
                                             embedded_message->mime_part);
     }
@@ -214,8 +217,10 @@ libbalsa_message_body_set_multipart(LibBalsaMessageBody * body,
     count = g_mime_multipart_get_count (multipart);
     for (i = 0; i < count; i++) {
        part = g_mime_multipart_get_part (multipart, i);
-       if (!*next_part)
+       if (!*next_part) {
            *next_part = libbalsa_message_body_new(body->message);
+           (*next_part)->parent = body;
+       }
        libbalsa_message_body_set_mime_body(*next_part, part);
        next_part = &(*next_part)->next;
     }
@@ -941,6 +946,97 @@ libbalsa_message_body_mp_related_root(LibBalsaMessageBody *body)
     return root_body;
 }
 
+
+#ifdef HAVE_HTML_WIDGET
+
+/** @brief Find the multipart/alternative parent of a body
+ *
+ * @param[in] body message body
+ * @return the body's multipart/alternative parent, NULL if it is not the child of such a part
+ *
+ * Return the multipart/alternative parent of the passed body, which @em must be either the direct parent, 
or if the body's direct
+ * parent is a multipart/related the direct parent of the latter.
+ */
+static inline LibBalsaMessageBody *
+find_mp_alt_parent(const LibBalsaMessageBody *body)
+{
+       LibBalsaMessageBody *mp_alt = NULL;
+
+       mp_alt = body->parent;
+       if ((mp_alt != NULL) && (mp_alt->body_type == LIBBALSA_MESSAGE_BODY_TYPE_MULTIPART)) {
+               gchar *conttype;
+
+               conttype = libbalsa_message_body_get_mime_type(mp_alt);
+               if (strcmp(conttype, "multipart/related") == 0) {
+                       g_free(conttype);
+                       mp_alt = mp_alt->parent;
+                       if (mp_alt != NULL) {
+                               conttype = libbalsa_message_body_get_mime_type(mp_alt);
+                       } else {
+                               conttype = NULL;
+                       }
+               }
+
+               if ((conttype != NULL) && strcmp(conttype, "multipart/alternative") != 0) {
+                       mp_alt = NULL;
+               }
+               g_free(conttype);
+       }
+
+       return mp_alt;
+}
+
+
+/** @brief Set if a multipart/alternative HTML or plain part is selected
+ *
+ * @param[in] body message body
+ *
+ * Iff the passed body is the child of a multipart/alternative set the LibBalsaMessageBody::html_selected 
property of the latter if
+ * the body's content type is a HTML type.
+ *
+ * @sa find_mp_alt_parent(), libbalsa_html_type()
+ */
+void
+libbalsa_message_body_set_html_selected(LibBalsaMessageBody *body)
+{
+       LibBalsaMessageBody *mp_alt_body;
+
+       if ((body != NULL) && (body->body_type == LIBBALSA_MESSAGE_BODY_TYPE_TEXT)) {
+               mp_alt_body = find_mp_alt_parent(body);
+               if (mp_alt_body != NULL) {
+                       gchar *conttype;
+
+                       conttype = libbalsa_message_body_get_mime_type(body);
+                       mp_alt_body->html_selected = libbalsa_html_type(conttype) != LIBBALSA_HTML_TYPE_NONE;
+                       g_free(conttype);
+               }
+       }
+}
+
+
+/** @brief Check if a multipart/alternative HTML or plain part is selected
+ *
+ * @param[in] body message body
+ * @return TRUE iff body is a child of a multipart/alternative for which the HTML part is selected
+ * @sa find_mp_alt_parent()
+ */
+gboolean
+libbalsa_message_body_get_html_selected(LibBalsaMessageBody *body)
+{
+       LibBalsaMessageBody *mp_alt_body;
+       gboolean result = FALSE;
+
+       g_return_val_if_fail(body != NULL, FALSE);
+       mp_alt_body = find_mp_alt_parent(body);
+       if (mp_alt_body != NULL) {
+               result = mp_alt_body->html_selected;
+       }
+       return result;
+}
+
+#endif /*HAVE_HTML_WIDGET*/
+
+
 /** Basic requirements for a multipart crypto: protocol is not NULL, exactly two body parts */
 #define MP_CRYPT_STRUCTURE(part, protocol)                                                                   
          \
        (((protocol) != NULL) && ((body)->parts != NULL) &&                                             \
diff --git a/libbalsa/body.h b/libbalsa/body.h
index d201ed120..4fb6adc0b 100644
--- a/libbalsa/body.h
+++ b/libbalsa/body.h
@@ -83,6 +83,12 @@ struct _LibBalsaMessageBody {
     gboolean was_encrypted;
     GMimeGpgmeSigstat* sig_info;  /* info about a pgp or S/MIME signature body */
 
+#ifdef HAVE_HTML_WIDGET
+    gboolean html_ext_loaded;  /* if external HTML content was loaded */
+    gboolean html_selected;            /* if the HTML part of a multipart/alternative is selected */
+#endif /* HAVE_HTML_WIDGET */
+
+    LibBalsaMessageBody *parent;       /* Parent part in the message */
     LibBalsaMessageBody *next; /* Next part in the message */
     LibBalsaMessageBody *parts;        /* The parts of a multipart or message/rfc822 message */
 };
@@ -132,6 +138,14 @@ LibBalsaMessageBody *libbalsa_message_body_get_by_id(LibBalsaMessageBody *
                                                      const gchar * id);
 LibBalsaMessageBody *libbalsa_message_body_mp_related_root(LibBalsaMessageBody *body);
 
+#ifdef HAVE_HTML_WIDGET
+void libbalsa_message_body_set_html_selected(LibBalsaMessageBody *body);
+gboolean libbalsa_message_body_get_html_selected(LibBalsaMessageBody *body);
+#else
+#define libbalsa_message_body_set_html_selected(x)
+#define libbalsa_message_body_get_html_selected(x)     FALSE
+#endif /*HAVE_HTML_WIDGET*/
+
 guint libbalsa_message_body_protect_mode(const LibBalsaMessageBody * body);
 guint libbalsa_message_body_signature_state(const LibBalsaMessageBody *body);
 gboolean libbalsa_message_body_multipart_signed(const LibBalsaMessageBody *body);
diff --git a/libbalsa/html.c b/libbalsa/html.c
index d2375e799..646ebd08c 100644
--- a/libbalsa/html.c
+++ b/libbalsa/html.c
@@ -419,6 +419,7 @@ lbh_info_bar_response_cb(GtkInfoBar * info_bar,
                if (lbh_get_body_content_utf8(info->body, &text) >= 0) {
                        if (g_atomic_int_get(&html_filter_found) != 0) {
                                lbh_load_external_resources(info->web_view, TRUE);
+                               info->body->html_ext_loaded= TRUE;
                        } else {
                                WebKitSettings *settings;
 
@@ -771,8 +772,7 @@ dump_snapshot(GObject      *source_object,
  */
 cairo_surface_t *
 libbalsa_html_print_bitmap(LibBalsaMessageBody *body,
-                                                  gdouble                              width,
-                                                  gboolean                     load_external_content)
+                                                  gdouble                              width)
 {
        gint render_width;
     gchar *text;
@@ -799,7 +799,7 @@ libbalsa_html_print_bitmap(LibBalsaMessageBody *body,
        render_width = (gint) (width * HTML_PRINT_DPI / 72.0);
        g_debug("%s: request Cairo width %g, render width %d", __func__, width, render_width);
     gtk_window_set_default_size(GTK_WINDOW(offline_window), render_width, LBH_NATURAL_SIZE);
-    view = lbh_web_view_new(info, render_width, load_external_content || (have_src_cid && !have_src_oth));
+    view = lbh_web_view_new(info, render_width, body->html_ext_loaded || (have_src_cid && !have_src_oth));
     webkit_web_view_set_zoom_level(view, HTML_PRINT_ZOOM);                     /* heuristic setting, any way 
to calculate it? */
     gtk_container_add(GTK_CONTAINER(offline_window), GTK_WIDGET(view));
     gtk_widget_show_all(offline_window);
@@ -869,8 +869,9 @@ libbalsa_html_new(LibBalsaMessageBody * body,
     have_src_cid = g_regex_match_simple(CID_REGEX, text, G_REGEX_CASELESS, 0);
     have_src_oth = g_regex_match_simple(SRC_REGEX, text, G_REGEX_CASELESS, 0);
 
+    body->html_ext_loaded = auto_load_ext_content || body->html_ext_loaded;
     info->web_view = lbh_web_view_new(info, LBH_NATURAL_SIZE,
-       auto_load_ext_content || (have_src_cid && !have_src_oth));
+       body->html_ext_loaded || (have_src_cid && !have_src_oth));
 
     g_signal_connect(info->web_view, "mouse-target-changed",
                      G_CALLBACK(lbh_mouse_target_changed_cb), info);
@@ -881,7 +882,7 @@ libbalsa_html_new(LibBalsaMessageBody * body,
     gtk_box_pack_end(GTK_BOX(vbox), GTK_WIDGET(info->web_view), TRUE, TRUE, 0);
 
     /* Simple check for possible resource requests: */
-    if (have_src_oth && !auto_load_ext_content) {
+    if (have_src_oth && !body->html_ext_loaded) {
         info->info_bar = lbh_info_bar(info);
         gtk_box_pack_start(GTK_BOX(vbox), info->info_bar, FALSE, FALSE, 0);
         g_debug("%s shows info_bar", __func__);
diff --git a/libbalsa/html.h b/libbalsa/html.h
index 87d726126..8c44c89ed 100644
--- a/libbalsa/html.h
+++ b/libbalsa/html.h
@@ -81,8 +81,7 @@ void libbalsa_html_clear_cache(void);
 gboolean libbalsa_html_can_print(GtkWidget * widget);
 void libbalsa_html_print(GtkWidget * widget);
 cairo_surface_t *libbalsa_html_print_bitmap(LibBalsaMessageBody *body,
-                                                                                   gdouble                   
           width,
-                                                                                       gboolean              
           load_external_images)
+                                                                                   gdouble                   
           width)
        G_GNUC_WARN_UNUSED_RESULT;
 
 # endif                                /* HAVE_HTML_WIDGET */
diff --git a/libbalsa/mime.c b/libbalsa/mime.c
index fae3d3918..f777ba0ad 100644
--- a/libbalsa/mime.c
+++ b/libbalsa/mime.c
@@ -76,7 +76,7 @@ process_mime_part(LibBalsaMessage * message, LibBalsaMessageBody * body,
        html_type = libbalsa_html_type(mime_type);
        g_free(mime_type);
 
-       if (ignore_html && html_type)
+       if (ignore_html && (html_type != LIBBALSA_HTML_TYPE_NONE))
            break;
 
 #ifdef HAVE_HTML_WIDGET
diff --git a/src/balsa-message.c b/src/balsa-message.c
index dc4bcd980..7b9163542 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -2015,8 +2015,9 @@ libbalsa_can_display(LibBalsaMessageBody *part, InternetAddressList *from)
 {
     gchar *content_type = libbalsa_message_body_get_mime_type(part);
     gboolean res = FALSE;
-    if ((!balsa_app.display_alt_plain || libbalsa_html_get_prefer_html(from)) &&
-       libbalsa_html_type(content_type))
+    if ((!balsa_app.display_alt_plain || libbalsa_html_get_prefer_html(from) ||
+         libbalsa_message_body_get_html_selected(part)) &&
+       (libbalsa_html_type(content_type) != LIBBALSA_HTML_TYPE_NONE))
        res = TRUE;
     else if(strcmp(content_type, "multipart/related") == 0 &&
            part->parts)
@@ -2028,7 +2029,7 @@ libbalsa_can_display(LibBalsaMessageBody *part, InternetAddressList *from)
 
 /** Determines whether given part can be displayed. We display plain
    text, parts html/rtf parts unless it has been disabled in the
-   preferences. We make sure the process is correctly recurrsive, to
+   preferences. We make sure the process is correctly recursive, to
    display properly messages of following structure:
 
    multiplart/alternative
@@ -2277,6 +2278,7 @@ select_part(BalsaMessage * balsa_message, BalsaPartInfo *info)
     body = add_part(balsa_message, info,
                     balsa_mime_widget_get_container(balsa_message->bm_widget));
     balsa_message->current_part = part_info_from_body(balsa_message, body);
+    libbalsa_message_body_set_html_selected(body);
 
     g_signal_emit(balsa_message, balsa_message_signals[SELECT_PART], 0);
 
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 6788c1047..e464c7e0e 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -238,7 +238,7 @@ balsa_mime_widget_new_text(BalsaMessage * bm, LibBalsaMessageBody * mime_body,
 
     /* handle HTML if possible */
     html_type = libbalsa_html_type(content_type);
-    if (html_type) {
+    if (html_type != LIBBALSA_HTML_TYPE_NONE) {
         BalsaMimeWidget *html_widget = NULL;
 
 #ifdef HAVE_HTML_WIDGET
diff --git a/src/balsa-print-object-html.c b/src/balsa-print-object-html.c
index d51496c4d..c975f6003 100644
--- a/src/balsa-print-object-html.c
+++ b/src/balsa-print-object-html.c
@@ -92,7 +92,7 @@ balsa_print_object_html(GList                                 *list,
     c_use_width = psetup->c_width - 2.0 * psetup->curr_depth * C_LABEL_SEP;
 
     /* render the HTML part into a surface, fall back to default if this fails */
-    html_surface = libbalsa_html_print_bitmap(body, c_use_width, psetup->html_load_ext_content);
+    html_surface = libbalsa_html_print_bitmap(body, c_use_width);
     if (html_surface == NULL) {
        return balsa_print_object_default(list, context, body, psetup);
     }
diff --git a/src/balsa-print-object.h b/src/balsa-print-object.h
index 2681b623b..937699d44 100644
--- a/src/balsa-print-object.h
+++ b/src/balsa-print-object.h
@@ -45,11 +45,6 @@ typedef struct {
 
     gint page_count;
     guint curr_depth;
-
-    /* note: the following two fields are relevant only if HTML support is enabled;
-     * don't hide them for code simplicity even if HTML support is disabled */
-    gboolean print_alt_html;   /* print text/html in multipart/alternative */
-    gboolean html_load_ext_content;    /* load external content when printing text/html */
 } BalsaPrintSetup;
 
 
diff --git a/src/print-gtk.c b/src/print-gtk.c
index d2d90d25b..d2b4d54c2 100644
--- a/src/print-gtk.c
+++ b/src/print-gtk.c
@@ -49,13 +49,6 @@ typedef struct {
     GtkWidget *margin_bottom;
     GtkWidget *margin_left;
     GtkWidget *margin_right;
-#ifdef HAVE_HTML_WIDGET
-    GtkWidget *html_print;
-    GtkWidget *html_load_ext_content;
-    gboolean prefer_text;
-    gboolean load_ext_content;
-    BalsaPrintSetup *setup;
-#endif
 } BalsaPrintPrefs;
 
 typedef struct {
@@ -119,47 +112,6 @@ print_header_footer(GtkPrintContext * context, cairo_t * cairo_ctx,
 }
 
 
-/*
- * Scan the parts of a multipart/alternative as to find the proper one for printing.  According to RFC 2046, 
Sect. 5.1.4, the first
- * /should/ be the "plain" one, and the following the "fancier" ones.  This is not guaranteed, though.
- * 
- * Furthermore, we may have cases like
- * +- multipart/alternative
- *      +- text/plain
- *      +- multipart/mixed
- *           +- text/html
- *           +- ...
- */
-static LibBalsaMessageBody *
-find_alt_part(LibBalsaMessageBody *parts,
-                         gboolean                         print_alt_html)
-{
-       LibBalsaMessageBody *part;
-       LibBalsaMessageBody *use_part = parts;          /* fallback: print 1st alternative part */
-
-       /* scan the parts */
-       for (part = parts; part != NULL; part = part->next) {
-               gchar *mime_type;
-               
-               mime_type = libbalsa_message_body_get_mime_type(part);
-               if ((strncmp(mime_type, "multipart/", 10U) == 0) && (part->parts != NULL)) {
-                       /* consider the first child of a multipart */
-                       g_free(mime_type);
-                       mime_type = libbalsa_message_body_get_mime_type(part->parts);
-               }
-
-               if ((strcmp(mime_type, "text/calendar") == 0) ||
-                       ((strcmp(mime_type, "text/plain") == 0) && !print_alt_html) ||
-                       ((strcmp(mime_type, "text/html") == 0) && print_alt_html)) {
-                       use_part = part;
-               }
-               g_free(mime_type);
-       }
-       
-       return use_part;
-}
-
-
 static inline GList *
 begin_crypto_frame(GList                  *bpo_list,
                                   BalsaPrintSetup *psetup,
@@ -199,8 +151,61 @@ print_single_part(GList                      *bpo_list,
 }
 
 
+static LibBalsaMessageBody *
+select_from_mp_alt(LibBalsaMessageBody *parts, gboolean html_part)
+{
+       LibBalsaMessageBody *body;
+       LibBalsaMessageBody *use_body = NULL;
+
+       for (body = parts; (body != NULL) && (use_body == NULL); body = body->next) {
+               gchar *conttype;
+
+               conttype = libbalsa_message_body_get_mime_type(body);
+               if ((html_part && (libbalsa_html_type(conttype) != LIBBALSA_HTML_TYPE_NONE)) ||
+                       (!html_part && strcmp(conttype, "text/plain") == 0)) {
+                       use_body = body;
+               } else if (html_part && (strcmp(conttype, "multipart/related") == 0)) {
+                       use_body = libbalsa_message_body_mp_related_root(body);
+               }
+               g_free(conttype);
+       }
+
+       return (use_body != NULL) ? use_body : parts;
+}
+
+
 /*
  * scan the body list and prepare print data according to the content type
+ *
+ * Multipart/alternative and multipart/related require additional attention, as the printout shall reflect 
the screen display.
+ * According to RFC 2046, Sect. 5.1.4, the first child of a multipart/alternative /should/ be the "plain" 
part, and the following
+ * the "fancier" ones.  This is not guaranteed, though.  Multipart/related typically bundles a html and 
inlined images, etc., but
+ * the ordering multipart/related and multipart/alternative is not defined.
+ *
+ * Thus, in practice, the following cases will occur:
+ *
+ * (1) multipart/alternative: print plain or html according to html_selected property
+ *       text/plain
+ *       text/html
+ *
+ * (2) multipart/alternative: print plain or html from multipart/related according to html_selected property
+ *       text/plain
+ *       multipart/related
+ *         text/html
+ *         image/png
+ *         [...]
+ *
+ * (3) multipart/related: print plain or html from multipart/alternative child according to its 
html_selected property
+ *       multipart/alternative
+ *         text/plain
+ *         text/html
+ *       image/png
+ *       [...]
+ *
+ * (4) multipart/related: print html-only message
+ *       text/html
+ *       image/png
+ *       [...]
  */
 static GList *
 scan_body(GList *bpo_list, GtkPrintContext * context, BalsaPrintSetup * psetup,
@@ -240,16 +245,32 @@ scan_body(GList *bpo_list, GtkPrintContext * context, BalsaPrintSetup * psetup,
        }
 
        if (body->parts) {
-               if (g_ascii_strcasecmp(conttype, "multipart/alternative") == 0) {
-                       LibBalsaMessageBody *print_part;
+               LibBalsaMessageBody *print_part;
 
-                       print_part = find_alt_part(body->parts, psetup->print_alt_html);
+               if (strcmp(conttype, "multipart/alternative") == 0) {
+#ifdef HAVE_HTML_WIDGET
+                       print_part = select_from_mp_alt(body->parts, body->html_selected);
+#else
+                       print_part = select_from_mp_alt(body->parts, FALSE);
+#endif
+                       bpo_list = print_single_part(bpo_list, context, psetup, print_part, no_first_sep, 
add_signature);
+               } else if (strcmp(conttype, "multipart/related") == 0) {
+                       LibBalsaMessageBody *mp_rel_root;
+                       gchar *mp_rel_root_type;
+
+                       mp_rel_root = libbalsa_message_body_mp_related_root(body);
+                       mp_rel_root_type = libbalsa_message_body_get_mime_type(mp_rel_root);
+                       if (strcmp(mp_rel_root_type, "multipart/alternative") == 0) {
+#ifdef HAVE_HTML_WIDGET
+                               print_part = select_from_mp_alt(mp_rel_root->parts, 
mp_rel_root->html_selected);
+#else
+                               print_part = select_from_mp_alt(mp_rel_root->parts, FALSE);
+#endif
+                       } else {
+                               print_part = mp_rel_root;
+                       }
+                       g_free(mp_rel_root_type);
                        bpo_list = print_single_part(bpo_list, context, psetup, print_part, no_first_sep, 
add_signature);
-               } else if (g_ascii_strcasecmp(conttype, "multipart/related") == 0) {
-                       /* catch the case of a RFC 2387 multipart/related, typically a text/html with images 
which are enclosed in the
-                        * "related" container */
-                       bpo_list = print_single_part(bpo_list, context, psetup, 
libbalsa_message_body_mp_related_root(body), no_first_sep,
-                               add_signature);
                } else {
                        bpo_list = scan_body(bpo_list, context, psetup, body->parts, no_first_sep);
                }
@@ -273,6 +294,7 @@ scan_body(GList *bpo_list, GtkPrintContext * context, BalsaPrintSetup * psetup,
     return bpo_list;
 }
 
+
 static void
 begin_print(GtkPrintOperation * operation, GtkPrintContext * context,
            BalsaPrintData * pdata)
@@ -574,9 +596,6 @@ message_prefs_widget(GtkPrintOperation * operation,
 {
     GtkWidget *page;
     GtkWidget *grid;
-#ifdef HAVE_HTML_WIDGET
-    GtkWidget *dummy;
-#endif
     GtkPageSetup *pg_setup;
 
     gtk_print_operation_set_custom_tab_label(operation, _("Message"));
@@ -605,25 +624,6 @@ message_prefs_widget(GtkPrintOperation * operation,
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(print_prefs->highlight_phrases), 
balsa_app.print_highlight_phrases);
     gtk_grid_attach(GTK_GRID(grid), print_prefs->highlight_phrases, 1, 1, 1, 1);
 
-#ifdef HAVE_HTML_WIDGET
-    /* treatment of HTML messages and parts */
-    grid = create_options_group(_("HTML options"), page, 1, 1, 1);
-
-    print_prefs->html_print = gtk_check_button_new_with_mnemonic(_("Prefer text/plain over HTML"));
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(print_prefs->html_print), print_prefs->prefer_text);
-    gtk_grid_attach(GTK_GRID(grid), print_prefs->html_print, 1, 0, 1, 1);
-
-    print_prefs->html_load_ext_content =
-       gtk_check_button_new_with_mnemonic(_("Download content from remote servers (may be dangerous)"));
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(print_prefs->html_load_ext_content), 
print_prefs->load_ext_content);
-    gtk_grid_attach(GTK_GRID(grid), print_prefs->html_load_ext_content, 1, 1, 1, 1);
-
-    /* phantom alignment */
-    dummy = gtk_label_new(" ");
-    gtk_widget_set_hexpand(dummy, TRUE);
-    gtk_grid_attach(GTK_GRID(grid), dummy, 2, 1, 1, 1);
-#endif
-
     /* margins */
     grid = create_options_group(_("Margins"), page, 0, 2, 2);
 
@@ -706,12 +706,6 @@ message_prefs_apply(GtkPrintOperation * operation, GtkWidget * widget,
        balsa_app.margin_left /= 25.4;
        balsa_app.margin_right /= 25.4;
     }
-#ifdef HAVE_HTML_WIDGET
-    print_prefs->setup->print_alt_html =
-       !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(print_prefs->html_print));
-    print_prefs->setup->html_load_ext_content =
-       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(print_prefs->html_load_ext_content));
-#endif
 }
 
 
@@ -741,9 +735,6 @@ message_print(LibBalsaMessage * msg, GtkWindow * parent)
     GtkPrintOperationResult res;
     BalsaPrintData *print_data;
     BalsaPrintPrefs print_prefs;
-#ifdef HAVE_HTML_WIDGET
-    InternetAddressList *from;
-#endif
     GError *err = NULL;
 
     print = gtk_print_operation_new();
@@ -765,12 +756,6 @@ message_print(LibBalsaMessage * msg, GtkWindow * parent)
     /* create a print context */
     print_data = g_new0(BalsaPrintData, 1);
     print_data->message = msg;
-#ifdef HAVE_HTML_WIDGET
-    print_prefs.setup = &print_data->setup;
-    from = libbalsa_message_get_headers(msg)->from;
-    print_prefs.prefer_text = balsa_app.display_alt_plain && !libbalsa_html_get_prefer_html(from);
-    print_prefs.load_ext_content = libbalsa_html_get_load_content(from);
-#endif
 
     g_signal_connect(print, "begin_print", G_CALLBACK(begin_print), print_data);
     g_signal_connect(print, "draw_page", G_CALLBACK(draw_page), print_data);


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