Skip to content

Commit

Permalink
Add keyboard shortcut to change view
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberphantom52 committed Jun 24, 2023
1 parent ac9cf19 commit 252334f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bottles/frontend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def __init__(self):
self.__create_action('preferences', self.__show_preferences, ['<primary>comma'])
self.__create_action('help', self.__help, ['F1'])
self.__create_action('new', self.__new_bottle, ['<primary>n'])
self.__create_action('switch_to_bottles_page', self.__show_bottles_view, ['<alt>1'])
self.__create_action('switch_to_library_page', self.__show_library_view, ['<alt>2'])

self.__register_arguments()

Expand Down Expand Up @@ -340,6 +342,12 @@ def __show_about_window(self, *_args):
about_window.set_transient_for(self.win)
about_window.present()

def __show_library_view(self, *_args):
self.win.stack_main.set_visible_child_name("page_library")

def __show_bottles_view(self, *_args):
self.win.stack_main.set_visible_child_name("page_list")

def __create_action(self, name, callback, shortcuts=None, param=None):
"""Add an application action.
Expand Down
9 changes: 9 additions & 0 deletions bottles/frontend/ui/help-overlay.blp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ ShortcutsWindow help_overlay {
action-name: "app.quit";
}

ShortcutsShortcut {
title: C_("shortcut window", "Switch to Bottles view");
action-name: "app.switch_to_bottles_page";
}

ShortcutsShortcut {
title: C_("shortcut window", "Switch to Library view");
action-name: "app.switch_to_library_page";
}
}
}
}

0 comments on commit 252334f

Please sign in to comment.