From 1a6585f182d37f809a6768ce3a0d68ffcb9112e1 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 6 Oct 2012 14:43:55 +0300 Subject: [PATCH] Close the mount window if esc is pressed --- main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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); -- 2.45.2