[evolution/wip/webkit-composer: 876/966] EEditorWidget: Again fix initial caret position when converting from HTML to plain
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit-composer: 876/966] EEditorWidget: Again fix initial caret position when converting from HTML to plain
- Date: Wed, 23 Apr 2014 11:07:04 +0000 (UTC)
commit 15072bbc20c4c29272e2aba48fa98818ee724882
Author: Tomas Popela <tpopela redhat com>
Date: Thu Mar 6 16:56:24 2014 +0100
EEditorWidget: Again fix initial caret position when converting from HTML to plain
e-util/e-editor-widget.c | 116 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 99 insertions(+), 17 deletions(-)
---
diff --git a/e-util/e-editor-widget.c b/e-util/e-editor-widget.c
index b0ad46b..c178217 100644
--- a/e-util/e-editor-widget.c
+++ b/e-util/e-editor-widget.c
@@ -2271,14 +2271,20 @@ editor_widget_process_document_from_convertor (EEditorWidget *widget,
WebKitDOMDocument *document_convertor)
{
EEditorSelection *selection = e_editor_widget_get_selection (widget);
+ gboolean start_bottom;
gchar *inner_text, *inner_html;
gint ii;
+ GSettings *settings;
WebKitDOMDocument *document;
WebKitDOMElement *paragraph, *new_blockquote, *top_signature;
WebKitDOMElement *cite_body, *signature;
WebKitDOMHTMLElement *body, *body_convertor;
WebKitDOMNodeList *list;
+ settings = g_settings_new ("org.gnome.evolution.mail");
+ start_bottom = g_settings_get_boolean (settings, "composer-reply-start-bottom");
+ g_object_unref (settings);
+
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
body = webkit_dom_document_get_body (document);
body_convertor = webkit_dom_document_get_body (document_convertor);
@@ -2334,15 +2340,14 @@ editor_widget_process_document_from_convertor (EEditorWidget *widget,
cite_body = webkit_dom_document_query_selector (
document_convertor, "span.-x-evo-cite-body", NULL);
- if (cite_body) {
- /* Remove initial paragraph as it will be added to right place
- * in e-composer-private.c */
- webkit_dom_node_remove_child (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (paragraph),
- NULL);
+ top_signature = webkit_dom_document_query_selector (
+ document, ".-x-evo-top-signature", NULL);
+ signature = webkit_dom_document_query_selector (
+ document, "span.-x-evo-signature", NULL);
- e_editor_selection_save_caret_position (selection);
+ if (cite_body) {
+ if (!(top_signature && start_bottom))
+ e_editor_selection_save_caret_position (selection);
} else {
webkit_dom_node_append_child (
WEBKIT_DOM_NODE (paragraph),
@@ -2352,11 +2357,6 @@ editor_widget_process_document_from_convertor (EEditorWidget *widget,
NULL);
}
- top_signature = webkit_dom_document_query_selector (
- document, ".-x-evo-top-signature", NULL);
- signature = webkit_dom_document_query_selector (
- document, "span.-x-evo-signature", NULL);
-
new_blockquote = webkit_dom_document_create_element (
document, "blockquote", NULL);
webkit_dom_element_set_attribute (
@@ -2373,10 +2373,92 @@ editor_widget_process_document_from_convertor (EEditorWidget *widget,
parse_html_into_paragraphs (
widget, document, new_blockquote, inner_html, TRUE);
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (new_blockquote),
- NULL);
+
+ if (start_bottom) {
+ if (signature) {
+ WebKitDOMNode *parent =
+ webkit_dom_node_get_parent_node (
+ WEBKIT_DOM_NODE (signature));
+ if (top_signature) {
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (new_blockquote),
+ NULL);
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (paragraph),
+ NULL);
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (paragraph),
+ e_editor_selection_get_caret_position_node (
+ document),
+ NULL);
+ } else {
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (new_blockquote),
+ WEBKIT_DOM_NODE (parent),
+ NULL);
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (paragraph),
+ webkit_dom_node_get_next_sibling (
+ WEBKIT_DOM_NODE (new_blockquote)),
+ NULL);
+ }
+ } else {
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (new_blockquote),
+ NULL);
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (paragraph),
+ webkit_dom_node_get_next_sibling (
+ WEBKIT_DOM_NODE (new_blockquote)),
+ NULL);
+ }
+ } else {
+ if (signature) {
+ WebKitDOMNode *parent =
+ webkit_dom_node_get_parent_node (
+ WEBKIT_DOM_NODE (signature));
+
+ if (top_signature) {
+ WebKitDOMElement *br;
+
+ br = webkit_dom_document_create_element (
+ document, "BR", NULL);
+
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (new_blockquote),
+ NULL);
+ /* Insert NL after signature */
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (br),
+ webkit_dom_node_get_next_sibling (
+ WEBKIT_DOM_NODE (paragraph)),
+ NULL);
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (parent),
+ WEBKIT_DOM_NODE (br),
+ NULL);
+ } else
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (new_blockquote),
+ WEBKIT_DOM_NODE (parent),
+ NULL);
+ } else {
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (new_blockquote),
+ NULL);
+ }
+ }
} else {
WebKitDOMNode *signature_clone, *first_child;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]