[gnome-tetravex] Improve hamburger menu.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tetravex] Improve hamburger menu.
- Date: Thu, 7 May 2020 09:10:46 +0000 (UTC)
commit 8b487c11b7ca15f00f53c0784367abe57fa5d633
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu May 7 11:08:09 2020 +0200
Improve hamburger menu.
One more click, but
a better behaviour.
src/app-menu.ui | 81 +++++++++++++++++++++++++++----------------------
src/gnome-tetravex.vala | 38 ++++++-----------------
2 files changed, 54 insertions(+), 65 deletions(-)
---
diff --git a/src/app-menu.ui b/src/app-menu.ui
index e655f7c..16f8d8f 100644
--- a/src/app-menu.ui
+++ b/src/app-menu.ui
@@ -23,43 +23,6 @@
<attribute name="label" translatable="yes">_New Game</attribute>
<attribute name="action">app.new-game</attribute>
</item>
- <item>
- <!-- Translators: entry of the hamburger menu (with a mnemonic that appears when pressing Alt);
displays Scores dialog -->
- <attribute name="label" translatable="yes">_Scores</attribute>
- <attribute name="action">app.scores</attribute>
- </item>
- <submenu>
- <!-- Translators: entry of the hamburger menu (with a mnemonic that appears when pressing Alt);
displays allows to change the theme -->
- <attribute name="label" translatable="yes">A_ppearance</attribute>
- <section>
- <item>
- <!-- Translators: entry of the Appearance submenu of the hamburger menu (with a mnemonic that
appears when pressing Alt); set theme to Adwaita; other possible themes are Neo_Retro, _Nostalgia and
_Synesthesia -->
- <attribute name="label" translatable="yes">_Extrusion</attribute>
- <attribute name="action">app.theme</attribute>
- <attribute name="target">extrusion</attribute>
- </item>
- <item>
- <!-- Translators: entry of the Appearance submenu of the hamburger menu (with a mnemonic that
appears when pressing Alt); set theme to NeoRetro; other possible themes are _Extrusion, _Nostalgia and
_Synesthesia -->
- <attribute name="label" translatable="yes">Neo_Retro</attribute>
- <attribute name="action">app.theme</attribute>
- <attribute name="target">neoretro</attribute>
- </item>
- <item>
- <!-- Translators: entry of the Appearance submenu of the hamburger menu (with a mnemonic that
appears when pressing Alt); set theme to Nostalgia; other possible themes are _Extrusion, Neo_Retro and
_Synesthesia -->
- <attribute name="label" translatable="yes">_Nostalgia</attribute>
- <attribute name="action">app.theme</attribute>
- <attribute name="target">nostalgia</attribute>
- </item>
- <item>
- <!-- Translators: entry of the Appearance submenu of the hamburger menu (with a mnemonic that
appears when pressing Alt); set theme to Synesthesia; other possible themes are _Extrusion, Neo_Retro and
_Nostalgia -->
- <attribute name="label" translatable="yes">_Synesthesia</attribute>
- <attribute name="action">app.theme</attribute>
- <attribute name="target">synesthesia</attribute>
- </item>
- </section>
- </submenu>
- </section>
- <section>
<submenu>
<!-- Translators: submenu of the hamburger menu (with a mnemonic that appears when pressing Alt);
allows to change the size of the board -->
<attribute name="label" translatable="yes">Si_ze</attribute>
@@ -95,6 +58,50 @@
<attribute name="target">6</attribute>
</item>
</section>
+ <section>
+ <item>
+ <!-- Translators: entry of the Size submenu of the hamburger menu (with a mnemonic that appears
when pressing Alt); starts a new game -->
+ <attribute name="label" translatable="yes">_New Game</attribute>
+ <attribute name="action">app.new-game</attribute>
+ </item>
+ </section>
+ </submenu>
+ </section>
+ <section>
+ <item>
+ <!-- Translators: entry of the hamburger menu (with a mnemonic that appears when pressing Alt);
displays Scores dialog -->
+ <attribute name="label" translatable="yes">_Scores</attribute>
+ <attribute name="action">app.scores</attribute>
+ </item>
+ <submenu>
+ <!-- Translators: entry of the hamburger menu (with a mnemonic that appears when pressing Alt);
displays allows to change the theme -->
+ <attribute name="label" translatable="yes">A_ppearance</attribute>
+ <section>
+ <item>
+ <!-- Translators: entry of the Appearance submenu of the hamburger menu (with a mnemonic that
appears when pressing Alt); set theme to Adwaita; other possible themes are Neo_Retro, _Nostalgia and
_Synesthesia -->
+ <attribute name="label" translatable="yes">_Extrusion</attribute>
+ <attribute name="action">app.theme</attribute>
+ <attribute name="target">extrusion</attribute>
+ </item>
+ <item>
+ <!-- Translators: entry of the Appearance submenu of the hamburger menu (with a mnemonic that
appears when pressing Alt); set theme to NeoRetro; other possible themes are _Extrusion, _Nostalgia and
_Synesthesia -->
+ <attribute name="label" translatable="yes">Neo_Retro</attribute>
+ <attribute name="action">app.theme</attribute>
+ <attribute name="target">neoretro</attribute>
+ </item>
+ <item>
+ <!-- Translators: entry of the Appearance submenu of the hamburger menu (with a mnemonic that
appears when pressing Alt); set theme to Nostalgia; other possible themes are _Extrusion, Neo_Retro and
_Synesthesia -->
+ <attribute name="label" translatable="yes">_Nostalgia</attribute>
+ <attribute name="action">app.theme</attribute>
+ <attribute name="target">nostalgia</attribute>
+ </item>
+ <item>
+ <!-- Translators: entry of the Appearance submenu of the hamburger menu (with a mnemonic that
appears when pressing Alt); set theme to Synesthesia; other possible themes are _Extrusion, Neo_Retro and
_Nostalgia -->
+ <attribute name="label" translatable="yes">_Synesthesia</attribute>
+ <attribute name="action">app.theme</attribute>
+ <attribute name="target">synesthesia</attribute>
+ </item>
+ </section>
</submenu>
</section>
<section>
diff --git a/src/gnome-tetravex.vala b/src/gnome-tetravex.vala
index b68cd94..7f888f7 100644
--- a/src/gnome-tetravex.vala
+++ b/src/gnome-tetravex.vala
@@ -603,7 +603,7 @@ private class Tetravex : Gtk.Application
can_restore = false;
}
- private void new_game (Variant? saved_game = null)
+ private void new_game (Variant? saved_game = null, int? given_size = null)
{
puzzle_is_finished = false;
has_been_finished = false;
@@ -626,7 +626,11 @@ private class Tetravex : Gtk.Application
if (saved_game == null)
{
- int size = settings.get_int (KEY_GRID_SIZE);
+ int size;
+ if (given_size == null)
+ size = settings.get_int (KEY_GRID_SIZE);
+ else
+ size = (!) given_size;
puzzle = new Puzzle ((uint8) size, (uint8) colors);
clock_box.show ();
}
@@ -759,14 +763,15 @@ private class Tetravex : Gtk.Application
private void new_game_cb ()
{
+ int size = settings.get_int (KEY_GRID_SIZE);
if (puzzle.game_in_progress && !puzzle.is_solved)
{
MessageDialog dialog = new MessageDialog (window,
DialogFlags.MODAL | DialogFlags.DESTROY_WITH_PARENT,
MessageType.QUESTION,
ButtonsType.NONE,
- /* Translators: popup dialog main text; appearing when user clicks "New Game" from the hamburger
menu, while a game is started; possible answers are "Keep playing"/"Start New Game" */
- _("Are you sure you want to start a new game with same
board size?"));
+ /* Translators: popup dialog main text; appearing when user clicks "New Game" from the hamburger
menu, while a game is started; possible answers are "Keep playing"/"Start New Game"; the %d are both replaced
with */
+ _("Are you sure you want to start a new %u × %u
game?").printf (size, size));
/* Translators: popup dialog possible answer (with a mnemonic that appears pressing Alt); appearing
when user clicks "New Game" from the hamburger menu; other possible answer is "_Start New Game" */
dialog.add_buttons (_("_Keep Playing"), ResponseType.REJECT,
@@ -780,7 +785,7 @@ private class Tetravex : Gtk.Application
if (response != ResponseType.ACCEPT)
return;
}
- new_game ();
+ new_game (/* saved game */ null, size);
}
private HistoryEntry? last_history_entry = null;
@@ -861,31 +866,8 @@ private class Tetravex : Gtk.Application
if (size == settings.get_int (KEY_GRID_SIZE))
return;
- if (puzzle.game_in_progress && !puzzle.is_solved)
- {
- MessageDialog dialog = new MessageDialog (window,
- DialogFlags.MODAL | DialogFlags.DESTROY_WITH_PARENT,
- MessageType.QUESTION,
- ButtonsType.NONE,
- /* Translators: popup dialog main text; appearing when user changes size from the hamburger menu
submenu, while a game is started; possible answers are "Keep playing"/"Start New Game" */
- _("Are you sure you want to start a new game with a
different board size?"));
-
- /* Translators: popup dialog possible answer (with a mnemonic that appears pressing Alt); appearing
when user changes size from the hamburger menu submenu, while a game is started; other possible answer is
"_Start New Game" */
- dialog.add_buttons (_("_Keep Playing"), ResponseType.REJECT,
-
- /* Translators: popup dialog possible answer (with a mnemonic that appears pressing Alt); appearing
when user changes size from the hamburger menu submenu, while a game is started; other possible answer is
"_Keep Playing" */
- _("_Start New Game"), ResponseType.ACCEPT);
-
- int response = dialog.run ();
- dialog.destroy ();
-
- if (response != ResponseType.ACCEPT)
- return;
- hamburger_button.set_active (false);
- }
settings.set_int (KEY_GRID_SIZE, size);
action.set_state (variant);
- new_game ();
}
private void move_up_l () { view.move_up (/* left board */ true); }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]