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 701732 - Implement AtkText signals for caret navigation within document content
Implement AtkText signals for caret navigation within document content
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: PDF
git master
Other Linux
: Normal normal
: ---
Assigned To: Joanmarie Diggs (IRC: joanie)
Evince Maintainers
Depends on: 638905 702078
Blocks: 677348
 
 
Reported: 2013-06-06 13:26 UTC by Joanmarie Diggs (IRC: joanie)
Modified: 2013-07-08 11:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch: emit text-caret-moved signal (622 bytes, patch)
2013-06-10 11:21 UTC, Joanmarie Diggs (IRC: joanie)
needs-work Details | Review
proposed patch (6.22 KB, patch)
2013-06-11 14:18 UTC, Joanmarie Diggs (IRC: joanie)
needs-work Details | Review
Emit the ATK text-caret-moved signal (1.26 KB, patch)
2013-07-03 16:11 UTC, Antía Puentes
none Details | Review
Emit the ATK text-caret-moved signal (1.33 KB, patch)
2013-07-03 17:34 UTC, Antía Puentes
needs-work Details | Review
Emit AtkText text-caret-moved and text-selection changed signals (1.63 KB, patch)
2013-07-04 15:54 UTC, Antía Puentes
committed Details | Review

Description Joanmarie Diggs (IRC: joanie) 2013-06-06 13:26:40 UTC
Once caret navigation has been implemented (see bug 638905), the following two AtkText signals/events should be implemented:

* atk_text-caret-moved
* atk_text-selection-changed
Comment 1 Joanmarie Diggs (IRC: joanie) 2013-06-06 13:28:09 UTC
Apologies for the c&p error. The above are, of course, text-caret-moved and text-selection-changed respectively.
Comment 2 Joanmarie Diggs (IRC: joanie) 2013-06-10 11:21:17 UTC
Created attachment 246394 [details] [review]
proposed patch: emit text-caret-moved signal
Comment 3 Carlos Garcia Campos 2013-06-10 16:10:21 UTC
Review of attachment 246394 [details] [review]:

Thanks.

::: libview/ev-view.c
@@ +4783,3 @@
 	}
 
+	g_signal_emit_by_name (ATK_TEXT (view->accessible), "text_caret_moved", view->cursor_offset);

This would be emitted even if the caret hasn't moved, for example if you press HOME key and you are already at line start. Also, I think ATK signals should be emitted by EvViewAccessible. We could add a readable property to EvView, cursor-position for example, and EvView accesible could connect to notify signal. I think it could be useful for other EvView users as well. Maybe we can make all caret functions return the new offset (or -1 in case of error) instead of returning TRUE/FALSE, and have a function set the new offset that checks wheter it has actually changed and emits the notify signal in such case. It will be useful also when the offsert can be changed by clicking, for example.
Comment 4 Joanmarie Diggs (IRC: joanie) 2013-06-11 14:18:31 UTC
Created attachment 246529 [details] [review]
proposed patch

(In reply to comment #3)
> Review of attachment 246394 [details] [review]:

Thanks for the review!
 
> This would be emitted even if the caret hasn't moved, for example if you press
> HOME key and you are already at line start.

Ugh. Fixed.

> Also, I think ATK signals should be emitted by EvViewAccessible.

Done.

> We could add a readable property to EvView,
> cursor-position for example, 

EvView has cursor-offset already. What would cursor-position contain? Because I didn't understand this, I've not done it in this new patch.

> and EvView accesible could connect to notify signal. 

Related to my previous comment, because I didn't understand the cursor-position, this new patch does emit a signal, but it's a new caret-moved signal rather than a notify signal on the proposed property.

> make all caret functions return the new offset (or -1 in case of error) instead
> of returning TRUE/FALSE,

Not done yet, as I'm curious as to what you think about my new patch.

> and have a function set the new offset that checks
> wheter it has actually changed and emits the notify signal in such case.

Done.

> will be useful also when the offsert can be changed by clicking, for example.

Verified it works when clicking.
Comment 5 Carlos Garcia Campos 2013-06-19 11:38:28 UTC
Review of attachment 246529 [details] [review]:

Now that we keep both the page and cursor offset, it makes more sense to use a signal instead of a property, because the cursor might be moved to the same offset of a different page, for example.

::: libview/ev-view-accessible.c
@@ +904,3 @@
+				 EvViewAccessible *accessible)
+{
+	g_signal_emit_by_name (ATK_TEXT (accessible), "text_caret_moved", view->cursor_offset);

I think the use of underscore for signal names is deprecated, use text-caret-moved instead. I think the current offset should be received as paramater. I wonder what happens with the current page, though.

::: libview/ev-view.c
@@ +4372,3 @@
+		return FALSE;
+
+	view->cursor_offset = new_offset;

This has changed a bit, cursor is positioned differently when using keybindins or by clicking. In both cases we already check whether the cursor has actually changed before queuing a redraw, so we could just emit the signal directly there instead of using a helper function to reposition the cursor.

@@ +5480,3 @@
+	  	         G_TYPE_FROM_CLASS (object_class),
+		         G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+		         G_STRUCT_OFFSET (EvViewClass, layers_changed),

layers_changed? :-) Since this is just a notification signal we can use NULL here and not add a vmethod to the class struct. We should also remove the G_SIGNAL_ACTION.

@@ +5484,3 @@
+		         g_cclosure_marshal_VOID__VOID,
+		         G_TYPE_NONE, 0,
+			 G_TYPE_NONE);

I wonder if it would be useful to pass the cursor page and offset as parameters.
Comment 6 Antía Puentes 2013-07-03 16:11:58 UTC
Created attachment 248328 [details] [review]
Emit the ATK text-caret-moved signal
Comment 7 Antía Puentes 2013-07-03 17:34:43 UTC
Created attachment 248337 [details] [review]
Emit the ATK text-caret-moved signal

Updating patch.
Comment 8 Carlos Garcia Campos 2013-07-03 17:42:21 UTC
Review of attachment 248337 [details] [review]:

::: libview/ev-view-accessible.c
@@ +915,3 @@
+				 EvViewAccessible *accessible)
+{
+	ev_view_accessible_set_caret_offset (ATK_TEXT (accessible), offset);

Do we really want to set the caret offset here?

@@ +916,3 @@
+{
+	ev_view_accessible_set_caret_offset (ATK_TEXT (accessible), offset);
+	g_signal_emit_by_name (ATK_TEXT (accessible), "text_caret_moved", offset);

I think the use of underscore for signal names is deprecated, use text-caret-moved instead. g_signal_emit_by_name receives a gpointer so you don't need to cast to AtkText here.

@@ +929,3 @@
 	atk_object_initialize (accessible, widget);
 
+	g_signal_connect (EV_VIEW (widget), "cursor-moved",

Same here, g_signal_connect expects a gpointer.
Comment 9 Antía Puentes 2013-07-04 15:54:29 UTC
Created attachment 248399 [details] [review]
Emit AtkText text-caret-moved and text-selection changed signals
Comment 10 Carlos Garcia Campos 2013-07-08 11:21:17 UTC
Comment on attachment 248399 [details] [review]
Emit AtkText text-caret-moved and text-selection changed signals

Pushed to git master.