Add shortcuts to open specific pages

This commit is contained in:
heliguy4599
2024-10-12 17:23:01 -04:00
parent a136a2f547
commit c81ca758e3
2 changed files with 17 additions and 6 deletions

View File

@@ -46,7 +46,13 @@ class WarehouseApplication(Adw.Application):
self.create_action("quit", lambda *_: self.quit(), ["<primary>q"])
self.create_action("refresh", self.on_refresh_shortcut, ["<primary>r", "F5"])
self.create_action("open-menu", lambda *_: self.props.active_window.main_menu.popup(), ["F10"])
self.create_action("show-packages-page", lambda *_: self.props.active_window.switch_page_shortcut_handler("p"), ["<primary>p"])
self.create_action("show-remotes-page", lambda *_: self.props.active_window.switch_page_shortcut_handler("m"), ["<primary>m"])
self.create_action("show-user-data-page", lambda *_: self.props.active_window.switch_page_shortcut_handler("d"), ["<primary>d"])
self.create_action("show-snapshots-page", lambda *_: self.props.active_window.switch_page_shortcut_handler("s"), ["<primary>s"])
self.create_action("show-install-page", lambda *_: self.props.active_window.switch_page_shortcut_handler("i"), ["<primary>i"])
self.is_dialog_open = False
gtk_version = (

View File

@@ -117,11 +117,6 @@ class WarehouseWindow(Adw.ApplicationWindow):
nav_row.grab_focus()
break
def save_sidebar_state(self, *args):
state = self.main_split.get_show_sidebar()
self.settings.set_boolean("sidebar-shown", state)
print(self.settings.get_boolean("sidebar-shown"))
def show_saved_page(self):
page_to_show = self.settings.get_string("page-shown")
page_found = False
@@ -194,6 +189,9 @@ class WarehouseWindow(Adw.ApplicationWindow):
def on_drop_leave(self, *args):
self.file_drop_stack.set_visible_child(self.main_split)
def switch_page_shortcut_handler(self, letter):
self.activate_row(self.shortcut_to_pages[letter])
def __init__(self, **kwargs):
super().__init__(**kwargs)
@@ -208,6 +206,13 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.snapshots_row: SnapshotPage(main_window=self),
self.install_row: InstallPage(main_window=self),
}
self.shortcut_to_pages = {
"p": self.packages_row,
"m": self.remotes_row,
"d": self.user_data_row,
"s": self.snapshots_row,
"i": self.install_row,
}
self.navigation_row_listbox.connect("row-activated", self.navigation_handler)
self.show_saved_page()
self.refresh_lockouts = []