diff options
author | Antia Puentes <[email protected]> | 2013-07-19 14:43:18 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2017-09-06 18:25:34 +0200 |
commit | 0f347181c81c0d831af9494c984ac3831390cbc8 (patch) | |
tree | af2397e4e92d949e0bf29d76a3786325fdcb41de /libview/ev-view.c | |
parent | 205542523f2927972757996f50e0ade2b71fa3ae (diff) | |
download | atril-0f347181c81c0d831af9494c984ac3831390cbc8.tar.bz2 atril-0f347181c81c0d831af9494c984ac3831390cbc8.tar.xz |
libview: Rework ev_view_accessible_get_selection
Actually return the text and offset range of the selected text in the
current page.
https://bugzilla.gnome.org/show_bug.cgi?id=704335
origin commit:
https://git.gnome.org/browse/evince/commit/?h=gnome-3-10&id=a178d26
Diffstat (limited to 'libview/ev-view.c')
-rw-r--r-- | libview/ev-view.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/libview/ev-view.c b/libview/ev-view.c index 9a81ce46..2e277cff 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -4233,11 +4233,11 @@ start_selection_for_event (EvView *view, &(view->selection_info.start)); } -static gboolean -position_caret_cursor_at_doc_point (EvView *view, - gint page, - gdouble doc_x, - gdouble doc_y) +gint +_ev_view_get_caret_cursor_offset_at_doc_point (EvView *view, + gint page, + gdouble doc_x, + gdouble doc_y) { EvRectangle *areas = NULL; guint n_areas = 0; @@ -4249,7 +4249,7 @@ position_caret_cursor_at_doc_point (EvView *view, ev_page_cache_get_text_layout (view->page_cache, page, &areas, &n_areas); if (!areas) - return FALSE; + return -1; i = 0; while (i < n_areas && offset == -1) { @@ -4305,11 +4305,26 @@ position_caret_cursor_at_doc_point (EvView *view, } if (last_line_offset == -1) - return FALSE; + return -1; if (offset == -1) offset = last_line_offset; + return offset; +} + +static gboolean +position_caret_cursor_at_doc_point (EvView *view, + gint page, + gdouble doc_x, + gdouble doc_y) +{ + gint offset; + + offset = _ev_view_get_caret_cursor_offset_at_doc_point (view, page, doc_x, doc_y); + if (offset == -1) + return FALSE; + if (view->cursor_offset != offset || view->cursor_page != page) { view->cursor_offset = offset; view->cursor_page = page; |