@@ -416,7 +416,47 @@ def set_values(self):
416416 selection .connect ('changed' , self .on_layout_item_selection_changed )
417417
418418 ## Keybindings tab
419- widget = guiget ('keybindingtreeview' )
419+ widget = guiget ('keybindingtreeview' )
420+ kbsearch = guiget ('keybindingsearchentry' )
421+ self .keybind_filter_str = ""
422+
423+ #lets hide whatever we can in nested scope
424+ def filter_visible (model , treeiter , data ):
425+ act = model [treeiter ][0 ]
426+ keys = data [act ] if act in data else ""
427+ desc = model [treeiter ][1 ]
428+ kval = model [treeiter ][2 ]
429+ mask = model [treeiter ][3 ]
430+ #so user can search for disabled keys also
431+ if not (len (keys ) and kval and mask ):
432+ act = "Disabled"
433+
434+ self .keybind_filter_str = self .keybind_filter_str .lower ()
435+ searchtxt = (act + " " + keys + " " + desc ).lower ()
436+ pos = searchtxt .find (self .keybind_filter_str )
437+ if (pos >= 0 ):
438+ dbg ("filter find:%s in search text: %s" %
439+ (self .keybind_filter_str , searchtxt ))
440+ return True
441+
442+ return False
443+
444+ def on_search (widget , text ):
445+ MAX_SEARCH_LEN = 10
446+ self .keybind_filter_str = widget .get_text ()
447+ ln = len (self .keybind_filter_str )
448+ #its a small list & we are eager for quick search, but limit
449+ if (ln >= 2 and ln < MAX_SEARCH_LEN ):
450+ dbg ("filter search str: %s" % self .keybind_filter_str )
451+ self .treemodelfilter .refilter ()
452+
453+ def on_search_refilter (widget ):
454+ dbg ("refilter" )
455+ self .treemodelfilter .refilter ()
456+
457+ kbsearch .connect ('key-press-event' , on_search )
458+ kbsearch .connect ('backspace' , on_search_refilter )
459+
420460 liststore = widget .get_model ()
421461 liststore .set_sort_column_id (0 , Gtk .SortType .ASCENDING )
422462 keybindings = self .config ['keybindings' ]
@@ -432,6 +472,10 @@ def set_values(self):
432472 liststore .append ([keybinding , self .keybindingnames [keybinding ],
433473 keyval , mask ])
434474
475+ self .treemodelfilter = liststore .filter_new ()
476+ self .treemodelfilter .set_visible_func (filter_visible , keybindings )
477+ widget .set_model (self .treemodelfilter )
478+
435479 ## Plugins tab
436480 # Populate the plugin list
437481 widget = guiget ('pluginlist' )
@@ -1731,6 +1775,11 @@ def on_bold_text_is_bright_checkbutton_toggled(self, widget):
17311775 self .config .save ()
17321776
17331777 def on_cellrenderer_accel_edited (self , liststore , path , key , mods , _code ):
1778+ inpath = path #save for debugging
1779+ trpath = Gtk .TreePath .new_from_string (inpath )
1780+ path = str (self .treemodelfilter .convert_path_to_child_path (trpath ))
1781+ dbg ("convert path with filter from: %s to: %s" %
1782+ (inpath , path ))
17341783 """Handle an edited keybinding"""
17351784 # Ignore `Gdk.KEY_Tab` so that `Shift+Tab` is displayed as `Shift+Tab`
17361785 # in `Preferences>Keybindings` and NOT `Left Tab` (see `Gdk.KEY_ISO_Left_Tab`).
@@ -1801,6 +1850,12 @@ def on_cellrenderer_accel_edited(self, liststore, path, key, mods, _code):
18011850 self .config .save ()
18021851
18031852 def on_cellrenderer_accel_cleared (self , liststore , path ):
1853+ inpath = path #save for debugging
1854+ trpath = Gtk .TreePath .new_from_string (inpath )
1855+ path = str (self .treemodelfilter .convert_path_to_child_path (trpath ))
1856+ dbg ("convert path with filter from: %s to: %s" %
1857+ (inpath , path ))
1858+
18041859 """Handle the clearing of a keybinding accelerator"""
18051860 celliter = liststore .get_iter_from_string (path )
18061861 liststore .set (celliter , 2 , 0 , 3 , 0 )
0 commit comments