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 768448 - Make Esc close annotation window
Make Esc close annotation window
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: pdf annotations
git master
Other Linux
: Normal enhancement
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-07-05 14:24 UTC by Christian Gogolin
Modified: 2016-07-16 09:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch to make esc close the annotation window (1.24 KB, patch)
2016-07-05 14:24 UTC, Christian Gogolin
reviewed Details | Review

Description Christian Gogolin 2016-07-05 14:24:31 UTC
Created attachment 330908 [details] [review]
patch to make esc close the annotation window

I find it quite annoying that I have to use the mouse to close the annotation window after typing the text for a newly added text annotation.

A natural key binding to close the annotation window would be the Esc key.

I am attaching a small patch against the current git master that closes the annotation window (in the same way as pressing the x button of that window does it) when Esc is pressed while editing in the annotation window.
Comment 1 Carlos Garcia Campos 2016-07-16 08:50:56 UTC
Review of attachment 330908 [details] [review]:

Thanks for the patch, I've addressed my own comments and pushed the patch to git master.

::: libview/ev-annotation-window.c
@@ +303,3 @@
+	EvAnnotationWindow *window = EV_ANNOTATION_WINDOW (widget);
+
+	if (event->type == GDK_KEY_PRESS && event->keyval == GDK_KEY_Escape) {

You are connecting to key-press-event signals, the event type should only be GDK_KEY_PRESS, so we don't need the extra check.

@@ +304,3 @@
+
+	if (event->type == GDK_KEY_PRESS && event->keyval == GDK_KEY_Escape) {
+        ev_annotation_window_close (window);

This is not correctly indented.

@@ +348,3 @@
 	gtk_widget_show (header);
 
+	gtk_widget_add_events (GTK_WIDGET (window), GDK_KEY_PRESS_MASK);

I'm pretty sure GtkWindow already adds the key press to the event mask on realize.

@@ +351,3 @@
+	g_signal_connect_swapped (window, "key-press-event",
+				  G_CALLBACK (ev_annotation_window_key_press_event),
+			          window);

Instead of connecting to the signal we could just add our implementation of key_press_event vfunc.
Comment 2 Christian Gogolin 2016-07-16 09:43:02 UTC
Cool. Thanks!