[gthumb] slideshow: handle the key press event in the main window only
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] slideshow: handle the key press event in the main window only
- Date: Sun, 24 Nov 2019 12:33:58 +0000 (UTC)
commit 67b5dd4621c7d77972d3522c92f1f9decd5e53a0
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Nov 17 08:37:32 2019 +0100
slideshow: handle the key press event in the main window only
This removes duplicated code.
extensions/slideshow/gth-slideshow.c | 118 ++++++++++++++---------------------
1 file changed, 48 insertions(+), 70 deletions(-)
---
diff --git a/extensions/slideshow/gth-slideshow.c b/extensions/slideshow/gth-slideshow.c
index 1b6c8b32..4a9d0e35 100644
--- a/extensions/slideshow/gth-slideshow.c
+++ b/extensions/slideshow/gth-slideshow.c
@@ -446,6 +446,49 @@ gth_slideshow_show_cb (GtkWidget *widget,
}
+static gboolean
+_gth_slideshow_key_press_cb (GthSlideshow *self,
+ GdkEventKey *event,
+ gpointer user_data)
+{
+ gboolean handled = TRUE;
+
+ switch (event->keyval) {
+ case GDK_KEY_F5:
+ case GDK_KEY_Escape:
+ case GDK_KEY_q:
+ _gth_slideshow_close (self);
+ break;
+
+ case GDK_KEY_p:
+ _gth_slideshow_toggle_pause (self);
+ break;
+
+ case GDK_KEY_space:
+ case GDK_KEY_Down:
+ case GDK_KEY_Right:
+ case GDK_KEY_Page_Down:
+ if (self->priv->paused)
+ _gth_slideshow_toggle_pause (self);
+ else
+ _gth_slideshow_load_next_image (self);
+ break;
+
+ case GDK_KEY_BackSpace:
+ case GDK_KEY_Up:
+ case GDK_KEY_Left:
+ case GDK_KEY_Page_Up:
+ _gth_slideshow_load_prev_image (self);
+ break;
+
+ default:
+ handled = FALSE;
+ }
+
+ return handled;
+}
+
+
static void
gth_slideshow_init (GthSlideshow *self)
{
@@ -495,6 +538,11 @@ _gth_slideshow_construct (GthSlideshow *self,
self->priv->projector->construct (self);
g_signal_connect (self, "show", G_CALLBACK (gth_slideshow_show_cb), self);
+
+ g_signal_connect (self,
+ "key-press-event",
+ G_CALLBACK (_gth_slideshow_key_press_cb),
+ NULL);
}
@@ -650,41 +698,6 @@ viewer_event_cb (GtkWidget *widget,
break;
}
}
- else if (event->type == GDK_KEY_PRESS) {
- switch (((GdkEventKey *) event)->keyval) {
- case GDK_KEY_F5:
- _gth_slideshow_close (self);
- break;
- }
- }
- else if (event->type == GDK_KEY_RELEASE) {
- switch (((GdkEventKey *) event)->keyval) {
- case GDK_KEY_Escape:
- case GDK_KEY_q:
- _gth_slideshow_close (self);
- break;
- case GDK_KEY_p:
- _gth_slideshow_toggle_pause (self);
- break;
-
- case GDK_KEY_space:
- case GDK_KEY_Down:
- case GDK_KEY_Right:
- case GDK_KEY_Page_Down:
- if (self->priv->paused)
- _gth_slideshow_toggle_pause (self);
- else
- _gth_slideshow_load_next_image (self);
- break;
-
- case GDK_KEY_BackSpace:
- case GDK_KEY_Up:
- case GDK_KEY_Left:
- case GDK_KEY_Page_Up:
- _gth_slideshow_load_prev_image (self);
- break;
- }
- }
}
@@ -1061,41 +1074,6 @@ stage_input_cb (ClutterStage *stage,
break;
}
}
- else if (event->type == CLUTTER_KEY_PRESS) {
- switch (clutter_event_get_key_symbol (event)) {
- case CLUTTER_KEY_F5:
- _gth_slideshow_close (self);
- break;
- }
- }
- else if (event->type == CLUTTER_KEY_RELEASE) {
- switch (clutter_event_get_key_symbol (event)) {
- case CLUTTER_KEY_Escape:
- case CLUTTER_KEY_q:
- _gth_slideshow_close (self);
- break;
- case CLUTTER_KEY_p:
- _gth_slideshow_toggle_pause (self);
- break;
-
- case CLUTTER_KEY_space:
- case CLUTTER_KEY_Down:
- case CLUTTER_KEY_Right:
- case CLUTTER_KEY_Page_Down:
- if (self->priv->paused)
- _gth_slideshow_toggle_pause (self);
- else
- _gth_slideshow_load_next_image (self);
- break;
-
- case CLUTTER_KEY_BackSpace:
- case CLUTTER_KEY_Up:
- case CLUTTER_KEY_Left:
- case CLUTTER_KEY_Page_Up:
- _gth_slideshow_load_prev_image (self);
- break;
- }
- }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]