[gnome-2048] Add a Keyboard Shortcuts window.



commit c86f08a1966fa23dc184fc53c0fc22fea88f7c45
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Jan 25 10:30:16 2019 +0100

    Add a Keyboard Shortcuts window.
    
    Allow to launch it with the F1 shortcut,
    writing real help isn't planned for now.

 data/help-overlay.ui         | 82 ++++++++++++++++++++++++++++++++++++++++++++
 data/mainwindow.ui           |  9 ++---
 po/POTFILES.in               |  1 +
 src/application.vala         | 16 +++------
 src/gnome-2048.gresource.xml |  3 ++
 5 files changed, 96 insertions(+), 15 deletions(-)
---
diff --git a/data/help-overlay.ui b/data/help-overlay.ui
new file mode 100644
index 0000000..52eef04
--- /dev/null
+++ b/data/help-overlay.ui
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  This file is part of GNOME 2048
+
+  GNOME 2048 is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  GNOME 2048 is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with GNOME 2048.  If not, see <https://www.gnu.org/licenses/>.
+-->
+<interface domain="gnome-2048">
+  <requires lib="gtk+" version="3.12"/>
+  <object class="GtkShortcutsWindow" id="help_overlay">
+    <child>
+      <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">New game</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Choose a new 
game</property>
+                <property name="accelerator">&lt;Primary&gt;n</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <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>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">True</property>
+            <property name="title" translatable="yes" context="shortcut window">Generic</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Toggle main 
menu</property>
+                <property name="accelerator">F10 Menu</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Keyboard 
shortcuts</property>
+                <property name="accelerator">&lt;Primary&gt;question &lt;Primary&gt;F1</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">About</property>
+                <property name="accelerator">&lt;Shift&gt;F1</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Quit</property>
+                <property name="accelerator">&lt;Primary&gt;q</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/data/mainwindow.ui b/data/mainwindow.ui
index 1d267b8..5d10554 100644
--- a/data/mainwindow.ui
+++ b/data/mainwindow.ui
@@ -164,10 +164,11 @@
         <attribute name="label" translatable="yes">Preferences</attribute>
         <attribute name="action">app.preferences</attribute>
       </item>
-      <!-- item>
-        <attribute name="label" translatable="yes">Help</attribute>
-        <attribute name="action">app.help</attribute>
-      </item -->
+      <item>
+        <!-- Translators: usual menu entry of the hamburger menu -->
+        <attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
+        <attribute name="action">win.show-help-overlay</attribute>
+      </item>
       <item>
         <!-- Translators: entry in the hamburger menu -->
         <attribute name="label" translatable="yes">About 2048</attribute>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 21d5fb0..7cc57ca 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,7 @@
 # List of source files containing translatable strings.
 # Please keep this file in alphabetical order.
 data/congrats.ui
+data/help-overlay.ui
 data/mainwindow.ui
 data/org.gnome.2048.gschema.xml
 data/org.gnome.gnome-2048.appdata.xml.in
diff --git a/src/application.vala b/src/application.vala
index 62bc6d7..89c289d 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -135,9 +135,12 @@ public class Application : Gtk.Application
         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.about",             { "<Shift><Primary>F1",
+        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",
                                                                  "<Primary>F1",
-                                                                   "<Shift>F1"      });
+                                                                 "<Primary>question",
+                                                          "<Shift><Primary>question"});
         set_accels_for_action ("app.toggle-hamburger",  {                 "F10",
                                                                           "Menu"    });
 
@@ -314,15 +317,6 @@ public class Application : Gtk.Application
         _scores_ctx.run_dialog ();
     }
 
-/*    private void help_cb ()
-    {
-        try {
-            show_uri (_window.get_screen (), "help:gnome-2048", get_current_event_time ());
-        } catch (GLib.Error e) {
-            warning ("Failed to show help: %s", e.message);
-        }
-    } */
-
     private void about_cb (/* SimpleAction action, Variant? variant */)
     {
         string [] authors = { "Juan R. GarcĂ­a Blanco", "Arnaud Bonatti" };
diff --git a/src/gnome-2048.gresource.xml b/src/gnome-2048.gresource.xml
index 9569158..c80063a 100644
--- a/src/gnome-2048.gresource.xml
+++ b/src/gnome-2048.gresource.xml
@@ -6,4 +6,7 @@
     <file preprocess="xml-stripblanks">data/congrats.ui</file>
     <!-- file>data/style.css</file -->
   </gresource>
+  <gresource prefix="/org/gnome/gnome-2048/gtk">
+    <file preprocess="xml-stripblanks" alias="help-overlay.ui">../data/help-overlay.ui</file>
+  </gresource>
 </gresources>


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