Add Ctrl+1/2/3 keyboard shortcuts for view switching
Register show-installed, show-catalog, and show-updates actions with Ctrl+1, Ctrl+2, Ctrl+3 accelerators. Update the keyboard shortcuts dialog to show the new navigation shortcuts.
This commit is contained in:
@@ -985,6 +985,43 @@ impl DriftwoodWindow {
|
|||||||
}
|
}
|
||||||
self.add_action(©_path_action);
|
self.add_action(©_path_action);
|
||||||
|
|
||||||
|
// View switching actions for keyboard shortcuts
|
||||||
|
let show_installed_action = gio::SimpleAction::new("show-installed", None);
|
||||||
|
{
|
||||||
|
let window_weak = self.downgrade();
|
||||||
|
show_installed_action.connect_activate(move |_, _| {
|
||||||
|
let Some(window) = window_weak.upgrade() else { return };
|
||||||
|
if let Some(vs) = window.imp().view_stack.get() {
|
||||||
|
vs.set_visible_child_name("installed");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
self.add_action(&show_installed_action);
|
||||||
|
|
||||||
|
let show_catalog_action = gio::SimpleAction::new("show-catalog", None);
|
||||||
|
{
|
||||||
|
let window_weak = self.downgrade();
|
||||||
|
show_catalog_action.connect_activate(move |_, _| {
|
||||||
|
let Some(window) = window_weak.upgrade() else { return };
|
||||||
|
if let Some(vs) = window.imp().view_stack.get() {
|
||||||
|
vs.set_visible_child_name("catalog");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
self.add_action(&show_catalog_action);
|
||||||
|
|
||||||
|
let show_updates_action = gio::SimpleAction::new("show-updates", None);
|
||||||
|
{
|
||||||
|
let window_weak = self.downgrade();
|
||||||
|
show_updates_action.connect_activate(move |_, _| {
|
||||||
|
let Some(window) = window_weak.upgrade() else { return };
|
||||||
|
if let Some(vs) = window.imp().view_stack.get() {
|
||||||
|
vs.set_visible_child_name("updates");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
self.add_action(&show_updates_action);
|
||||||
|
|
||||||
// Keyboard shortcuts
|
// Keyboard shortcuts
|
||||||
if let Some(app) = self.application() {
|
if let Some(app) = self.application() {
|
||||||
let gtk_app = app.downcast_ref::<gtk::Application>().unwrap();
|
let gtk_app = app.downcast_ref::<gtk::Application>().unwrap();
|
||||||
@@ -994,6 +1031,9 @@ impl DriftwoodWindow {
|
|||||||
gtk_app.set_accels_for_action("win.dashboard", &["<Control>d"]);
|
gtk_app.set_accels_for_action("win.dashboard", &["<Control>d"]);
|
||||||
gtk_app.set_accels_for_action("win.check-updates", &["<Control>u"]);
|
gtk_app.set_accels_for_action("win.check-updates", &["<Control>u"]);
|
||||||
gtk_app.set_accels_for_action("win.show-shortcuts", &["<Control>question"]);
|
gtk_app.set_accels_for_action("win.show-shortcuts", &["<Control>question"]);
|
||||||
|
gtk_app.set_accels_for_action("win.show-installed", &["<Control>1"]);
|
||||||
|
gtk_app.set_accels_for_action("win.show-catalog", &["<Control>2"]);
|
||||||
|
gtk_app.set_accels_for_action("win.show-updates", &["<Control>3"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1409,6 +1449,9 @@ impl DriftwoodWindow {
|
|||||||
let nav_group = adw::PreferencesGroup::builder()
|
let nav_group = adw::PreferencesGroup::builder()
|
||||||
.title("Navigation")
|
.title("Navigation")
|
||||||
.build();
|
.build();
|
||||||
|
nav_group.add(&shortcut_row("Ctrl+1", "Installed"));
|
||||||
|
nav_group.add(&shortcut_row("Ctrl+2", "Catalog"));
|
||||||
|
nav_group.add(&shortcut_row("Ctrl+3", "Updates"));
|
||||||
nav_group.add(&shortcut_row("Ctrl+F", "Search"));
|
nav_group.add(&shortcut_row("Ctrl+F", "Search"));
|
||||||
nav_group.add(&shortcut_row("Ctrl+D", "Dashboard"));
|
nav_group.add(&shortcut_row("Ctrl+D", "Dashboard"));
|
||||||
nav_group.add(&shortcut_row("Ctrl+,", "Preferences"));
|
nav_group.add(&shortcut_row("Ctrl+,", "Preferences"));
|
||||||
|
|||||||
Reference in New Issue
Block a user