After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 704335 - ev_view_accessible_get_selection should work as expected
ev_view_accessible_get_selection should work as expected
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
: 701790 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-07-16 16:19 UTC by Antía Puentes
Modified: 2014-06-10 16:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Return the text and offset range of the text selected in the current page (5.88 KB, patch)
2013-07-16 16:48 UTC, Antía Puentes
needs-work Details | Review
Return the text and offset range of the text selected in the current page (5.85 KB, patch)
2013-07-18 13:25 UTC, Antía Puentes
committed Details | Review

Description Antía Puentes 2013-07-16 16:19:49 UTC
The implementation of the atk_text_get_selection is broken in EvViewAccessible. It should return the selected text and the start and end positions of the selected region.
Comment 1 Antía Puentes 2013-07-16 16:48:04 UTC
Created attachment 249288 [details] [review]
Return the text and offset range of the text selected in the current page

The implementation of atk_text_get_selection returns the start and end offsets of the selected region. Evince works with offsets per page, so we would need to work with global offsets to avoid errors when the selection covers several pages.

As a first approach, this patch returns the text and offsets of the text selected in the current page, if any.
Comment 2 Carlos Garcia Campos 2013-07-18 09:19:26 UTC
Review of attachment 249288 [details] [review]:

Looks good, there are just a few minor details. Thanks.

::: libview/ev-view-accessible.c
@@ +659,3 @@
+
+	*start_offset = start;
+	*end_offset   = end;

Please, don't line up the =

@@ +692,3 @@
 		return NULL;
 
+	ev_document_doc_mutex_lock ();

Limit the mutex to the ev_selection_get_selected_text call, if there aren't selections in the current page we would be locking for nothing.

@@ +696,1 @@
+	for (l = view->selection_info.selections; l != NULL && !current_page; l = l->next) {

Break the loop when you find the selections instead of using a boolean local variable.

@@ +696,3 @@
+	for (l = view->selection_info.selections; l != NULL && !current_page; l = l->next) {
+		EvViewSelection *selection = (EvViewSelection *)l->data;
+		EvPage *page;

This is only used in the if (get_selection_bound, you can move it there

@@ +704,3 @@
+		current_page = TRUE;
+		if (get_selection_bounds (view, selection, &start, &end) && start != end) {
+			page = ev_document_get_page (view->document, selection->page);

This returns a new EvPage, that you are leaking. Call g_object_unref after ev_selection_get_selected_text

@@ +711,3 @@
+
+			*start_pos = start;
+			*end_pos   = end;

Please, don't line up the =

::: libview/ev-view.c
@@ +4298,3 @@
+{
+	gint offset =
+		_ev_view_get_caret_cursor_offset_at_doc_point (view, page, doc_x, doc_y);

Use two different lines here better.

gint offset;

offset = _ev_view_get_caret_cursor_offset_at_doc_point (view, page, doc_x, doc_y);
Comment 3 Antía Puentes 2013-07-18 13:25:24 UTC
Created attachment 249502 [details] [review]
Return the text and offset range of the text selected in the current page

Patch updated according to comments in comment 2
Comment 4 Carlos Garcia Campos 2013-07-19 12:48:50 UTC
Comment on attachment 249502 [details] [review]
Return the text and offset range of the text selected in the current page

Pushed, thanks!
Comment 5 Joanmarie Diggs (IRC: joanie) 2014-06-10 16:02:19 UTC
*** Bug 701790 has been marked as a duplicate of this bug. ***