From 6df291b61fe1f05c2111e7aeef98ac9a95583c25 Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Sun, 30 Nov 2014 19:20:07 +0100 Subject: Make Escape key close the main window This patch makes pressing the Escape key have the same effect as clicking the close window button. --- src/process-window.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/process-window.c b/src/process-window.c index 503f5f1..1a7a2c1 100644 --- a/src/process-window.c +++ b/src/process-window.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "settings.h" #include "process-window.h" @@ -58,6 +59,7 @@ static void xtm_process_window_hide (GtkWidget *widget); static void emit_destroy_signal (XtmProcessWindow *window); static gboolean emit_delete_event_signal (XtmProcessWindow *window, GdkEvent *event); +static gboolean xtm_process_window_key_pressed (XtmProcessWindow *window, GdkEventKey *event); static void toolbar_update_style (XtmProcessWindow *window); static void monitor_update_step_size (XtmProcessWindow *window); static void monitor_update_paint_box (XtmProcessWindow *window); @@ -96,6 +98,7 @@ xtm_process_window_init (XtmProcessWindow *window) gtk_window_resize (GTK_WINDOW (window->window), width, height); g_signal_connect_swapped (window->window, "destroy", G_CALLBACK (emit_destroy_signal), window); g_signal_connect_swapped (window->window, "delete-event", G_CALLBACK (emit_delete_event_signal), window); + g_signal_connect (window->window, "key-press-event", G_CALLBACK(xtm_process_window_key_pressed), window); window->toolbar = GTK_WIDGET (gtk_builder_get_object (window->builder, "process-toolbar")); g_signal_connect_swapped (window->settings, "notify::toolbar-style", G_CALLBACK (toolbar_update_style), window); @@ -206,6 +209,19 @@ emit_delete_event_signal (XtmProcessWindow *window, GdkEvent *event) return ret; } +static gboolean +xtm_process_window_key_pressed (XtmProcessWindow *window, GdkEventKey *event) +{ + gboolean ret = FALSE; + + if (event->keyval == GDK_KEY_Escape) { + emit_delete_event_signal (window, (GdkEvent*) event); + ret = TRUE; + } + + return ret; +} + static void toolbar_update_style (XtmProcessWindow *window) { -- 2.1.3