[evolution/webkit] Finish porting of printing - solves all print-out rendering issues
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit] Finish porting of printing - solves all print-out rendering issues
- Date: Fri, 16 Dec 2011 16:20:24 +0000 (UTC)
commit 41fb32ab256e04ad5e2a138c4baf6b7364cb6a3b
Author: Dan VrÃtil <dvratil redhat com>
Date: Fri Dec 16 17:17:24 2011 +0100
Finish porting of printing - solves all print-out rendering issues
Selecting which headers to print or re-ordering them is now reflected
in real time in the webkit webview using DOM API so there is no need
to reload the document after the printing dialog is confirmed. This
solution seems to solve all problems with incorrectly rendered print-out.
mail/e-mail-printer.c | 253 +++++++++++++++++++++++++------------------
mail/e-mail-printer.h | 3 +-
mail/e-mail-reader-utils.c | 51 +---------
mail/em-composer-utils.c | 2 +-
mail/em-format-html-print.c | 47 +--------
mail/em-format-html-print.h | 5 +-
mail/em-format-html.c | 35 +++++--
mail/em-format-html.h | 1 +
8 files changed, 182 insertions(+), 215 deletions(-)
---
diff --git a/mail/e-mail-printer.c b/mail/e-mail-printer.c
index bf8f28d..2f275d2 100644
--- a/mail/e-mail-printer.c
+++ b/mail/e-mail-printer.c
@@ -24,8 +24,11 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#include <e-util/e-print.h>
#include <e-util/e-marshal.h>
+#include <webkit/webkitdom.h>
+
#include "e-mail-printer.h"
#include "em-format-html-print.h"
@@ -48,10 +51,10 @@ struct _EMailPrinterPrivate {
WebKitWebView *webview; /* WebView to print from */
gchar *uri;
- GtkWidget *buttons[BUTTONS_COUNT];
- GtkWidget *treeview;
+ GtkWidget *buttons[BUTTONS_COUNT];
+ GtkWidget *treeview;
- GtkPrintOperation *operation;
+ GtkPrintOperation *operation;
};
G_DEFINE_TYPE (
@@ -147,8 +150,8 @@ emp_run_print_operation (EMailPrinter *emp)
EMFormat *emf;
SoupSession *session;
GHashTable *formatters;
- WebKitWebFrame *frame;
gchar *mail_uri;
+ WebKitWebFrame *frame;
emf = EM_FORMAT (emp->priv->efhp);
mail_uri = em_format_build_mail_uri (emf->folder, emf->message_uid, NULL, NULL);
@@ -166,30 +169,51 @@ emp_run_print_operation (EMailPrinter *emp)
emp->priv->uri = g_strconcat (mail_uri, "?part_id=print_layout", NULL);
if (emp->priv->webview == NULL) {
- emp->priv->webview = WEBKIT_WEB_VIEW (webkit_web_view_new ());
+ emp->priv->webview = WEBKIT_WEB_VIEW (e_web_view_new());
+ e_web_view_set_enable_frame_flattening (E_WEB_VIEW (emp->priv->webview), FALSE);
g_object_ref_sink (emp->priv->webview);
- g_signal_connect_swapped (emp->priv->operation, "begin-print",
- G_CALLBACK (webkit_web_view_reload), emp->priv->webview);
}
- webkit_web_view_load_uri (emp->priv->webview, emp->priv->uri);
+ webkit_web_view_load_uri (emp->priv->webview, emp->priv->uri);
+ frame = webkit_web_view_get_main_frame (emp->priv->webview);
+ webkit_web_frame_print_full (frame, emp->priv->operation,
+ GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL);
- frame = webkit_web_view_get_main_frame (emp->priv->webview);
- webkit_web_frame_print_full (frame, emp->priv->operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL);
-
- g_free (mail_uri);
+ g_free (mail_uri);
}
+static void
+set_header_visible (EMailPrinter *emp,
+ EMFormatHeader *header,
+ gint index,
+ gboolean visible)
+{
+ WebKitDOMDocument *document;
+ WebKitDOMNodeList *headers;
+ WebKitDOMElement *element;
+ WebKitDOMCSSStyleDeclaration *style;
+
+ document = webkit_web_view_get_dom_document (emp->priv->webview);
+ headers = webkit_dom_document_get_elements_by_class_name (document, "header-item");
+
+ g_return_if_fail (index < webkit_dom_node_list_get_length (headers));
+
+ element = WEBKIT_DOM_ELEMENT (webkit_dom_node_list_item (headers, index));
+ style = webkit_dom_element_get_style (element);
+ webkit_dom_css_style_declaration_set_property (style,
+ "display", (visible ? "table-row" : "none"), "", NULL);
+}
static void
header_active_renderer_toggled_cb (GtkCellRendererToggle *renderer,
gchar *path,
EMailPrinter *emp)
{
- EMFormat *emf = (EMFormat *)emp->priv->efhp;
GtkTreeIter iter;
+ GtkTreePath *p;
gboolean active;
EMFormatHeader *header;
+ gint *indices;
gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (emp->priv->headers),
&iter, path);
@@ -200,13 +224,11 @@ header_active_renderer_toggled_cb (GtkCellRendererToggle *renderer,
COLUMN_HEADER_STRUCT, &header, -1);
gtk_list_store_set (GTK_LIST_STORE (emp->priv->headers), &iter,
COLUMN_ACTIVE, !active, -1);
-
- /* If the new state is active */
- if ((!active) == TRUE) {
- em_format_add_header_struct (emf, header);
- } else {
- em_format_remove_header_struct (emf, header);
- }
+
+ p = gtk_tree_path_new_from_string (path);
+ indices = gtk_tree_path_get_indices (p);
+ set_header_visible (emp, header, indices[0], !active);
+ gtk_tree_path_free (p);
}
static void
@@ -214,7 +236,6 @@ emp_headers_tab_toggle_selection (GtkWidget *button,
gpointer user_data)
{
EMailPrinter *emp = user_data;
- EMFormat *emf = (EMFormat *) emp->priv->efhp;
GtkTreeIter iter;
gboolean select;
@@ -230,16 +251,18 @@ emp_headers_tab_toggle_selection (GtkWidget *button,
do {
EMFormatHeader *header;
+ GtkTreePath *path;
+ gint *indices;
gtk_tree_model_get (GTK_TREE_MODEL (emp->priv->headers), &iter,
COLUMN_HEADER_STRUCT, &header, -1);
gtk_list_store_set (GTK_LIST_STORE (emp->priv->headers), &iter,
COLUMN_ACTIVE, select, -1);
- if (select)
- em_format_add_header_struct (emf, header);
- else
- em_format_remove_header_struct (emf, header);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (emp->priv->headers), &iter);
+ indices = gtk_tree_path_get_indices (path);
+ set_header_visible (emp, header, indices[0], select);
+ gtk_tree_path_free (path);
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (emp->priv->headers), &iter));
}
@@ -293,77 +316,127 @@ emp_headers_tab_move (GtkWidget *button,
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeRowReference *selection_middle;
+ gint *indices;
+
+ WebKitDOMDocument *document;
+ WebKitDOMNodeList *headers;
+ WebKitDOMNode *header, *parent;
model = GTK_TREE_MODEL (emp->priv->headers);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (emp->priv->treeview));
selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
+ /* The order of header rows in the HMTL document should be in sync with
+ order of headers in the listview and in efhp->headers_list */
+ document = webkit_web_view_get_dom_document (emp->priv->webview);
+ headers = webkit_dom_document_get_elements_by_class_name (document, "header-item");
+
l = g_list_nth (selected_rows, g_list_length (selected_rows) / 2);
selection_middle = gtk_tree_row_reference_new (model, l->data);
- references = NULL;
+ for (l = selected_rows; l; l = l->next) {
+ references = g_list_prepend (references,
+ gtk_tree_row_reference_new (model, l->data));
+ }
if (button == emp->priv->buttons[BUTTON_TOP]) {
- for (l = selected_rows; l; l = l->next) {
- references = g_list_prepend (references,
- gtk_tree_row_reference_new (model, l->data));
- }
-
for (l = references; l; l = l->next) {
+ /* Move the rows in the view */
path = gtk_tree_row_reference_get_path (l->data);
gtk_tree_model_get_iter (model, &iter, path);
gtk_list_store_move_after (emp->priv->headers, &iter, NULL);
+
+ /* Move the header row in HTML document */
+ indices = gtk_tree_path_get_indices (path);
+ header = webkit_dom_node_list_item (headers, indices[0]);
+ parent = webkit_dom_node_get_parent_node (header);
+ webkit_dom_node_remove_child (parent, header, NULL);
+ webkit_dom_node_insert_before (parent, header,
+ webkit_dom_node_get_first_child (parent), NULL);
+
gtk_tree_path_free (path);
}
- g_list_foreach (references, (GFunc) gtk_tree_row_reference_free, NULL);
- g_list_free (references);
+ } else if (button == emp->priv->buttons[BUTTON_UP]) {
+
+ GtkTreeIter *iter_prev;
+ WebKitDOMNode *node2;
+
+ references = g_list_reverse (references);
+
+ for (l = references; l; l = l->next) {
- } else if (button == emp->priv->buttons[BUTTON_UP]) {
+ path = gtk_tree_row_reference_get_path (l->data);
+ gtk_tree_model_get_iter (model, &iter, path);
+ iter_prev = gtk_tree_iter_copy (&iter);
+ gtk_tree_model_iter_previous (model, iter_prev);
- GtkTreeIter iter_last;
+ gtk_list_store_move_before (emp->priv->headers, &iter, iter_prev);
- gtk_tree_model_get_iter (model, &iter, selected_rows->data);
- gtk_tree_model_iter_previous (model, &iter);
+ indices = gtk_tree_path_get_indices (path);
+ header = webkit_dom_node_list_item (headers, indices[0]);
+ node2 = webkit_dom_node_get_previous_sibling (header);
+ parent = webkit_dom_node_get_parent_node (header);
- gtk_tree_model_get_iter (model, &iter_last,
- g_list_last (selected_rows)->data);
+ webkit_dom_node_remove_child (parent, header, NULL);
+ webkit_dom_node_insert_before (parent, header, node2, NULL);
- gtk_list_store_move_after (emp->priv->headers, &iter, &iter_last);
+ gtk_tree_path_free (path);
+ gtk_tree_iter_free (iter_prev);
+ }
} else if (button == emp->priv->buttons[BUTTON_DOWN]) {
- GtkTreeIter iter_last;
+ GtkTreeIter *iter_next;
+ WebKitDOMNode *node2;
- gtk_tree_model_get_iter (model, &iter, selected_rows->data);
+ for (l = references; l; l = l->next) {
- gtk_tree_model_get_iter (model, &iter_last,
- g_list_last (selected_rows)->data);
- gtk_tree_model_iter_next (model, &iter_last);
+ path = gtk_tree_row_reference_get_path (l->data);
+ gtk_tree_model_get_iter (model, &iter, path);
+ iter_next = gtk_tree_iter_copy (&iter);
+ gtk_tree_model_iter_next (model, iter_next);
- gtk_list_store_move_before (emp->priv->headers, &iter_last, &iter);
+ gtk_list_store_move_after (emp->priv->headers, &iter, iter_next);
- } else if (button == emp->priv->buttons[BUTTON_BOTTOM]) {
+ indices = gtk_tree_path_get_indices (path);
+ header = webkit_dom_node_list_item (headers, indices[0]);
+ node2 = webkit_dom_node_get_next_sibling (header);
+ parent = webkit_dom_node_get_parent_node (header);
- for (l = selected_rows; l; l = l->next) {
- references = g_list_prepend (references,
- gtk_tree_row_reference_new (model, l->data));
+ webkit_dom_node_remove_child (parent, header, NULL);
+ webkit_dom_node_insert_before (parent, header,
+ webkit_dom_node_get_next_sibling (node2), NULL);
+
+ gtk_tree_path_free (path);
+ gtk_tree_iter_free (iter_next);
}
+
+ } else if (button == emp->priv->buttons[BUTTON_BOTTOM]) {
+
references = g_list_reverse (references);
for (l = references; l; l = l->next) {
path = gtk_tree_row_reference_get_path (l->data);
gtk_tree_model_get_iter (model, &iter, path);
gtk_list_store_move_before (emp->priv->headers, &iter, NULL);
- gtk_tree_path_free (path);
- }
- g_list_foreach (references, (GFunc) gtk_tree_row_reference_free, NULL);
- g_list_free (references);
+ /* Move the header row in HTML document */
+ indices = gtk_tree_path_get_indices (path);
+ header = webkit_dom_node_list_item (headers, indices[0]);
+ parent = webkit_dom_node_get_parent_node (header);
+ webkit_dom_node_remove_child (parent, header, NULL);
+ webkit_dom_node_append_child (parent, header, NULL);
+ gtk_tree_path_free (path);
+ }
};
+ g_list_foreach (references, (GFunc) gtk_tree_row_reference_free, NULL);
+ g_list_free (references);
+
+ /* Keep the selection in middle of the screen */
path = gtk_tree_row_reference_get_path (selection_middle);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (emp->priv->treeview),
path, COLUMN_ACTIVE, TRUE, 0.5, 0.5);
@@ -380,7 +453,7 @@ static GtkWidget*
emp_create_headers_tab (GtkPrintOperation *operation,
EMailPrinter *emp)
{
- GtkWidget *vbox, *hbox, *label, *scw, *button;
+ GtkWidget *vbox, *hbox, *scw, *button;
GtkTreeView *view;
GtkTreeSelection *selection;
GtkTreeViewColumn *column;
@@ -389,11 +462,8 @@ emp_create_headers_tab (GtkPrintOperation *operation,
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_box_pack_end (GTK_BOX (hbox), vbox, FALSE, FALSE, 5);
-/*
- label = gtk_label_new (_("Select headers you want to print"));
- gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 2, 1);
-*/
- emp->priv->treeview = gtk_tree_view_new_with_model (
+
+ emp->priv->treeview = gtk_tree_view_new_with_model (
GTK_TREE_MODEL (emp->priv->headers));
view = GTK_TREE_VIEW (emp->priv->treeview);
selection = gtk_tree_view_get_selection (view);
@@ -431,7 +501,7 @@ emp_create_headers_tab (GtkPrintOperation *operation,
G_CALLBACK (emp_headers_tab_toggle_selection), emp);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, TRUE, 5);
- button = gtk_button_new_with_label (_("Unselect All"));
+ button = gtk_button_new_from_stock (GTK_STOCK_CLEAR);
emp->priv->buttons[BUTTON_SELECT_NONE] = button;
g_signal_connect (button, "clicked",
G_CALLBACK (emp_headers_tab_toggle_selection), emp);
@@ -472,36 +542,6 @@ emp_create_headers_tab (GtkPrintOperation *operation,
}
static void
-emp_headers_tab_apply (GtkPrintOperation *operation,
- GtkWidget *widget,
- gpointer user_data)
-{
- EMailPrinter *emp = user_data;
- GtkTreeIter iter;
- GtkTreeModel *model;
- EMFormat *emf;
-
- emf = EM_FORMAT (emp->priv->efhp);
- model = GTK_TREE_MODEL (emp->priv->headers);
-
- g_queue_clear (&emf->header_list);
- gtk_tree_model_get_iter_first (model, &iter);
- do {
- gboolean active;
- EMFormatHeader *header;
-
- gtk_tree_model_get (model, &iter,
- COLUMN_ACTIVE, &active,
- COLUMN_HEADER_STRUCT, &header, -1);
-
- if (active)
- em_format_add_header_struct (emf, header);
-
- } while (gtk_tree_model_iter_next (model, &iter));
-
-}
-
-static void
emp_set_formatter (EMailPrinter *emp,
EMFormatHTMLPrint *formatter)
{
@@ -509,6 +549,7 @@ emp_set_formatter (EMailPrinter *emp,
CamelMediumHeader *header;
GArray *headers;
gint i;
+ GtkTreeIter last_known;
g_return_if_fail (EM_IS_FORMAT_HTML_PRINT (formatter));
@@ -532,7 +573,6 @@ emp_set_formatter (EMailPrinter *emp,
GtkTreeIter iter;
GList *found_header;
EMFormatHeader *emfh;
- gint index = G_MAXINT;
header = &g_array_index (headers, CamelMediumHeader, i);
emfh = em_format_header_new (header->name, header->value);
@@ -540,19 +580,24 @@ emp_set_formatter (EMailPrinter *emp,
found_header = g_queue_find_custom (&EM_FORMAT (formatter)->header_list,
emfh, (GCompareFunc) emp_header_name_equal);
- if (found_header) {
- index = g_queue_link_index (&EM_FORMAT (formatter)->header_list,
- found_header);
- }
-
- gtk_list_store_insert (emp->priv->headers, &iter, index);
+ if (!found_header) {
+ emfh->flags |= EM_FORMAT_HTML_HEADER_HIDDEN;
+ em_format_add_header_struct (EM_FORMAT (formatter), emfh);
+ gtk_list_store_append (emp->priv->headers, &iter);
+ } else {
+ if (gtk_list_store_iter_is_valid (emp->priv->headers, &last_known))
+ gtk_list_store_insert_after (emp->priv->headers, &iter, &last_known);
+ else
+ gtk_list_store_insert_after (emp->priv->headers, &iter, NULL);
+
+ last_known = iter;
+ }
gtk_list_store_set (emp->priv->headers, &iter,
COLUMN_ACTIVE, (found_header != NULL),
COLUMN_HEADER_NAME, emfh->name,
COLUMN_HEADER_VALUE, emfh->value,
COLUMN_HEADER_STRUCT, emfh, -1);
-
}
camel_medium_free_headers (CAMEL_MEDIUM (emf->message), headers);
@@ -684,13 +729,12 @@ e_mail_printer_init (EMailPrinter *emp)
}
EMailPrinter*
-e_mail_printer_new (EMFormatHTML* source,
- GtkPrintOperationAction action)
+e_mail_printer_new (EMFormatHTML* source)
{
EMailPrinter *emp;
EMFormatHTMLPrint *efhp;
- efhp = em_format_html_print_new (source, action);
+ efhp = em_format_html_print_new (source);
emp = g_object_new (E_TYPE_MAIL_PRINTER,
"print-formatter", efhp, NULL);
@@ -708,13 +752,12 @@ e_mail_printer_print (EMailPrinter *emp,
if (emp->priv->operation)
g_object_unref (emp->priv->operation);
- emp->priv->operation = gtk_print_operation_new ();
+ emp->priv->operation = e_print_operation_new ();
+ gtk_print_operation_set_unit (emp->priv->operation, GTK_UNIT_PIXEL);
gtk_print_operation_set_show_progress (emp->priv->operation, TRUE);
g_signal_connect (emp->priv->operation, "create-custom-widget",
G_CALLBACK (emp_create_headers_tab), emp);
- g_signal_connect (emp->priv->operation, "custom-widget-apply",
- G_CALLBACK (emp_headers_tab_apply), emp);
g_signal_connect (emp->priv->operation, "done",
G_CALLBACK (emp_printing_done), emp);
g_signal_connect (emp->priv->operation, "draw-page",
diff --git a/mail/e-mail-printer.h b/mail/e-mail-printer.h
index e8eea75..95ccf06 100644
--- a/mail/e-mail-printer.h
+++ b/mail/e-mail-printer.h
@@ -63,8 +63,7 @@ struct _EMailPrinterClass {
GType e_mail_printer_get_type (void);
-EMailPrinter * e_mail_printer_new (EMFormatHTML *source,
- GtkPrintOperationAction action);
+EMailPrinter * e_mail_printer_new (EMFormatHTML *source);
void e_mail_printer_print (EMailPrinter *printer,
GCancellable *cancellable);
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 80d6674..d071248 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -461,55 +461,6 @@ e_mail_reader_open_selected (EMailReader *reader)
}
static void
-mail_reader_printing_finished (GtkPrintOperation *operation,
- GtkPrintOperationResult result,
- EActivity *activity)
-{
- WebKitWebView *webview;
-
- webview = g_object_get_data (G_OBJECT (activity), "webview");
-
- /* Destroy the webview */
- g_object_unref (webview);
-
- e_activity_set_state (activity, E_ACTIVITY_COMPLETED);
-}
-
-
-static void
-webview_document_load_finished_cb (WebKitWebView *webview,
- GParamSpec *pspec,
- EActivity *activity)
-{
- GtkPrintOperation *operation;
- GtkPrintOperationAction action;
- EMFormatHTMLPrint *efhp;
- WebKitWebFrame *frame;
-
- WebKitLoadStatus status = webkit_web_view_get_load_status (webview);
-
- if (status != WEBKIT_LOAD_FINISHED)
- return;
-
- frame = webkit_web_view_get_main_frame (webview);
- efhp = g_object_get_data (G_OBJECT (activity), "efhp");
- action = em_format_html_print_get_action (efhp);
-
- operation = gtk_print_operation_new ();
- gtk_print_operation_set_show_progress (operation, TRUE);
-
- g_object_set_data (G_OBJECT (operation), "webview", webview);
- g_signal_connect (operation, "done",
- G_CALLBACK (mail_reader_printing_finished), activity);
-
- action = em_format_html_print_get_action (efhp);
- webkit_web_frame_print_full (frame,
- operation, action, NULL);
-
- g_object_unref (efhp);
-}
-
-static void
printing_done_cb (EMailPrinter *printer,
GtkPrintOperation *operation,
GtkPrintOperationResult result,
@@ -565,7 +516,7 @@ e_mail_reader_print (EMailReader *reader,
e_activity_set_state (activity, E_ACTIVITY_RUNNING);
cancellable = e_activity_get_cancellable (activity);
- printer = e_mail_printer_new (formatter, action);
+ printer = e_mail_printer_new (formatter);
g_signal_connect (printer, "done",
G_CALLBACK (printing_done_cb), activity);
e_mail_printer_print (printer, cancellable);
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 902e239..4df9e65 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -930,7 +930,7 @@ em_utils_composer_print_cb (EMsgComposer *composer,
em_format_parse ((EMFormat *) efhd, message, NULL, NULL);
/* Use EMailPrinter and WebKit to print the message */
- emp = e_mail_printer_new ((EMFormatHTML *) efhd, action);
+ emp = e_mail_printer_new ((EMFormatHTML *) efhd);
g_signal_connect (emp, "done",
G_CALLBACK (composer_print_done_cb), efhd);
diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c
index bc1b27b..f27f2a2 100644
--- a/mail/em-format-html-print.c
+++ b/mail/em-format-html-print.c
@@ -42,7 +42,6 @@ struct _EMFormatHTMLPrintPrivate {
EMFormatHTML *original_formatter;
EMFormatPURI *top_level_puri;
- GtkPrintOperationAction print_action;
/* List of attachment PURIs */
GList *attachments;
@@ -51,8 +50,7 @@ struct _EMFormatHTMLPrintPrivate {
enum {
PROP_0,
- PROP_ORIGINAL_FORMATTER,
- PROP_PRINT_ACTION
+ PROP_ORIGINAL_FORMATTER
};
static void efhp_write_print_layout (EMFormat *emf, EMFormatPURI *puri, CamelStream *stream, EMFormatWriterInfo *info, GCancellable *cancellable);
@@ -136,7 +134,7 @@ efhp_write_headers (EMFormat *emf,
subject = camel_header_decode_string (buf, "UTF-8");
str = g_string_new ("<table border=\"0\" cellspacing=\"5\" " \
"cellpadding=\"0\" class=\"printing-header\">\n");
- g_string_append_printf (str, "<tr><td colspan=\"2\"><h1>%s</h1></td></tr>\n",
+ g_string_append_printf (str, "<tr class='header-item'><td colspan=\"2\"><h1>%s</h1></td></tr>\n",
subject);
g_free (subject);
@@ -451,10 +449,6 @@ efhp_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- EMFormatHTMLPrintPrivate *priv;
-
- priv = EM_FORMAT_HTML_PRINT (object)->priv;
-
switch (prop_id) {
case PROP_ORIGINAL_FORMATTER:
@@ -462,12 +456,6 @@ efhp_set_property (GObject *object,
EM_FORMAT_HTML_PRINT (object),
(EMFormat *) g_value_get_object (value));
return;
-
- case PROP_PRINT_ACTION:
- priv->print_action =
- g_value_get_int (value);
- return;
-
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -489,11 +477,6 @@ efhp_get_property (GObject *object,
g_value_set_pointer (value,
priv->original_formatter);
return;
-
- case PROP_PRINT_ACTION:
- g_value_set_int (value,
- priv->print_action);
- return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -532,19 +515,6 @@ em_format_html_print_class_init (EMFormatHTMLPrintClass *klass)
EM_TYPE_FORMAT,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (
- object_class,
- PROP_PRINT_ACTION,
- g_param_spec_int (
- "print-action",
- NULL,
- NULL,
- GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
- GTK_PRINT_OPERATION_ACTION_EXPORT,
- GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
}
static void
@@ -584,14 +554,12 @@ em_format_html_print_get_type (void)
}
EMFormatHTMLPrint *
-em_format_html_print_new (EMFormatHTML *source,
- GtkPrintOperationAction action)
+em_format_html_print_new (EMFormatHTML *source)
{
EMFormatHTMLPrint *efhp;
efhp = g_object_new (EM_TYPE_FORMAT_HTML_PRINT,
"original-formatter", source,
- "print-action", action,
NULL);
return efhp;
@@ -617,12 +585,3 @@ em_format_html_print_message (EMFormatHTMLPrint *efhp,
/* FIXME Not passing a GCancellable here. */
em_format_parse (EM_FORMAT (efhp), message, folder, NULL);
}
-
-GtkPrintOperationAction
-em_format_html_print_get_action (EMFormatHTMLPrint *efhp)
-{
- g_return_val_if_fail (EM_IS_FORMAT_HTML_PRINT (efhp),
- GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
-
- return efhp->priv->print_action;
-}
\ No newline at end of file
diff --git a/mail/em-format-html-print.h b/mail/em-format-html-print.h
index 37eb2f4..024356e 100644
--- a/mail/em-format-html-print.h
+++ b/mail/em-format-html-print.h
@@ -58,14 +58,11 @@ struct _EMFormatHTMLPrintClass {
GType em_format_html_print_get_type (void);
EMFormatHTMLPrint *
- em_format_html_print_new (EMFormatHTML *source,
- GtkPrintOperationAction action);
+ em_format_html_print_new (EMFormatHTML *source);
void em_format_html_print_message (EMFormatHTMLPrint *efhp,
CamelMimeMessage *message,
CamelFolder *folder,
const gchar *uid);
-GtkPrintOperationAction
- em_format_html_print_get_action (EMFormatHTMLPrint *efhp);
G_END_DECLS
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 3fef161..f52b4fc 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -921,6 +921,22 @@ efh_write_headers (EMFormat *emf,
" else { f.display=\"block\"; s.display=\"none\";\n"
" i.src=i.src.substr(0,i.src.lastIndexOf(\"/\"))+\"/minus.png\"; window.headers_collapsed(false, window.em_format_html); }\n"
"}\n"
+ "function set_header_visible(header,value,visible) {\n}"
+ " var hdrs=window.document.getElementsByClassName('header-item');\n"
+ " for (var i = 0; i < hdrs.length; i++) { \n"
+ " var hdr = hdrs[i]; \n"
+ " if (hdr.className.indexOf('rtl') == -1) { \n"
+ " if ((hdr.firstChild.textContent == header) && \n"
+ " (hdr.firstChild.nextSibling.textContent == value)) { \n"
+ " hdr.style.display=(visible ? 'block' : 'none');\n"
+ " }\n"
+ " } else { \n"
+ " if ((hdr.firstChild.textContent == value) && \n"
+ " (hdr.firstChild.nextSibling.textContent == header)) { \n"
+ " hdr.style.display=(visible ? 'block' : 'none');\n"
+ " }\n"
+ " }\n"
+ "}\n"
"</script>\n"
"<style type=\"text/css\">body { background: #%06x; }</style>"
"<table border=\"0\" width=\"100%%\" height=\"100%%\" style=\"color: #%06x;\">\n"
@@ -1791,30 +1807,31 @@ efh_format_text_header (EMFormatHTML *emfh,
if (flags & EM_FORMAT_HTML_HEADER_NOCOLUMNS) {
if (flags & EM_FORMAT_HEADER_BOLD) {
- fmt = "<tr><td><b>%s:</b> %s</td></tr>";
+ fmt = "<tr class=\"header-item\" style=\"display: %s\"><td><b>%s:</b> %s</td></tr>";
} else {
- fmt = "<tr><td>%s: %s</td></tr>";
+ fmt = "<tr class=\"header-item\" style=\"display: %s\"><td>%s: %s</td></tr>";
}
} else if (flags & EM_FORMAT_HTML_HEADER_NODEC) {
if (is_rtl)
- fmt = "<tr><td align=\"right\" valign=\"top\" width=\"100%%\">%2$s</td><th valign=top align=\"left\" nowrap>%1$s<b> </b></th></tr>";
+ fmt = "<tr class=\"header-item rtl\" style=\"display: %s\"><td align=\"right\" valign=\"top\" width=\"100%%\">%2$s</td><th valign=top align=\"left\" nowrap>%1$s<b> </b></th></tr>";
else
- fmt = "<tr><th align=\"right\" valign=\"top\" nowrap>%s<b> </b></th><td valign=top>%s</td></tr>";
+ fmt = "<tr class=\"header-item\" style=\"display: %s\"><th align=\"right\" valign=\"top\" nowrap>%s<b> </b></th><td valign=top>%s</td></tr>";
} else {
if (flags & EM_FORMAT_HEADER_BOLD) {
if (is_rtl)
- fmt = "<tr><td align=\"right\" valign=\"top\" width=\"100%%\">%2$s</td><th align=\"left\" nowrap>%1$s:<b> </b></th></tr>";
+ fmt = "<tr class=\"header-item rtl\" style=\"display: %s\"><td align=\"right\" valign=\"top\" width=\"100%%\">%2$s</td><th align=\"left\" nowrap>%1$s:<b> </b></th></tr>";
else
- fmt = "<tr><th align=\"right\" valign=\"top\" nowrap>%s:<b> </b></th><td>%s</td></tr>";
+ fmt = "<tr class=\"header-item\" style=\"display: %s\"><th align=\"right\" valign=\"top\" nowrap>%s:<b> </b></th><td>%s</td></tr>";
} else {
if (is_rtl)
- fmt = "<tr><td align=\"right\" valign=\"top\" width=\"100%\">%2$s</td><td align=\"left\" nowrap>%1$s:<b> </b></td></tr>";
+ fmt = "<tr class=\"header-item rtl\" style=\"display: %s\"><td align=\"right\" valign=\"top\" width=\"100%\">%2$s</td><td align=\"left\" nowrap>%1$s:<b> </b></td></tr>";
else
- fmt = "<tr><td align=\"right\" valign=\"top\" nowrap>%s:<b> </b></td><td>%s</td></tr>";
+ fmt = "<tr class=\"header-item\" style=\"display: %s\"><td align=\"right\" valign=\"top\" nowrap>%s:<b> </b></td><td>%s</td></tr>";
}
}
- g_string_append_printf (buffer, fmt, label, html);
+ g_string_append_printf (buffer, fmt,
+ (flags & EM_FORMAT_HTML_HEADER_HIDDEN ? "none" : "table-row"), label, html);
g_free (mhtml);
}
diff --git a/mail/em-format-html.h b/mail/em-format-html.h
index 8ea3e23..ad11db2 100644
--- a/mail/em-format-html.h
+++ b/mail/em-format-html.h
@@ -80,6 +80,7 @@ typedef enum {
#define EM_FORMAT_HTML_HEADER_HTML (EM_FORMAT_HEADER_LAST<<1)
#define EM_FORMAT_HTML_HEADER_NODEC (EM_FORMAT_HEADER_LAST<<2)
#define EM_FORMAT_HTML_HEADER_NOLINKS (EM_FORMAT_HEADER_LAST<<3)
+#define EM_FORMAT_HTML_HEADER_HIDDEN (EM_FORMAT_HEADER_LAST<<4)
#define EM_FORMAT_HTML_HEADER_LAST (EM_FORMAT_HEADER_LAST<<8)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]