[evolution] EHTMLEditor - Headers and credits are in wrong order when forwarding a message or using the inline r
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHTMLEditor - Headers and credits are in wrong order when forwarding a message or using the inline r
- Date: Fri, 17 Oct 2014 12:19:16 +0000 (UTC)
commit 80055cfdbefe3f23176b487a0b19711822e4fb6a
Author: Tomas Popela <tpopela redhat com>
Date: Fri Oct 17 13:57:33 2014 +0200
EHTMLEditor - Headers and credits are in wrong order when forwarding a message or using the inline reply
Mark the headers and citations whe inserting them and restore them on
the right position.
e-util/e-html-editor-view.c | 53 ++++++++++++++++++++++++---
em-format/e-mail-formatter-quote-headers.c | 15 ++++++--
em-format/e-mail-formatter-quote.c | 9 ++---
3 files changed, 63 insertions(+), 14 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 931a869..7b2ab1e 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -1121,14 +1121,34 @@ move_elements_to_body (WebKitDOMDocument *document)
gint ii;
list = webkit_dom_document_query_selector_all (
- document, "span.-x-evo-to-body", NULL);
+ document, "span.-x-evo-to-body[data-headers]", NULL);
for (ii = webkit_dom_node_list_get_length (list) - 1; ii >= 0; ii--) {
+ WebKitDOMNode *child;
WebKitDOMNode *node = webkit_dom_node_list_item (list, ii);
- while (webkit_dom_node_has_child_nodes (node)) {
+ while ((child = webkit_dom_node_get_first_child (node))) {
webkit_dom_node_insert_before (
WEBKIT_DOM_NODE (body),
- webkit_dom_node_get_first_child (node),
+ child,
+ webkit_dom_node_get_first_child (
+ WEBKIT_DOM_NODE (body)),
+ NULL);
+ }
+
+ remove_node (node);
+ }
+ g_object_unref (list);
+
+ list = webkit_dom_document_query_selector_all (
+ document, "span.-x-evo-to-body[data-credits]", NULL);
+ for (ii = webkit_dom_node_list_get_length (list) - 1; ii >= 0; ii--) {
+ WebKitDOMNode *child;
+ WebKitDOMNode *node = webkit_dom_node_list_item (list, ii);
+
+ while ((child = webkit_dom_node_get_first_child (node))) {
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ child,
webkit_dom_node_get_first_child (
WEBKIT_DOM_NODE (body)),
NULL);
@@ -4343,10 +4363,31 @@ html_editor_view_process_document_from_convertor (EHTMLEditorView *view,
}
}
- /* Move elements to body */
+ /* Move credits to the body */
list = webkit_dom_document_query_selector_all (
- document_convertor, "span.-x-evo-to-body", NULL);
- for (ii = webkit_dom_node_list_get_length (list) - 1; ii >= 0; ii--) {
+ document_convertor, "span.-x-evo-to-body[data-credits]", NULL);
+ length = webkit_dom_node_list_get_length (list);
+ for (ii = 0; ii < length; ii++) {
+ WebKitDOMNode *node, *child;
+
+ node = webkit_dom_node_list_item (list, ii);
+ while ((child = webkit_dom_node_get_first_child (node))) {
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ child,
+ WEBKIT_DOM_NODE (wrapper),
+ NULL);
+ }
+
+ remove_node (node);
+ }
+ g_object_unref (list);
+
+ /* Move headers to body */
+ list = webkit_dom_document_query_selector_all (
+ document_convertor, "span.-x-evo-to-body[data-headers]", NULL);
+ length = webkit_dom_node_list_get_length (list);
+ for (ii = 0; ii < length; ii++) {
WebKitDOMNode *node, *child;
node = webkit_dom_node_list_item (list, ii);
diff --git a/em-format/e-mail-formatter-quote-headers.c b/em-format/e-mail-formatter-quote-headers.c
index e996bd0..bee894f 100644
--- a/em-format/e-mail-formatter-quote-headers.c
+++ b/em-format/e-mail-formatter-quote-headers.c
@@ -32,6 +32,9 @@
#include "e-mail-inline-filter.h"
#include "e-mail-part-headers.h"
+#define HEADER_PREFIX "<span class=\"-x-evo-to-body\" data-headers><pre>"
+#define HEADER_SUFFIX "</pre></span>"
+
typedef EMailFormatterExtension EMailFormatterQuoteHeaders;
typedef EMailFormatterExtensionClass EMailFormatterQuoteHeadersClass;
@@ -69,12 +72,16 @@ emfqe_format_text_header (EMailFormatter *emf,
else
html = value;
+ g_string_append_printf (buffer, HEADER_PREFIX);
+
if (flags & E_MAIL_FORMATTER_HEADER_FLAG_BOLD)
g_string_append_printf (
- buffer, "<b>%s</b>: %s<br>", label, html);
+ buffer, "<b>%s</b>: %s", label, html);
else
g_string_append_printf (
- buffer, "%s: %s<br>", label, html);
+ buffer, "%s: %s", label, html);
+
+ g_string_append_printf (buffer, HEADER_SUFFIX);
g_free (mhtml);
}
@@ -253,7 +260,9 @@ emqfe_headers_format (EMailFormatterExtension *extension,
g_strfreev (default_headers);
- g_string_append (buffer, "<br>\n");
+ g_string_append (buffer, HEADER_PREFIX);
+ g_string_append (buffer, "<br>");
+ g_string_append (buffer, HEADER_SUFFIX);
g_output_stream_write_all (
stream, buffer->str, buffer->len, NULL, cancellable, NULL);
diff --git a/em-format/e-mail-formatter-quote.c b/em-format/e-mail-formatter-quote.c
index b402eda..4df8be6 100644
--- a/em-format/e-mail-formatter-quote.c
+++ b/em-format/e-mail-formatter-quote.c
@@ -122,10 +122,10 @@ mail_formatter_quote_run (EMailFormatter *formatter,
* the special span element and it will be moved to body in EHTMLEditorView */
if (qf->priv->credits && *qf->priv->credits) {
gchar *credits = g_strdup_printf (
- "<span class=\"-x-evo-to-body\"><pre>%s</pre></span>", qf->priv->credits);
+ "<span class=\"-x-evo-to-body\" data-credits><pre>%s</pre></span>",
+ qf->priv->credits);
g_output_stream_write_all (
- stream, credits, strlen (credits),
- NULL, cancellable, NULL);
+ stream, credits, strlen (credits), NULL, cancellable, NULL);
g_free (credits);
}
@@ -135,8 +135,7 @@ mail_formatter_quote_run (EMailFormatter *formatter,
if (qf->priv->flags & E_MAIL_FORMATTER_QUOTE_FLAG_CITE) {
string = "<span class=\"-x-evo-cite-body\"><span>";
g_output_stream_write_all (
- stream, string, strlen (string),
- NULL, cancellable, NULL);
+ stream, string, strlen (string), NULL, cancellable, NULL);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]