GNOME Bugzilla – Bug 768448
Make Esc close annotation window
Last modified: 2016-07-16 09:43:02 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.
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.
Cool. Thanks!