game-details: Add remove shortcut

This commit is contained in:
Jamie Gravendeel
2025-12-03 17:17:21 +01:00
parent f8fa86859e
commit 76a74501ad
2 changed files with 13 additions and 6 deletions

View File

@@ -8,6 +8,13 @@ template $GameDetails: Adw.NavigationPage {
title: bind $_or(template.game as <$Game>.name, _("Add Game")) as <string>;
hidden => $_exit();
ShortcutController {
Shortcut {
trigger: "Delete|KP_Delete";
action: "action(details.remove)";
}
}
child: Adw.BreakpointBin {
width-request: bind template.root as <Widget>.width-request;
height-request: bind template.root as <Widget>.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",

View File

@@ -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")