diff --git a/GTG/gtk/browser/main_window.py b/GTG/gtk/browser/main_window.py index 4cda243c3..4163c3e23 100644 --- a/GTG/gtk/browser/main_window.py +++ b/GTG/gtk/browser/main_window.py @@ -212,6 +212,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'])), @@ -485,15 +486,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."""