diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2013-01-30 11:33:46 +0100 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2013-01-30 16:59:53 +0100 |
commit | 1cf9f6df4a0fd9a478b31a69c4d976d4faa3e136 (patch) | |
tree | e4c94654cf99985a29fc7439c2c6ed79c3984ca8 | |
parent | 512e39329ca55705ea0b27235139b97baa66f016 (diff) |
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.
-rw-r--r-- | src/searchbar.vala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/searchbar.vala b/src/searchbar.vala index c54ed1f..32e257a 100644 --- a/src/searchbar.vala +++ b/src/searchbar.vala @@ -6,12 +6,13 @@ private class Boxes.Searchbar: Boxes.UI { 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); @@ -26,6 +27,14 @@ private class Boxes.Searchbar: Boxes.UI { }); } + public void disable_key_handler () { + GLib.SignalHandler.block (App.app.window, key_handler_id); + } + + public void enable_key_handler () { + GLib.SignalHandler.unblock (App.app.window, key_handler_id); + } + private bool refilter () { App.app.filter.text = text; App.app.view.refilter (); |