game-details: Rename edit-done to apply
This commit is contained in:
committed by
Laura Kramolis
parent
fe8e41ecb7
commit
fdf4d6d788
@@ -256,19 +256,19 @@ template $GameDetails: Adw.NavigationPage {
|
|||||||
Adw.PreferencesGroup {
|
Adw.PreferencesGroup {
|
||||||
Adw.EntryRow name_entry {
|
Adw.EntryRow name_entry {
|
||||||
title: _("Title");
|
title: _("Title");
|
||||||
entry-activated => $_activate_edit_done();
|
entry-activated => $_activate_apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
Adw.EntryRow developer_entry {
|
Adw.EntryRow developer_entry {
|
||||||
title: _("Developer (optional)");
|
title: _("Developer (optional)");
|
||||||
entry-activated => $_activate_edit_done();
|
entry-activated => $_activate_apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Adw.PreferencesGroup {
|
Adw.PreferencesGroup {
|
||||||
Adw.EntryRow executable_entry {
|
Adw.EntryRow executable_entry {
|
||||||
title: _("Executable");
|
title: _("Executable");
|
||||||
entry-activated => $_activate_edit_done();
|
entry-activated => $_activate_apply();
|
||||||
|
|
||||||
[suffix]
|
[suffix]
|
||||||
MenuButton {
|
MenuButton {
|
||||||
@@ -297,7 +297,7 @@ template $GameDetails: Adw.NavigationPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
action-name: "details.edit-done";
|
action-name: "details.apply";
|
||||||
label: bind $_if_else(template.game as <$Game>.added, _("Apply"), _("Add")) as <string>;
|
label: bind $_if_else(template.game as <$Game>.added, _("Apply"), _("Add")) as <string>;
|
||||||
halign: center;
|
halign: center;
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ class GameDetails(Adw.NavigationPage):
|
|||||||
),
|
),
|
||||||
))
|
))
|
||||||
|
|
||||||
group.add_action(edit_done := Gio.SimpleAction.new("edit-done"))
|
group.add_action(apply := Gio.SimpleAction.new("apply"))
|
||||||
edit_done.connect("activate", lambda *_: self._edit_done())
|
apply.connect("activate", lambda *_: self._apply())
|
||||||
|
|
||||||
entries = tuple(
|
entries = tuple(
|
||||||
Gtk.PropertyExpression.new(
|
Gtk.PropertyExpression.new(
|
||||||
@@ -75,7 +75,7 @@ class GameDetails(Adw.NavigationPage):
|
|||||||
for prop in _REQUIRED_PROPERTIES
|
for prop in _REQUIRED_PROPERTIES
|
||||||
)
|
)
|
||||||
valid = Gtk.ClosureExpression.new(bool, lambda _, *values: all(values), entries)
|
valid = Gtk.ClosureExpression.new(bool, lambda _, *values: all(values), entries)
|
||||||
valid.bind(edit_done, "enabled")
|
valid.bind(apply, "enabled")
|
||||||
|
|
||||||
def edit(self):
|
def edit(self):
|
||||||
"""Enter edit mode."""
|
"""Enter edit mode."""
|
||||||
@@ -87,7 +87,7 @@ class GameDetails(Adw.NavigationPage):
|
|||||||
self.stack.props.visible_child_name = "edit"
|
self.stack.props.visible_child_name = "edit"
|
||||||
self.name_entry.grab_focus()
|
self.name_entry.grab_focus()
|
||||||
|
|
||||||
def _edit_done(self):
|
def _apply(self):
|
||||||
for prop in _EDITABLE_PROPERTIES:
|
for prop in _EDITABLE_PROPERTIES:
|
||||||
entry = getattr(self, f"{prop}_entry")
|
entry = getattr(self, f"{prop}_entry")
|
||||||
value = entry.props.text
|
value = entry.props.text
|
||||||
@@ -109,8 +109,8 @@ class GameDetails(Adw.NavigationPage):
|
|||||||
self.stack.props.visible_child_name = "details"
|
self.stack.props.visible_child_name = "details"
|
||||||
|
|
||||||
@Gtk.Template.Callback()
|
@Gtk.Template.Callback()
|
||||||
def _activate_edit_done(self, _entry):
|
def _activate_apply(self, _entry):
|
||||||
self.activate_action("details.edit-done")
|
self.activate_action("details.apply")
|
||||||
|
|
||||||
@Gtk.Template.Callback()
|
@Gtk.Template.Callback()
|
||||||
def _or(self, _obj, first: _T, second: _T) -> _T:
|
def _or(self, _obj, first: _T, second: _T) -> _T:
|
||||||
|
|||||||
Reference in New Issue
Block a user