[gnome-nibbles/arnaudb/shortcuts-dialog: 6/7] Add Keyboard Shortcuts dialog.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles/arnaudb/shortcuts-dialog: 6/7] Add Keyboard Shortcuts dialog.
- Date: Wed, 8 Jul 2020 15:03:18 +0000 (UTC)
commit 22ca68c7b2c9702d195bb31214fc108745738e53
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Mon Jul 6 16:35:18 2020 +0200
Add Keyboard Shortcuts dialog.
data/gnome-nibbles.gresource.xml | 5 +-
data/ui/help-overlay.ui | 123 +++++++++++++++++++++++++++++++++++++++
data/ui/nibbles.ui | 5 ++
src/controls.vala | 4 +-
src/gnome-nibbles.vala | 2 +-
src/nibbles-window.vala | 4 +-
src/players.vala | 2 +-
src/preferences-dialog.vala | 2 +-
src/scoreboard.vala | 4 +-
src/speed.vala | 2 +-
10 files changed, 142 insertions(+), 11 deletions(-)
---
diff --git a/data/gnome-nibbles.gresource.xml b/data/gnome-nibbles.gresource.xml
index da59396..f3e46e7 100644
--- a/data/gnome-nibbles.gresource.xml
+++ b/data/gnome-nibbles.gresource.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
- <gresource prefix="/org/gnome/nibbles/ui">
+ <gresource prefix="/org/gnome/Nibbles/ui">
<file preprocess="xml-stripblanks" alias="controls.ui"
ui/controls.ui</file>
<file preprocess="xml-stripblanks" alias="controls-grid.ui"
ui/controls-grid.ui</file>
<file preprocess="xml-stripblanks" compressed="true" alias="first-run.ui"
ui/first-run.ui</file>
@@ -12,4 +12,7 @@
<file preprocess="xml-stripblanks" alias="scoreboard.ui"
ui/scoreboard.ui</file>
<file preprocess="xml-stripblanks" alias="speed.ui" >ui/speed.ui</file>
</gresource>
+ <gresource prefix="/org/gnome/Nibbles/gtk">
+ <file preprocess="xml-stripblanks" alias="help-overlay.ui"
ui/help-overlay.ui</file>
+ </gresource>
</gresources>
diff --git a/data/ui/help-overlay.ui b/data/ui/help-overlay.ui
new file mode 100644
index 0000000..6f0838b
--- /dev/null
+++ b/data/ui/help-overlay.ui
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ This file is part of GNOME Nibbles.
+
+ Copyright (C) 2020 Arnaud Bonatti
+
+ GNOME Nibbles 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 2 of the License, or
+ (at your option) any later version.
+
+ GNOME Nibbles 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 this GNOME Nibbles. If not, see <https://www.gnu.org/licenses/>.
+-->
+<interface domain="gnome-nibbles">
+ <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">6</property>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="visible">True</property>
+ <!-- Translators: header of the "Next screen" and "Previous screen" shortcuts section -->
+ <property name="title" translatable="yes" context="shortcut window">During game setup</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <!-- Translators: shortcut that during game setup switches to the next screen -->
+ <property name="title" translatable="yes" context="shortcut window">Next screen</property>
+ <property name="accelerator"><Primary>n</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <!-- Translators: shortcut that during game setup goes back to the previous screen -->
+ <property name="title" translatable="yes" context="shortcut window">Previous
screen</property>
+ <property name="accelerator">Escape</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="visible">True</property>
+ <!-- Translators: header of the "Start a new game" and "Pause or unpause" shortcuts section -->
+ <property name="title" translatable="yes" context="shortcut window">During a game</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <!-- Translators: shortcut that during a game opens a popup to discard current game and
start a new one -->
+ <property name="title" translatable="yes" context="shortcut window">Start a new
game</property>
+ <property name="accelerator"><Primary>n Escape</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <!-- Translators: shortcut that pauses or unpauses the current game -->
+ <property name="title" translatable="yes" context="shortcut window">Pause or
unpause</property>
+ <property name="accelerator"><Primary>p Pause</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="visible">True</property>
+ <!-- Translators: header of the "Toggle main menu," "Keyboard shortcuts," "About," and "Quit,"
shortcuts section -->
+ <property name="title" translatable="yes" context="shortcut window">Generic</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <!-- Translators: shortcut that toggles the hamburger menu -->
+ <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>
+ <!-- Translators: shortcut that opens Keyboard Shortcuts window -->
+ <property name="title" translatable="yes" context="shortcut window">Keyboard
shortcuts</property>
+ <property name="accelerator"><Primary>question</property> <!-- TODO make
<Primary>F1 work -->
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <!-- Translators: shortcut that opens the application help -->
+ <property name="title" translatable="yes" context="shortcut window">Help</property>
+ <property name="accelerator">F1</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">False</property>
+ <!-- Translators: shortcut (disabled for now) that opens About dialog -->
+ <property name="title" translatable="yes" context="shortcut window">About</property>
+ <property name="accelerator"><Shift>F1</property> <!-- TODO implement shortcut -->
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <!-- Translators: shortcut that quits application -->
+ <property name="title" translatable="yes" context="shortcut window">Quit</property>
+ <property name="accelerator"><Primary>q</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/data/ui/nibbles.ui b/data/ui/nibbles.ui
index a284c33..94a94d4 100644
--- a/data/ui/nibbles.ui
+++ b/data/ui/nibbles.ui
@@ -35,6 +35,11 @@
</item>
</section>
<section>
+ <item>
+ <!-- Translators: entry of the hamburger menu (with a mnemonic that appears when pressing Alt);
displays Keyboard Shortcuts dialog -->
+ <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+ <attribute name="action">win.show-help-overlay</attribute>
+ </item>
<item>
<!-- Translators: entry of the hamburger menu (with a mnemonic that appears when pressing Alt);
opens the help of the application -->
<attribute name="label" translatable="yes">_Help</attribute>
diff --git a/src/controls.vala b/src/controls.vala
index 20b8bb0..b1d484e 100644
--- a/src/controls.vala
+++ b/src/controls.vala
@@ -19,7 +19,7 @@
using Gtk;
-[GtkTemplate (ui = "/org/gnome/nibbles/ui/controls.ui")]
+[GtkTemplate (ui = "/org/gnome/Nibbles/ui/controls.ui")]
private class Controls : Box
{
[GtkChild] private Box grids_box;
@@ -99,7 +99,7 @@ private class Controls : Box
}
}
-[GtkTemplate (ui = "/org/gnome/nibbles/ui/controls-grid.ui")]
+[GtkTemplate (ui = "/org/gnome/Nibbles/ui/controls-grid.ui")]
private class ControlsGrid : Button
{
[GtkChild] private Label name_label;
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index 452c643..33af594 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -84,7 +84,7 @@ private class Nibbles : Gtk.Application
Gtk.Settings.get_default ().@set ("gtk-application-prefer-dark-theme", true);
var css_provider = new CssProvider ();
- css_provider.load_from_resource ("/org/gnome/nibbles/ui/nibbles.css");
+ css_provider.load_from_resource ("/org/gnome/Nibbles/ui/nibbles.css");
StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), css_provider,
STYLE_PROVIDER_PRIORITY_APPLICATION);
add_action_entries (action_entries, this);
diff --git a/src/nibbles-window.vala b/src/nibbles-window.vala
index e059608..1dd3d9d 100644
--- a/src/nibbles-window.vala
+++ b/src/nibbles-window.vala
@@ -18,7 +18,7 @@
using Gtk;
-[GtkTemplate (ui = "/org/gnome/nibbles/ui/nibbles.ui")]
+[GtkTemplate (ui = "/org/gnome/Nibbles/ui/nibbles.ui")]
private class NibblesWindow : ApplicationWindow
{
/* Application and worm settings */
@@ -948,7 +948,7 @@ private class NibblesWindow : ApplicationWindow
}
}
-[GtkTemplate (ui = "/org/gnome/nibbles/ui/first-run.ui")]
+[GtkTemplate (ui = "/org/gnome/Nibbles/ui/first-run.ui")]
private class FirstRun : Box
{
}
diff --git a/src/players.vala b/src/players.vala
index b81e6ba..9198412 100644
--- a/src/players.vala
+++ b/src/players.vala
@@ -18,7 +18,7 @@
using Gtk;
-[GtkTemplate (ui = "/org/gnome/nibbles/ui/players.ui")]
+[GtkTemplate (ui = "/org/gnome/Nibbles/ui/players.ui")]
private class Players : Box
{
[GtkChild] private ToggleButton worms4;
diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala
index d4eb850..216a1e2 100644
--- a/src/preferences-dialog.vala
+++ b/src/preferences-dialog.vala
@@ -18,7 +18,7 @@
using Gtk;
-[GtkTemplate (ui = "/org/gnome/nibbles/ui/preferences-dialog.ui")]
+[GtkTemplate (ui = "/org/gnome/Nibbles/ui/preferences-dialog.ui")]
private class PreferencesDialog : Window
{
private GLib.Settings settings;
diff --git a/src/scoreboard.vala b/src/scoreboard.vala
index 7c6b13d..f5e9640 100644
--- a/src/scoreboard.vala
+++ b/src/scoreboard.vala
@@ -18,7 +18,7 @@
using Gtk;
-[GtkTemplate (ui = "/org/gnome/nibbles/ui/scoreboard.ui")]
+[GtkTemplate (ui = "/org/gnome/Nibbles/ui/scoreboard.ui")]
private class Scoreboard : Box
{
private Gee.HashMap<PlayerScoreBox, Worm> boxes = new Gee.HashMap<PlayerScoreBox, Worm> ();
@@ -56,7 +56,7 @@ private class Scoreboard : Box
}
}
-[GtkTemplate (ui = "/org/gnome/nibbles/ui/player-score-box.ui")]
+[GtkTemplate (ui = "/org/gnome/Nibbles/ui/player-score-box.ui")]
private class PlayerScoreBox : Box
{
[GtkChild] private Label name_label;
diff --git a/src/speed.vala b/src/speed.vala
index b8737d4..86f9b6c 100644
--- a/src/speed.vala
+++ b/src/speed.vala
@@ -19,7 +19,7 @@
using Gtk;
-[GtkTemplate (ui = "/org/gnome/nibbles/ui/speed.ui")]
+[GtkTemplate (ui = "/org/gnome/Nibbles/ui/speed.ui")]
private class Speed : Box
{
private SimpleAction speed_action;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]