[gnome-photos/wip/rishi/misc-fixes: 5/24] main-window: Cancel editing when pressing escape
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/misc-fixes: 5/24] main-window: Cancel editing when pressing escape
- Date: Tue, 15 Dec 2015 11:47:59 +0000 (UTC)
commit 026e154b17b22beec443196a6a5114df63233b9a
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Dec 14 13:31:34 2015 +0100
main-window: Cancel editing when pressing escape
src/photos-main-window.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/src/photos-main-window.c b/src/photos-main-window.c
index 76b8343..4bd077d 100644
--- a/src/photos-main-window.c
+++ b/src/photos-main-window.c
@@ -41,6 +41,7 @@
struct _PhotosMainWindowPrivate
{
+ GAction *edit_cancel;
GAction *load_next;
GAction *load_previous;
GtkWidget *embed;
@@ -213,6 +214,21 @@ photos_main_window_handle_back_key (PhotosMainWindow *self, GdkEventKey *event)
static gboolean
+photos_main_window_handle_key_edit (PhotosMainWindow *self, GdkEventKey *event)
+{
+ gboolean handled = FALSE;
+
+ if (event->keyval == GDK_KEY_Escape)
+ {
+ g_action_activate (self->priv->edit_cancel, NULL);
+ handled = TRUE;
+ }
+
+ return handled;
+}
+
+
+static gboolean
photos_main_window_handle_key_overview (PhotosMainWindow *self, GdkEventKey *event)
{
PhotosMainWindowPrivate *priv = self->priv;
@@ -285,10 +301,13 @@ photos_main_window_key_press_event (GtkWidget *widget, GdkEventKey *event)
switch (mode)
{
case PHOTOS_WINDOW_MODE_NONE:
- case PHOTOS_WINDOW_MODE_EDIT:
handled = GDK_EVENT_PROPAGATE;
break;
+ case PHOTOS_WINDOW_MODE_EDIT:
+ handled = photos_main_window_handle_key_edit (self, event);
+ break;
+
case PHOTOS_WINDOW_MODE_PREVIEW:
handled = photos_main_window_handle_key_preview (self, event);
break;
@@ -362,6 +381,7 @@ photos_main_window_constructed (GObject *object)
app = g_application_get_default ();
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (self));
+ priv->edit_cancel = g_action_map_lookup_action (G_ACTION_MAP (app), "edit-cancel");
priv->load_next = g_action_map_lookup_action (G_ACTION_MAP (app), "load-next");
priv->load_previous = g_action_map_lookup_action (G_ACTION_MAP (app), "load-previous");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]