]> git.tdb.fi Git - pmount-gui.git/commitdiff
Close the mount window if esc is pressed
authorMikko Rasa <tdb@tdb.fi>
Sat, 6 Oct 2012 11:43:55 +0000 (14:43 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 6 Oct 2012 11:43:55 +0000 (14:43 +0300)
main.c

diff --git a/main.c b/main.c
index f6a0b132685d35dd462bc2139878a5ccd9ac0292..b1dcb1ccc645e57f470fdcbbc6a671bad381d133 100644 (file)
--- a/main.c
+++ b/main.c
@@ -8,6 +8,7 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
 
 typedef struct sProperty
 {
@@ -571,6 +572,20 @@ void row_activated(GtkTreeView *list, GtkTreePath *path, GtkTreeViewColumn *colu
        (void)column;
 }
 
+gboolean key_press(GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+       if(event->key.keyval==GDK_KEY_Escape)
+       {
+               gtk_main_quit();
+               return TRUE;
+       }
+
+       (void)widget;
+       (void)user_data;
+
+       return FALSE;
+}
+
 int main(int argc, char **argv)
 {
        GtkWidget *window;
@@ -601,6 +616,7 @@ int main(int argc, char **argv)
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_container_set_border_width(GTK_CONTAINER(window), 5);
        g_signal_connect(window, "destroy", G_CALLBACK(&gtk_main_quit), NULL);
+       g_signal_connect(window, "key-press-event", G_CALLBACK(&key_press), NULL);
 
        viewport = gtk_viewport_new(NULL, NULL);
        gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_IN);