[banshee] Muinshee: Make the Esc key close the dialog if there is no search text



commit 02e070d840e40dba76f6fb32bc7cf9f37fc16ff9
Author: Adam Lofts <Adam Lofts gmail com>
Date:   Thu Oct 20 17:04:55 2011 +0100

    Muinshee: Make the Esc key close the dialog if there is no search text
    
    Override the KeyPress handler of the search entry to have the Esc key
    press bubble up if the search entry is empty. In this case the dialog
    will be closed. Fixes bgo#611333.
    
    The behavior now matches common search entries: if the entry contains
    text, the first hit on Esc clear the text, the second closes the dialog.
    
    Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>

 src/Clients/Muinshee/Muinshee/BaseDialog.cs |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/Clients/Muinshee/Muinshee/BaseDialog.cs b/src/Clients/Muinshee/Muinshee/BaseDialog.cs
index d879b77..df11370 100644
--- a/src/Clients/Muinshee/Muinshee/BaseDialog.cs
+++ b/src/Clients/Muinshee/Muinshee/BaseDialog.cs
@@ -48,6 +48,19 @@ using Banshee.MediaEngine;
 
 namespace Muinshee
 {
+    internal class MuinsheeSearchEntry : SearchEntry
+    {
+        protected override bool OnKeyPressEvent (Gdk.EventKey evnt)
+        {
+            // The default behavior is to have Esc clear the search entry
+            // Close the dialog if there is already nothing in the search entry
+            if (evnt.Key == Gdk.Key.Escape && String.IsNullOrEmpty (Query)) {
+                return false;
+            }
+            return base.OnKeyPressEvent (evnt);
+        }
+    }
+
     public abstract class BaseDialog : BansheeDialog
     {
         private SearchEntry search_entry;
@@ -65,7 +78,7 @@ namespace Muinshee
             Label search_label = new Label ("_Search:");
             filter_box.PackStart (search_label, false, false, 0);
 
-            search_entry = new SearchEntry ();
+            search_entry = new MuinsheeSearchEntry ();
             search_entry.Show ();
             search_entry.Changed += OnFilterChanged;
             search_entry.Ready = true;



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