[libhandy] preferences-window: Handle Esc key
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy] preferences-window: Handle Esc key
- Date: Mon, 24 Aug 2020 16:05:52 +0000 (UTC)
commit ff18a3b6e1a604b2c1cd13912abb14211fe0cd43
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Aug 14 17:47:19 2020 +0500
preferences-window: Handle Esc key
We already can cancel search with Esc, allow also to close the window or
close the current subpage.
Closing subpage is only allowed when can-swipe-back is TRUE, to prevent
it from closing when it soulnd't be allowed.
Fixes https://gitlab.gnome.org/GNOME/libhandy/-/issues/321
Signed-off-by: Alexander Mikhaylenko <alexm gnome org>
src/hdy-preferences-window.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/hdy-preferences-window.c b/src/hdy-preferences-window.c
index d89fb822..bd8799db 100644
--- a/src/hdy-preferences-window.c
+++ b/src/hdy-preferences-window.c
@@ -212,9 +212,6 @@ key_press_event_cb (GtkWidget *sender,
GdkKeymap *keymap;
GdkEventKey *key_event = (GdkEventKey *) event;
- if (priv->subpage)
- return GDK_EVENT_PROPAGATE;
-
gdk_event_get_state (event, &state);
keymap = gdk_keymap_get_for_display (gtk_widget_get_display (sender));
@@ -225,6 +222,17 @@ key_press_event_cb (GtkWidget *sender,
key_event->group,
&keyval, NULL, NULL, NULL);
+ if (priv->subpage) {
+ if (keyval == GDK_KEY_Escape &&
+ hdy_preferences_window_get_can_swipe_back (self)) {
+ hdy_preferences_window_close_subpage (self);
+
+ return GDK_EVENT_STOP;
+ }
+
+ return GDK_EVENT_PROPAGATE;
+ }
+
if (priv->search_enabled &&
(keyval == GDK_KEY_f || keyval == GDK_KEY_F) &&
(state & default_modifiers) == GDK_CONTROL_MASK) {
@@ -240,6 +248,12 @@ key_press_event_cb (GtkWidget *sender,
return GDK_EVENT_STOP;
}
+ if (keyval == GDK_KEY_Escape) {
+ gtk_window_close (GTK_WINDOW (self));
+
+ return GDK_EVENT_STOP;
+ }
+
return GDK_EVENT_PROPAGATE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]