[gnome-control-center] wacom: Make escape key exit



commit 8843ad8fb256f48c3e3293972a0967379bf7eabe
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jan 11 18:39:09 2012 +0000

    wacom: Make escape key exit
    
    And nothing else

 panels/wacom/calibrator/gui_gtk.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/panels/wacom/calibrator/gui_gtk.c b/panels/wacom/calibrator/gui_gtk.c
index 94cf19e..79e6754 100644
--- a/panels/wacom/calibrator/gui_gtk.c
+++ b/panels/wacom/calibrator/gui_gtk.c
@@ -251,15 +251,22 @@ on_button_press_event(GtkWidget      *widget,
 }
 
 static gboolean
-on_key_press_event(GtkWidget   *widget,
-                   GdkEventKey *event,
-                   gpointer     data)
+on_key_release_event(GtkWidget   *widget,
+                     GdkEventKey *event,
+                     gpointer     data)
 {
     struct CalibArea *calib_area = (struct CalibArea*)data;
-    GtkWidget *parent = gtk_widget_get_parent(calib_area->drawing_area);
+    GtkWidget *parent;
+
+    if (event->type != GDK_KEY_RELEASE)
+        return FALSE;
+    if (event->keyval != GDK_KEY_Escape)
+        return FALSE;
+
+    parent = gtk_widget_get_parent(calib_area->drawing_area);
     if (parent)
         gtk_widget_destroy(parent);
-    return TRUE;
+    return FALSE;
 }
 
 static gboolean
@@ -302,13 +309,13 @@ CalibrationArea_(struct Calib *c)
     calib_area->drawing_area = gtk_drawing_area_new();
 
     /* Listen for mouse events */
-    gtk_widget_add_events(calib_area->drawing_area, GDK_KEY_PRESS_MASK | GDK_BUTTON_PRESS_MASK);
+    gtk_widget_add_events(calib_area->drawing_area, GDK_KEY_RELEASE_MASK | GDK_BUTTON_PRESS_MASK);
     gtk_widget_set_can_focus(calib_area->drawing_area, TRUE);
 
     /* Connect callbacks */
     g_signal_connect(calib_area->drawing_area, "draw", G_CALLBACK(draw), calib_area);
     g_signal_connect(calib_area->drawing_area, "button-press-event", G_CALLBACK(on_button_press_event), calib_area);
-    g_signal_connect(calib_area->drawing_area, "key-press-event", G_CALLBACK(on_key_press_event), calib_area);
+    g_signal_connect(calib_area->drawing_area, "key-release-event", G_CALLBACK(on_key_release_event), calib_area);
 
     /* parse geometry string */
     if (geo != NULL)



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