Skip to content

Commit

Permalink
Add action to dismiss search bar
Browse files Browse the repository at this point in the history
fixes #1003
  • Loading branch information
diegogangl committed Jun 24, 2024
1 parent 13ba20c commit 2733df0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions GTG/gtk/browser/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def _set_actions(self):
('change_tags', self.on_modify_tags, ('win.change_tags', ['<ctrl>T'])),
('focus_sidebar', self.focus_sidebar, ('win.focus_sidebar', ['<ctrl>B'])),
('search', self.toggle_search, ('win.search', ['<ctrl>F'])),
('close_search', self.dismiss_search, ('win.close_search', ['Escape'])),
('focus_quickentry', self.focus_quickentry, ('win.focus_quickentry', ['<ctrl>L'])),
('delete_task', self.on_delete_tasks, ('win.delete_task', ['<ctrl>Delete'])),
('help_overlay', None, ('win.show-help-overlay', ['<ctrl>question'])),
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit 2733df0

Please sign in to comment.