[evolution/wip/webkit-composer] Bug 726629 - [webkit-composer] Scroll to cursor after paste



commit 458874c07e4c640028d7e9024ac6cca8dd48097d
Author: Tomas Popela <tpopela redhat com>
Date:   Wed Mar 19 10:49:19 2014 +0100

    Bug 726629 - [webkit-composer] Scroll to cursor after paste

 composer/e-composer-private.c |    3 +++
 e-util/e-editor-selection.c   |   12 ++++++++++++
 e-util/e-editor-selection.h   |    3 ++-
 3 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 9c06457..1278003 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -492,6 +492,7 @@ e_composer_paste_html (EMsgComposer *composer,
        e_editor_widget_check_magic_links (editor_widget, FALSE);
        e_editor_widget_force_spell_check (editor_widget);
 
+       e_editor_selection_scroll_to_caret (editor_selection);
        g_free (html);
 
        return TRUE;
@@ -550,6 +551,7 @@ e_composer_paste_image (EMsgComposer *composer,
 
                selection = e_editor_widget_get_selection (editor_widget);
                e_editor_selection_insert_image (selection, uri);
+               e_editor_selection_scroll_to_caret (selection);
        } else {
                EAttachment *attachment;
 
@@ -600,6 +602,7 @@ e_composer_paste_text (EMsgComposer *composer,
 
                e_editor_widget_check_magic_links (editor_widget, FALSE);
                e_editor_widget_force_spell_check (editor_widget);
+               e_editor_selection_scroll_to_caret (editor_selection);
        }
 
        g_free (text);
diff --git a/e-util/e-editor-selection.c b/e-util/e-editor-selection.c
index bd1be6c..be2e075 100644
--- a/e-util/e-editor-selection.c
+++ b/e-util/e-editor-selection.c
@@ -5076,3 +5076,15 @@ e_editor_selection_move (EEditorSelection *selection,
 {
        editor_selection_modify (selection, "move", forward, granularity);
 }
+
+void
+e_editor_selection_scroll_to_caret (EEditorSelection *selection)
+{
+       WebKitDOMElement *caret;
+
+       caret = e_editor_selection_save_caret_position (selection);
+
+       webkit_dom_element_scroll_into_view (caret, TRUE);
+
+       e_editor_selection_clear_caret_position_marker (selection);
+}
diff --git a/e-util/e-editor-selection.h b/e-util/e-editor-selection.h
index 845bcfc..28c0974 100644
--- a/e-util/e-editor-selection.h
+++ b/e-util/e-editor-selection.h
@@ -223,7 +223,8 @@ void                e_editor_selection_move         (EEditorSelection *selection,
 void           e_editor_selection_extend       (EEditorSelection *selection,
                                                 gboolean forward,
                                                 EEditorSelectionGranularity granularity);
-
+void           e_editor_selection_scroll_to_caret
+                                               (EEditorSelection *selection);
 G_END_DECLS
 
 #endif /* E_EDITOR_SELECTION_H */


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