diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-04-19 11:02:45 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-04-19 11:02:45 +0200 |
commit | 2367f3543163b6b12bab2d9a1b5bbd4adc98eb41 (patch) | |
tree | f3b4e41b3289f827c5b5f6319f542ed8cf73b7aa | |
parent | 47549b6f4b071b91ce3eaf3ffb5cd4aa9a97eddf (diff) | |
download | cv-2367f3543163b6b12bab2d9a1b5bbd4adc98eb41.tar.gz cv-2367f3543163b6b12bab2d9a1b5bbd4adc98eb41.tar.bz2 cv-2367f3543163b6b12bab2d9a1b5bbd4adc98eb41.zip |
cvg: Cancel keyboard shortcut if another key is pressed in the meantime
-rw-r--r-- | cvg.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -13,6 +13,7 @@ struct cvg { IplImage *output; cairo_surface_t *input_surface; cairo_surface_t *output_surface; + guint last_press; }; static cairo_surface_t * @@ -109,15 +110,20 @@ key_event(GtkWidget *widget, GdkEventKey *event, gpointer userdata) switch (event->keyval) { case GDK_KEY_g: g_signal_emit_by_name(cvg->gauss_btn, "released", NULL); - g_signal_emit_by_name(cvg->gauss_btn, "clicked", NULL); + if (cvg->last_press == event->keyval) + g_signal_emit_by_name(cvg->gauss_btn, "clicked", + NULL); break; case GDK_KEY_o: g_signal_emit_by_name(cvg->open_btn, "released", NULL); - g_signal_emit_by_name(cvg->open_btn, "clicked", NULL); + if (cvg->last_press == event->keyval) + g_signal_emit_by_name(cvg->open_btn, "clicked", + NULL); break; } return FALSE; case GDK_KEY_PRESS: + cvg->last_press = event->keyval; switch (event->keyval) { case GDK_KEY_g: g_signal_emit_by_name(cvg->gauss_btn, "pressed", NULL); |