mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Add keyboard shortcuts
This commit is contained in:
@@ -24,6 +24,21 @@ ShortcutsWindow help_overlay {
|
||||
title: C_("shortcut window", "Quit");
|
||||
action-name: "app.quit";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: C_("shortcut window", "Toggle Batch Mode");
|
||||
action-name: "app.toggle-batch-mode";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: C_("shortcut window", "Manage Orphaned Data Folders");
|
||||
action-name: "app.open-orphans-window";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: C_("shortcut window", "Select All Flatpaks");
|
||||
action-name: "app.select-all-in-batch-mode";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
18
src/main.py
18
src/main.py
@@ -39,12 +39,28 @@ class FlattoolGuiApplication(Adw.Application):
|
||||
self.create_action('preferences', self.on_preferences_action)
|
||||
self.create_action('search', self.on_search_action, ['<primary>f'])
|
||||
self.create_action('manage-data-folders', self.on_manage_data_folders_action)
|
||||
#self.create_action('toggle ba')
|
||||
self.create_action('toggle-batch-mode', self.batch_mode_shortcut, ['<primary>b'])
|
||||
self.create_action('select-all-in-batch-mode', self.select_all_shortcut, ['<primary>a'])
|
||||
self.create_action('open-orphans-window', self.manage_data_shortcut, ['<primary>d'])
|
||||
|
||||
self.show_runtimes_stateful = Gio.SimpleAction.new_stateful("show-runtimes", None, GLib.Variant.new_boolean(False))
|
||||
self.show_runtimes_stateful.connect("activate", self.on_show_runtimes_action)
|
||||
self.add_action(self.show_runtimes_stateful)
|
||||
|
||||
def batch_mode_shortcut(self, widget, _):
|
||||
button = self.props.active_window.batch_mode_button
|
||||
button.set_active(not button.get_active())
|
||||
|
||||
def select_all_shortcut(self, widget, _):
|
||||
batch_button = self.props.active_window.batch_mode_button
|
||||
batch_button.set_active(True)
|
||||
select_button = self.props.active_window.batch_select_all_button
|
||||
select_button.set_active(not select_button.get_active())
|
||||
self.props.active_window.batch_select_all_handler(select_button)
|
||||
|
||||
def manage_data_shortcut(self, widget, _):
|
||||
self.props.active_window.orphans_window()
|
||||
|
||||
def do_activate(self):
|
||||
"""Called when the application is activated.
|
||||
|
||||
|
||||
@@ -644,6 +644,10 @@ class FlattoolGuiWindow(Adw.ApplicationWindow):
|
||||
dialog.connect("response", self.batch_uninstall_on_response, dialog.choose_finish)
|
||||
Gtk.Window.present(dialog)
|
||||
|
||||
def batch_key_handler(self, _b, event, _c, _d):
|
||||
if event == Gdk.KEY_Escape:
|
||||
self.batch_mode_button.set_active(False)
|
||||
|
||||
def flatpak_row_select_handler(self, tickbox, index):
|
||||
if tickbox.get_active():
|
||||
self.selected_host_flatpak_indexes.append(index)
|
||||
@@ -674,3 +678,6 @@ class FlattoolGuiWindow(Adw.ApplicationWindow):
|
||||
self.batch_uninstall_button.add_css_class("destructive-action")
|
||||
self.batch_select_all_button.connect("clicked", self.batch_select_all_handler)
|
||||
self.batch_actions_enable(False)
|
||||
event_controller = Gtk.EventControllerKey()
|
||||
event_controller.connect("key-pressed", self.batch_key_handler)
|
||||
self.add_controller(event_controller)
|
||||
Reference in New Issue
Block a user