[evolution/wip/webkit-composer] EEditorWidget: Fix spellcheck when editting message as new
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit-composer] EEditorWidget: Fix spellcheck when editting message as new
- Date: Mon, 17 Mar 2014 12:27:25 +0000 (UTC)
commit 32b4c8e56993be19c263c2f322a6b82e4b1bc97f
Author: Tomas Popela <tpopela redhat com>
Date: Mon Mar 17 13:14:23 2014 +0100
EEditorWidget: Fix spellcheck when editting message as new
Revert 08dc9a7af5c0c7a8304cb70cc7fb92ac75c7898d and add missing call to
e_editor_widget_force_spell_check.
composer/e-composer-private.c | 1 +
e-util/e-editor-widget.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 64e1500..a1e6aa8 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -870,6 +870,7 @@ composer_move_caret (EMsgComposer *composer)
WEBKIT_DOM_ELEMENT (body), "data-edit-as-new", "", NULL);
e_editor_selection_restore_caret_position (editor_selection);
+ e_editor_widget_force_spell_check (editor_widget);
return;
}
diff --git a/e-util/e-editor-widget.c b/e-util/e-editor-widget.c
index eb0ea60..eaab796 100644
--- a/e-util/e-editor-widget.c
+++ b/e-util/e-editor-widget.c
@@ -287,6 +287,29 @@ e_editor_widget_force_spell_check_for_current_paragraph (EEditorWidget *widget)
}
static void
+move_caret_into_element (WebKitDOMDocument *document,
+ WebKitDOMElement *element)
+{
+ WebKitDOMDOMWindow *window;
+ WebKitDOMDOMSelection *window_selection;
+ WebKitDOMRange *new_range;
+
+ if (!element)
+ return;
+
+ window = webkit_dom_document_get_default_view (document);
+ window_selection = webkit_dom_dom_window_get_selection (window);
+ new_range = webkit_dom_document_create_range (document);
+
+ webkit_dom_range_select_node_contents (
+ new_range, WEBKIT_DOM_NODE (element), NULL);
+ webkit_dom_range_collapse (new_range, FALSE, NULL);
+ webkit_dom_dom_selection_remove_all_ranges (window_selection);
+ webkit_dom_dom_selection_add_range (window_selection, new_range);
+}
+
+
+static void
refresh_spell_check (EEditorWidget *widget,
gboolean enable_spell_check)
{
@@ -313,6 +336,15 @@ refresh_spell_check (EEditorWidget *widget,
selection = e_editor_widget_get_selection (widget);
e_editor_selection_save_caret_position (selection);
+ /* Sometimes the web view is not event focused, so we have to move caret
+ * into body */
+ if (!webkit_dom_document_get_element_by_id (document, "-x-evo-caret-position")) {
+ move_caret_into_element (
+ document,
+ WEBKIT_DOM_ELEMENT (webkit_dom_document_get_body (document)));
+ e_editor_selection_save_caret_position (selection);
+ }
+
/* Block callbacks of selection-changed signal as we don't want to
* recount all the block format things in EEditorSelection and here as well
* when we are moving with caret */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]