[gnome-tweak-tool] AppChooser: Add an accelerator to toggle searching



commit c60d424256af19f34facedbf6bb2798698e6770e
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Tue Apr 28 14:24:01 2015 +0100

    AppChooser: Add an accelerator to toggle searching
    
    Use Control-f to toggle the state of the search-bar
    
    https://bugzilla.gnome.org/show_bug.cgi?id=747983

 gtweak/tweaks/tweak_group_startup.py |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/gtweak/tweaks/tweak_group_startup.py b/gtweak/tweaks/tweak_group_startup.py
index 3c6840a..ff2551c 100644
--- a/gtweak/tweaks/tweak_group_startup.py
+++ b/gtweak/tweaks/tweak_group_startup.py
@@ -46,6 +46,8 @@ class _AppChooser(Gtk.Dialog):
         self.searchbar = Gtk.SearchBar()
         self.searchbar.add(self.entry)
         self.searchbar.props.hexpand = True
+        # Translators: This is the accelerator for opening the AppChooser search-bar
+        self._search_key, self._search_mods = Gtk.accelerator_parse(_("<primary>f"))
 
         lb = Gtk.ListBox()
         lb.props.margin = 5
@@ -168,6 +170,10 @@ class _AppChooser(Gtk.Dialog):
             self.set_response_sensitive(Gtk.ResponseType.OK, False)
 
     def _on_key_press(self, widget, event):
+      mods = event.state & Gtk.accelerator_get_default_mod_mask()
+      if event.keyval == self._search_key and mods == self._search_mods:
+          self.searchbar.set_search_mode(not self.searchbar.get_search_mode())
+          return True
       keyname = Gdk.keyval_name(event.keyval)
       if keyname == 'Escape':
           if self.searchbar.get_search_mode():


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