[evolution/wip/webkit-composer] Bug 725259 - [webkit-composer] Pasted text should be checked for URLs, emails, ...



commit a01db2f05a84eaf7990a43c8c73aeed3094f60ea
Author: Tomas Popela <tpopela redhat com>
Date:   Mon Mar 3 16:47:24 2014 +0100

    Bug 725259 - [webkit-composer] Pasted text should be checked for URLs, emails, ...

 composer/e-composer-private.c |    1 +
 e-util/e-editor-widget.c      |   41 ++++++++++++++++++++++-------------------
 2 files changed, 23 insertions(+), 19 deletions(-)
---
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index abae034..3a5d9ad 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -592,6 +592,7 @@ e_composer_paste_text (EMsgComposer *composer,
        e_editor_selection_insert_text (editor_selection, text);
 
        e_editor_widget_check_magic_links (editor_widget, FALSE);
+       e_editor_widget_force_spell_check (editor_widget);
 
        g_free (text);
 
diff --git a/e-util/e-editor-widget.c b/e-util/e-editor-widget.c
index 866dcc8..2293077 100644
--- a/e-util/e-editor-widget.c
+++ b/e-util/e-editor-widget.c
@@ -329,12 +329,6 @@ body_input_event_cb (WebKitDOMElement *element,
 
                        webkit_dom_node_set_text_content (node, res->str, NULL);
 
-                       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (editor_widget));
-                       window = webkit_dom_document_get_default_view (document);
-                       selection = webkit_dom_dom_window_get_selection (window);
-
-                       webkit_dom_dom_selection_modify (selection, "move", "right", "character");
-
                        g_string_free (res, TRUE);
                }
                g_free (text);
@@ -701,7 +695,8 @@ editor_widget_check_magic_links (EEditorWidget *widget,
                document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
 
                if (!return_pressed)
-                       e_editor_selection_save_caret_position (e_editor_widget_get_selection (widget));
+                       e_editor_selection_save_caret_position (
+                               e_editor_widget_get_selection (widget));
 
                g_match_info_fetch_pos (match_info, 0, &start_pos_url, &end_pos_url);
 
@@ -713,15 +708,20 @@ editor_widget_check_magic_links (EEditorWidget *widget,
                url_length = g_utf8_strlen (urls[0], -1);
                url_start = url_end - url_length;
 
-               webkit_dom_text_split_text (WEBKIT_DOM_TEXT (node), include_space ? url_end - 1 : url_end, 
NULL);
-
-               url_text_node = webkit_dom_text_split_text (WEBKIT_DOM_TEXT (node), url_start, NULL);
-               url_text_node_clone = webkit_dom_node_clone_node (WEBKIT_DOM_NODE (url_text_node), TRUE);
+               webkit_dom_text_split_text (
+                       WEBKIT_DOM_TEXT (node),
+                       include_space ? url_end - 1 : url_end,
+                       NULL);
 
-               url_text = webkit_dom_text_get_whole_text (WEBKIT_DOM_TEXT (url_text_node_clone));
+               url_text_node = webkit_dom_text_split_text (
+                       WEBKIT_DOM_TEXT (node), url_start, NULL);
+               url_text_node_clone = webkit_dom_node_clone_node (
+                       WEBKIT_DOM_NODE (url_text_node), TRUE);
+               url_text = webkit_dom_text_get_whole_text (
+                       WEBKIT_DOM_TEXT (url_text_node_clone));
 
-               final_url = g_strconcat (g_str_has_prefix (url_text, "www") ? "http://"; : "",
-                                        url_text, NULL);
+               final_url = g_strconcat (
+                       g_str_has_prefix (url_text, "www") ? "http://"; : "", url_text, NULL);
 
                /* Create and prepare new anchor element */
                anchor = webkit_dom_document_create_element (document, "A", NULL);
@@ -743,7 +743,8 @@ editor_widget_check_magic_links (EEditorWidget *widget,
                        NULL);
 
                if (!return_pressed)
-                       e_editor_selection_restore_caret_position (e_editor_widget_get_selection (widget));
+                       e_editor_selection_restore_caret_position (
+                               e_editor_widget_get_selection (widget));
 
                g_free (url_end_raw);
                g_free (final_url);
@@ -806,9 +807,10 @@ editor_widget_check_magic_links (EEditorWidget *widget,
                                gchar *inner_html, *protocol, *new_href;
 
                                protocol = g_strndup (href, strstr (href, "://") - href + 3);
-                               inner_html = webkit_dom_html_element_get_inner_html (WEBKIT_DOM_HTML_ELEMENT 
(parent));
-                               new_href = g_strconcat (protocol, inner_html,
-                                                       appending_to_link ? text_to_append : "", NULL);
+                               inner_html = webkit_dom_html_element_get_inner_html (
+                                       WEBKIT_DOM_HTML_ELEMENT (parent));
+                               new_href = g_strconcat (
+                                       protocol, inner_html, appending_to_link ? text_to_append : "", NULL);
 
                                webkit_dom_html_anchor_element_set_href (
                                        WEBKIT_DOM_HTML_ANCHOR_ELEMENT (parent),
@@ -843,7 +845,8 @@ editor_widget_check_magic_links (EEditorWidget *widget,
                                gchar *inner_html;
                                gchar *new_href;
 
-                               inner_html = webkit_dom_html_element_get_inner_html (WEBKIT_DOM_HTML_ELEMENT 
(parent));
+                               inner_html = webkit_dom_html_element_get_inner_html (
+                                       WEBKIT_DOM_HTML_ELEMENT (parent));
                                new_href = g_strconcat (
                                                inner_html,
                                                appending_to_link ? text_to_append : "",


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