[Xfce4-commits] [apps/xfce4-taskmanager] 03/03: Make Escape key close the main window

noreply at xfce.org noreply at xfce.org
Mon Dec 1 10:31:40 CET 2014


This is an automated email from the git hooks/post-receive script.

landry pushed a commit to branch master
in repository apps/xfce4-taskmanager.

commit 0b1014f8f941c0a34d42050284b509aaaee4ccca
Author: Harald Judt <h.judt at gmx.at>
Date:   Sun Nov 30 19:20:07 2014 +0100

    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 46b9c58..a448650 100644
--- a/src/process-window.c
+++ b/src/process-window.c
@@ -18,6 +18,7 @@
 #include <glib-object.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
 
 #include "settings.h"
 #include "process-window.h"
@@ -59,6 +60,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);
@@ -125,6 +127,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);
@@ -241,6 +244,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)
 {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list