[gnome-boxes] searchbar: Allow to disable key press snooping



commit e33f5d63c6d558c8b6e1aac80660620e0097ede1
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Wed Jan 30 11:33:46 2013 +0100

    searchbar: Allow to disable key press snooping
    
    The searchbar grabs all key presses in the collection view and use
    them to filter the displayed VMs. However, if we need keyboard input
    in another widget, the searchbar will prevent it. This commit
    adds methods to enable/disable this keyboard snooping when needed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=681747

 src/searchbar.vala |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/searchbar.vala b/src/searchbar.vala
index c54ed1f..7f4b15d 100644
--- a/src/searchbar.vala
+++ b/src/searchbar.vala
@@ -2,16 +2,25 @@
 
 private class Boxes.Searchbar: Boxes.UI {
     public override Clutter.Actor actor { get { return gtk_actor; } }
+    public bool enable_key_handler {
+        set {
+            if (value)
+                GLib.SignalHandler.unblock (App.app.window, key_handler_id);
+            else
+                GLib.SignalHandler.block (App.app.window, key_handler_id);
+        }
+    }
     private GtkClutter.Actor gtk_actor;
     private Gd.TaggedEntry entry;
 
     private uint refilter_delay_id;
+    private ulong key_handler_id;
     static const uint refilter_delay = 200; // in ms
 
     public Searchbar () {
         setup_searchbar ();
 
-        App.app.window.key_press_event.connect (on_app_key_pressed);
+        key_handler_id = App.app.window.key_press_event.connect (on_app_key_pressed);
         entry.notify["text"].connect ( () => {
                 if (refilter_delay_id != 0)
                     Source.remove (refilter_delay_id);



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