Public repository: timo / schach

Reader

Ein aufgeräumtes Schach-Programm für GNOME

feat(ui): icon-only help buttons, Backspace undoes

public

feat(ui): icon-only help buttons, Backspace undoes

- Hint and threat split buttons without labels; second hint step
  named in the tooltip instead
- Backspace as second undo key via bubble-phase controller, not an
  app accel, so text fields keep it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Changeset447ade111494cb23613b64282a5dd743a0397d6e
Author (claimed)Timo Stolz <timo.stolz@nullachtvierzehn.de>,
Parents2253b73de93a
Childrendbcddca5f6c7
Pushlog
by timo via ssh
by timo via ssh

modified README.md +1 −1

@@ -97,7 +97,7 @@ Ins App-Menü aufnehmen:
9797
 | Taste | Aktion |
9898
 |---|---|
9999
 | Strg+N | Neue Partie |
100
-| Strg+Z | Zug zurücknehmen |
100
+| Strg+Z oder Rücktaste | Zug zurücknehmen |
101101
 | H | Hinweis |
102102
 | B | Drohung zeigen |
103103
 | F | Brett drehen |

modified schach/app.py +17 −4

@@ -50,7 +50,7 @@ FEATURED_THEMES = [
5050
 # Übersicht für den Reiter „Tastenkürzel“ in den Einstellungen
5151
 SHORTCUTS = [
5252
     ("Partie", [
53
-        ("Neue Partie", "<Control>n"), ("Zug zurücknehmen", "<Control>z"),
53
+        ("Neue Partie", "<Control>n"), ("Zug zurücknehmen", "<Control>z BackSpace"),
5454
         ("Hinweis", "h"), ("Drohung zeigen", "b"), ("Neues Rätsel", "r"),
5555
     ]),
5656
     ("Ansicht", [
@@ -258,9 +258,8 @@ class Window(OnlineMixin, PuzzleMixin, O
258258
         threat_menu = Gio.Menu()
259259
         threat_menu.append_section("Drohung von", sources)
260260
         self.helper_menu = helper_menu
261
-        self.hint_content = Adw.ButtonContent(icon_name="dialog-information-symbolic", label="Hinweis")
262261
         self.hint_btn = Adw.SplitButton(
263
-            child=self.hint_content, menu_model=helper_menu, dropdown_tooltip="Wer hilft?",
262
+            icon_name="dialog-information-symbolic", menu_model=helper_menu, dropdown_tooltip="Wer hilft?",
264263
         )
265264
         self.hint_btn.set_action_name("win.hint")
266265
         self.help_box = Gtk.Box(spacing=6)
@@ -337,6 +336,14 @@ class Window(OnlineMixin, PuzzleMixin, O
337336
         self.view.set_focusable(True)
338337
         self.set_focus(self.view)
339338
 
339
+        # Rücktaste nimmt auch zurück – aber nicht als App-Kürzel, sonst fehlt sie in Textfeldern
340
+        backspace = Gtk.ShortcutController(propagation_phase=Gtk.PropagationPhase.BUBBLE)
341
+        backspace.add_shortcut(Gtk.Shortcut(
342
+            trigger=Gtk.ShortcutTrigger.parse_string("BackSpace"),
343
+            action=Gtk.CallbackAction.new(self._backspace_undo),
344
+        ))
345
+        self.add_controller(backspace)
346
+
340347
         self.set_size_request(360, 480)
341348
         breakpoint = Adw.Breakpoint.new(Adw.BreakpointCondition.parse("max-width: 560sp"))
342349
         breakpoint.connect("apply", lambda *_: self._set_narrow(True))
@@ -614,10 +621,10 @@ class Window(OnlineMixin, PuzzleMixin, O
614621
         self._action("duo-draw").set_enabled(self.mode == "duo" and not self._over())
615622
         self._action("duo-resign").set_enabled(self.mode == "duo" and not self._over())
616623
         self._action("hint").set_enabled(can_hint)
617
-        self.hint_content.set_label("Zug zeigen" if self.hint_level == 1 else "Hinweis")
618624
         self.hint_btn.set_tooltip_text(
619625
             "Hinweis (H) – das Rätsel zählt dann nicht als gelöst" if self.mode == "puzzle"
620626
             else "Kurszug zeigen (H)" if self.mode == "opening"
627
+            else f"Zug zeigen (H) – von {HELPERS[self._helper()][0]}" if self.hint_level == 1
621628
             else f"Hinweis von {HELPERS[self._helper()][0]} (H)"
622629
         )
623630
         self._action("hint-helper").set_enabled(self.mode in ("maia", "duo"))  # Rätsel: Hinweis = Lösung
@@ -940,6 +947,12 @@ class Window(OnlineMixin, PuzzleMixin, O
940947
         self.maia_ready = True
941948
         self._refresh()
942949
 
950
+    def _backspace_undo(self, *_):
951
+        if isinstance(self.get_focus(), Gtk.Editable) or not self._action("undo").get_enabled():
952
+            return False
953
+        self.activate_action("win.undo", None)
954
+        return True
955
+
943956
     def undo(self, *_):
944957
         if self.mode == "online":
945958
             self._takeback_request()