From 2733df063ff37c17e10db362ea69859acaaa3e61 Mon Sep 17 00:00:00 2001 From: Diego Garcia Gangl Date: Mon, 27 May 2024 15:35:58 -0300 Subject: [PATCH] Add action to dismiss search bar fixes #1003 --- GTG/gtk/browser/main_window.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/GTG/gtk/browser/main_window.py b/GTG/gtk/browser/main_window.py index 57b5cf79b..a1850ee8c 100644 --- a/GTG/gtk/browser/main_window.py +++ b/GTG/gtk/browser/main_window.py @@ -210,6 +210,7 @@ def _set_actions(self): ('change_tags', self.on_modify_tags, ('win.change_tags', ['T'])), ('focus_sidebar', self.focus_sidebar, ('win.focus_sidebar', ['B'])), ('search', self.toggle_search, ('win.search', ['F'])), + ('close_search', self.dismiss_search, ('win.close_search', ['Escape'])), ('focus_quickentry', self.focus_quickentry, ('win.focus_quickentry', ['L'])), ('delete_task', self.on_delete_tasks, ('win.delete_task', ['Delete'])), ('help_overlay', None, ('win.show-help-overlay', ['question'])), @@ -483,15 +484,20 @@ def toggle_search(self, action, param): def on_search_toggled(self, widget=None): if self.searchbar.get_search_mode(): - self.search_button.set_active(False) - self.searchbar.set_search_mode(False) - self.search_entry.set_text('') + self.dismiss_search(None, None) else: self.search_button.set_active(True) self.searchbar.set_search_mode(True) self.search_entry.grab_focus() + def dismiss_search(self, action, param): + """Callback to dismiss the search bar.""" + + self.search_button.set_active(False) + self.searchbar.set_search_mode(False) + self.search_entry.set_text('') + def do_search(self): """Perform the actual search and cancel the timeout."""