[gthumb] activate commands on key release with the exception of F5



commit 754811e6c23871dec96e7d3871d7ea999cdcdf2e
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Sep 13 16:06:13 2010 +0200

    activate commands on key release with the exception of F5
    
    F5 cannot be activated on key release because it's used to
    activate the slideshow as well, and the release key event
    relative to the slideshow activation is captured by the
    fullscreen window that quits soon after.
    
    The other commands are activated on key release to avoid
    double activation of a command on long key presses.

 extensions/slideshow/gth-slideshow.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/extensions/slideshow/gth-slideshow.c b/extensions/slideshow/gth-slideshow.c
index 1488cea..8b88921 100644
--- a/extensions/slideshow/gth-slideshow.c
+++ b/extensions/slideshow/gth-slideshow.c
@@ -615,12 +615,17 @@ viewer_event_cb (GtkWidget    *widget,
 	}
 	else if (event->type == GDK_KEY_PRESS) {
 		switch (((GdkEventKey *) event)->keyval) {
-		case GDK_Escape:
 		case GDK_F5:
+			_gth_slideshow_close (self);
+			break;
+		}
+	}
+	else if (event->type == GDK_KEY_RELEASE) {
+		switch (((GdkEventKey *) event)->keyval) {
+		case GDK_Escape:
 		case GDK_q:
 			_gth_slideshow_close (self);
 			break;
-
 		case GDK_p:
 			_gth_slideshow_toggle_pause (self);
 			break;
@@ -687,6 +692,7 @@ default_projector_construct (GthSlideshow *self)
 	g_signal_connect (self->priv->viewer, "button-press-event", G_CALLBACK (viewer_event_cb), self);
 	g_signal_connect (self->priv->viewer, "motion-notify-event", G_CALLBACK (viewer_event_cb), self);
 	g_signal_connect (self->priv->viewer, "key-press-event", G_CALLBACK (viewer_event_cb), self);
+	g_signal_connect (self->priv->viewer, "key-release-event", G_CALLBACK (viewer_event_cb), self);
 
 	gtk_widget_show (self->priv->viewer);
 	gtk_container_add (GTK_CONTAINER (self), self->priv->viewer);
@@ -995,12 +1001,17 @@ stage_input_cb (ClutterStage *stage,
 	}
 	else if (event->type == CLUTTER_KEY_PRESS) {
 		switch (clutter_event_get_key_symbol (event)) {
-		case CLUTTER_Escape:
 		case CLUTTER_F5:
+			_gth_slideshow_close (self);
+			break;
+		}
+	}
+	else if (event->type == CLUTTER_KEY_RELEASE) {
+		switch (clutter_event_get_key_symbol (event)) {
+		case CLUTTER_Escape:
 		case CLUTTER_q:
 			_gth_slideshow_close (self);
 			break;
-
 		case CLUTTER_p:
 			_gth_slideshow_toggle_pause (self);
 			break;
@@ -1109,6 +1120,7 @@ clutter_projector_construct (GthSlideshow *self)
 	g_signal_connect (self->stage, "button-press-event", G_CALLBACK (stage_input_cb), self);
 	g_signal_connect (self->stage, "motion-event", G_CALLBACK (stage_input_cb), self);
 	g_signal_connect (self->stage, "key-press-event", G_CALLBACK (stage_input_cb), self);
+	g_signal_connect (self->stage, "key-release-event", G_CALLBACK (stage_input_cb), self);
 
 	self->priv->image1 = clutter_texture_new ();
 	clutter_actor_hide (self->priv->image1);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]