From: Mikko Rasa Date: Sat, 6 Oct 2012 11:43:55 +0000 (+0300) Subject: Close the mount window if esc is pressed X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=1a6585f182d37f809a6768ce3a0d68ffcb9112e1;p=pmount-gui.git Close the mount window if esc is pressed --- diff --git a/main.c b/main.c index f6a0b13..b1dcb1c 100644 --- a/main.c +++ b/main.c @@ -8,6 +8,7 @@ #include #include #include +#include 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(>k_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);