[gnome-2048] Add Undo and Preferences shortcuts.



commit 93ad07167c58f3dc05053ab36133b49cca7379bb
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Jan 25 17:02:18 2019 +0100

    Add Undo and Preferences shortcuts.

 data/help-overlay.ui | 36 ++++++++++++++++++++++++++++++++++++
 src/application.vala |  5 ++++-
 2 files changed, 40 insertions(+), 1 deletion(-)
---
diff --git a/data/help-overlay.ui b/data/help-overlay.ui
index 52eef04..421df08 100644
--- a/data/help-overlay.ui
+++ b/data/help-overlay.ui
@@ -22,6 +22,28 @@
       <object class="GtkShortcutsSection">
         <property name="visible">True</property>
         <property name="max-height">11</property>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">True</property>
+            <property name="title" translatable="yes" context="shortcut window">Game</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <!-- Translators: the application has no help, so the use of arrows for playing is 
documented here -->
+                <property name="title" translatable="yes" context="shortcut window">Play</property>
+                <property name="accelerator">Left Up Right Down</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <!-- Translators: undo is not allowed by default, it is an option available in the 
Preferences dialog -->
+                <property name="title" translatable="yes" context="shortcut window">Undo (if 
enabled)</property>
+                <property name="accelerator">&lt;Primary&gt;z</property>
+              </object>
+            </child>
+          </object>
+        </child>
         <child>
           <object class="GtkShortcutsGroup">
             <property name="visible">True</property>
@@ -29,6 +51,7 @@
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
+                <!-- Translators: that opens the New Game menu, that allow to choose the board size of the 
next game -->
                 <property name="title" translatable="yes" context="shortcut window">Choose a new 
game</property>
                 <property name="accelerator">&lt;Primary&gt;n</property>
               </object>
@@ -36,6 +59,7 @@
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
+                <!-- Translators: that is an immediate start of a new game, with similar options -->
                 <property name="title" translatable="yes" context="shortcut window">Start a new 
game</property>
                 <property name="accelerator">&lt;Shift&gt;&lt;Primary&gt;n</property>
               </object>
@@ -49,6 +73,7 @@
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
+                <!-- Translators: toggles the hamburger menu -->
                 <property name="title" translatable="yes" context="shortcut window">Toggle main 
menu</property>
                 <property name="accelerator">F10 Menu</property>
               </object>
@@ -56,6 +81,15 @@
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
+                <!-- Translators: opens Prefences dialog -->
+                <property name="title" translatable="yes" context="shortcut window">Preferences</property>
+                <property name="accelerator">&lt;Primary&gt;e</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <!-- Translators: opens Keyboard Shortcuts window -->
                 <property name="title" translatable="yes" context="shortcut window">Keyboard 
shortcuts</property>
                 <property name="accelerator">&lt;Primary&gt;question &lt;Primary&gt;F1</property>
               </object>
@@ -63,6 +97,7 @@
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
+                <!-- Translators: opens About dialog -->
                 <property name="title" translatable="yes" context="shortcut window">About</property>
                 <property name="accelerator">&lt;Shift&gt;F1</property>
               </object>
@@ -70,6 +105,7 @@
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
+                <!-- Translators: quit application -->
                 <property name="title" translatable="yes" context="shortcut window">Quit</property>
                 <property name="accelerator">&lt;Primary&gt;q</property>
               </object>
diff --git a/src/application.vala b/src/application.vala
index 91dee25..11e109f 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -127,9 +127,11 @@ public class Application : Gtk.Application
 
         _create_scores_dialog ();   // the library forbids to delay the dialog creation
 
+        set_accels_for_action ("app.preferences",       {        "<Primary>e"       });
         set_accels_for_action ("app.toggle-new-game",   {        "<Primary>n"       });
         set_accels_for_action ("app.new-game",          { "<Shift><Primary>n"       });
         set_accels_for_action ("app.quit",              {        "<Primary>q"       });
+        set_accels_for_action ("app.undo",              {        "<Primary>z"       });
         set_accels_for_action ("app.about",             {          "<Shift>F1",
                                                           "<Shift><Primary>F1"      }); // as usual, this 
second shortcut does not work
         set_accels_for_action ("win.show-help-overlay", {                 "F1",
@@ -302,7 +304,8 @@ public class Application : Gtk.Application
 
     private void undo_cb (/* SimpleAction action, Variant? variant */)
     {
-        _game.undo ();
+        if (_settings.get_boolean ("allow-undo"))   // for the keyboard shortcut
+            _game.undo ();
     }
 
     private void new_game_cb (/* SimpleAction action, Variant? variant */)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]