mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Fix backspace shortcut breaking typing in inputs
This commit is contained in:
17
src/main.py
17
src/main.py
@@ -60,7 +60,6 @@ class WarehouseApplication(Adw.Application):
|
||||
self.create_action("toggle-search-mode", self.on_toggle_search_mode_shortcut, ["<primary>f"])
|
||||
self.create_action("filter", self.on_filter_shortcut, ["<primary>t"])
|
||||
self.create_action("new", self.on_new_shortcut, ["<primary>n"])
|
||||
self.create_action("delete", self.on_delete_shortcut, ["BackSpace", "Delete"])
|
||||
self.create_action("active-data-view", lambda *_: self.on_data_view_shortcut(True), ["<Alt>1"])
|
||||
self.create_action("leftover-data-view", lambda *_: self.on_data_view_shortcut(False), ["<Alt>2"])
|
||||
|
||||
@@ -167,22 +166,6 @@ class WarehouseApplication(Adw.Application):
|
||||
|
||||
def on_delete_shortcut(self, *args):
|
||||
page = self.props.active_window.stack.get_visible_child()
|
||||
try:
|
||||
if not page.select_button.get_active():
|
||||
return
|
||||
|
||||
page.selection_uninstall()
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
if not page.select_button.get_active():
|
||||
return
|
||||
|
||||
page.trash_handler()
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
if not page.select_button.get_active():
|
||||
return
|
||||
|
||||
@@ -45,13 +45,6 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
snapshots_row = gtc()
|
||||
install_row = gtc()
|
||||
|
||||
def key_handler(self, controller, keyval, keycode, state):
|
||||
if keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK:
|
||||
self.close()
|
||||
|
||||
# if keyval == Gdk.KEY_Escape:
|
||||
# self.batch_mode_button.set_active(False)
|
||||
|
||||
def start_loading(self, *args):
|
||||
for _, page in self.pages.items():
|
||||
if page.instance:
|
||||
@@ -188,6 +181,15 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
def switch_page_shortcut_handler(self, letter):
|
||||
self.activate_row(self.shortcut_to_pages[letter])
|
||||
|
||||
def key_handler(self, controller, keyval, keycode, state):
|
||||
if keyval == Gdk.KEY_BackSpace or keyval == Gdk.KEY_Delete:
|
||||
page = self.stack.get_visible_child()
|
||||
try:
|
||||
if page.select_button.get_active():
|
||||
page.on_backspace_handler()
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
|
||||
@@ -345,6 +345,7 @@ class PackagesPage(Adw.BreakpointBin):
|
||||
self.prev_status = None
|
||||
self.selected_rows = []
|
||||
self.current_row_for_properties = None
|
||||
self.on_backspace_handler = self.selection_uninstall
|
||||
event_controller = Gtk.EventControllerKey()
|
||||
|
||||
# Apply
|
||||
|
||||
@@ -456,10 +456,10 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
|
||||
AttemptInstallDialog(package_names, lambda is_valid: self.select_button.set_active(not is_valid))
|
||||
|
||||
def select_trash_handler(self):
|
||||
def selection_trash_handler(self):
|
||||
if (
|
||||
self.is_trash_dialog_open
|
||||
or len(self.selected_active_rows) + len(self.selected_leftover_rows) < 1
|
||||
len(self.selected_active_rows) + len(self.selected_leftover_rows) < 1
|
||||
or self.is_trash_dialog_open
|
||||
):
|
||||
return
|
||||
|
||||
@@ -502,7 +502,7 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
case self.install_from_snapshots:
|
||||
self.install_handler()
|
||||
case self.trash_snapshots:
|
||||
self.select_trash_handler()
|
||||
self.selection_trash_handler()
|
||||
|
||||
def key_handler(self, controller, keyval, keycode, state):
|
||||
if keyval == Gdk.KEY_Escape:
|
||||
@@ -522,6 +522,7 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
self.list_page = SnapshotsListPage(self)
|
||||
self.snapshotting_status = LoadingStatus("Initial Title", _("This could take a while"), True, self.on_cancel)
|
||||
self.new_snapshot_dialog = None
|
||||
self.on_backspace_handler = self.selection_trash_handler
|
||||
event_controller = Gtk.EventControllerKey()
|
||||
|
||||
# Apply
|
||||
|
||||
@@ -155,7 +155,7 @@ class UserDataPage(Adw.BreakpointBin):
|
||||
HostInfo.clipboard.set(to_copy.replace("\n", "", 1))
|
||||
self.toast_overlay.add_toast(Adw.Toast(title=_("Copied paths")))
|
||||
|
||||
def trash_handler(self, *args):
|
||||
def selection_trash_handler(self, *args):
|
||||
error = [None]
|
||||
child = self.stack.get_visible_child()
|
||||
|
||||
@@ -239,7 +239,7 @@ class UserDataPage(Adw.BreakpointBin):
|
||||
case self.more_install:
|
||||
self.install_handler()
|
||||
case self.more_trash:
|
||||
self.trash_handler()
|
||||
self.selection_trash_handler()
|
||||
|
||||
def key_handler(self, controller, keyval, keycode, state):
|
||||
if keyval == Gdk.KEY_Escape:
|
||||
@@ -263,6 +263,7 @@ class UserDataPage(Adw.BreakpointBin):
|
||||
"size": self.sort_size,
|
||||
}
|
||||
self.buttons_to_sort_modes = {}
|
||||
self.on_backspace_handler = self.selection_trash_handler
|
||||
event_controller = Gtk.EventControllerKey()
|
||||
|
||||
# Apply
|
||||
@@ -290,7 +291,7 @@ class UserDataPage(Adw.BreakpointBin):
|
||||
self.select_button.connect("toggled", self.select_toggle_handler)
|
||||
self.select_all_button.connect("clicked", self.select_all_handler)
|
||||
self.copy_button.connect("clicked", self.copy_handler)
|
||||
self.trash_button.connect("clicked", self.trash_handler)
|
||||
self.trash_button.connect("clicked", self.selection_trash_handler)
|
||||
self.install_button.connect("clicked", self.install_handler)
|
||||
self.more_menu.connect("row-activated", self.more_menu_handler)
|
||||
self.sort_ascend.connect("clicked", self.sort_button_handler)
|
||||
|
||||
Reference in New Issue
Block a user