From 76a74501adaadd5eb1ef2a781549bfbb33467b87 Mon Sep 17 00:00:00 2001 From: Jamie Gravendeel Date: Wed, 3 Dec 2025 17:17:21 +0100 Subject: [PATCH] game-details: Add remove shortcut --- cartridges/ui/game-details.blp | 10 ++++++++-- cartridges/ui/game_details.py | 9 +++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cartridges/ui/game-details.blp b/cartridges/ui/game-details.blp index baadf84..1380413 100644 --- a/cartridges/ui/game-details.blp +++ b/cartridges/ui/game-details.blp @@ -8,6 +8,13 @@ template $GameDetails: Adw.NavigationPage { title: bind $_or(template.game as <$Game>.name, _("Add Game")) as ; hidden => $_exit(); + ShortcutController { + Shortcut { + trigger: "Delete|KP_Delete"; + action: "action(details.remove)"; + } + } + child: Adw.BreakpointBin { width-request: bind template.root as .width-request; height-request: bind template.root as .height-request; @@ -177,11 +184,10 @@ template $GameDetails: Adw.NavigationPage { } Button { - action-name: "game.remove"; + action-name: "details.remove"; icon-name: "user-trash-symbolic"; tooltip-text: _("Remove"); valign: center; - clicked => $_pop(); styles [ "circular", diff --git a/cartridges/ui/game_details.py b/cartridges/ui/game_details.py index 2667de0..568bc63 100644 --- a/cartridges/ui/game_details.py +++ b/cartridges/ui/game_details.py @@ -55,6 +55,7 @@ class GameDetails(Adw.NavigationPage): self.insert_action_group("details", group := Gio.SimpleActionGroup()) group.add_action_entries(( ("edit", lambda *_: self.edit()), + ("remove", lambda *_: self._remove()), ( "search-on", lambda _action, param, *_: Gio.AppInfo.launch_default_for_uri( @@ -113,6 +114,10 @@ class GameDetails(Adw.NavigationPage): def _activate_apply(self, _entry): self.activate_action("details.apply") + def _remove(self): + self.game.removed = True + self.activate_action("navigation.pop") + @Gtk.Template.Callback() def _or(self, _obj, first: _T, second: _T) -> _T: return first or second @@ -160,10 +165,6 @@ class GameDetails(Adw.NavigationPage): def _bool(self, _obj, o: object) -> bool: return bool(o) - @Gtk.Template.Callback() - def _pop(self, _obj): - self.activate_action("navigation.pop") - @Gtk.Template.Callback() def _format_more_info(self, _obj, label: str) -> str: executable = _("program")