[tasque] Close task window on ESC keypress.



commit 4601e927dd5eda898db12c85683e8dadb3b8ca1f
Author: Matt Enright <awickedshimmy gmail com>
Date:   Fri May 1 14:27:19 2009 +0200

    Close task window on ESC keypress.
    
    This brings the behavior for Tasque in-line with other GNOME
    applet-style apps like Tomboy or the Hamster applet in allowing them to
    be quickly called, worked in, and then closed again.
    
    The code for the handler is pretty much straight ripped out of Tomboy,
    where I had nothing to do with writing it.
    
    Signed-off-by: Matt Enright <awickedshimmy gmail com>
---
 src/TaskWindow.cs |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/TaskWindow.cs b/src/TaskWindow.cs
index 4d98d8b..91a712e 100644
--- a/src/TaskWindow.cs
+++ b/src/TaskWindow.cs
@@ -186,6 +186,8 @@ namespace Tasque
 						(uint) Gdk.Key.q,
 						Gdk.ModifierType.ControlMask,
 						Gtk.AccelFlags.Visible);
+
+			this.KeyPressEvent += KeyPressed;
 			
 			topHBox.Show ();
 			mainVBox.PackStart (topHBox, false, false, 0);
@@ -1181,6 +1183,18 @@ namespace Tasque
 				TaskWindow.ShowStatus (status);
 			}
 		}
+
+		void KeyPressed (object sender, Gtk.KeyPressEventArgs args)
+		{
+			args.RetVal = true;
+			if (args.Event.Key == Gdk.Key.Escape) {
+				if ((GdkWindow.State & Gdk.WindowState.Maximized) > 0)
+					Unmaximize ();
+				Hide ();
+				return;
+			}
+			args.RetVal = false;
+		}
 		#endregion // Event Handlers
 		
 		#region Private Classes



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]