[gnome-klotski] Use a Game menu.



commit 635f869e3dec1044ab6786d8580f566938f3a428
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed May 6 07:29:32 2020 +0200

    Use a Game menu.

 data/klotski.ui         | 25 +++++++++++++++++--------
 src/klotski-window.vala |  6 +++++-
 2 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/data/klotski.ui b/data/klotski.ui
index 763670d..7de3282 100644
--- a/data/klotski.ui
+++ b/data/klotski.ui
@@ -17,7 +17,7 @@
 -->
 <interface>
   <requires lib="gtk+" version="3.12"/>
-  <menu id="app-menu">
+  <menu id="main-menu">
     <section>
       <item>
         <!-- Translators: label of an entry in the Hamburger menu (with a mnemonic that appears pressing 
Alt); opens the Scores dialog -->
@@ -38,6 +38,17 @@
       </item>
     </section>
   </menu>
+  <menu id="game-menu">
+    <section>
+      <item>
+        <!-- Translators: label of an entry in the game menu (with a mnemonic that appears pressing Alt); 
allows to directly restart the current puzzle -->
+        <attribute name="label" translatable="yes">_Start Over</attribute>
+        <attribute name="action">win.start-game</attribute>
+        <!-- Translators: tooltip text of the Start Over button, in the headerbar -->
+<!--        <property name="tooltip-text" translatable="yes">Restart the current puzzle</property>-->
+      </item>
+    </section>
+  </menu>
   <object class="GtkPopover" id="puzzles_popover">
     <property name="visible">False</property>
     <property name="name">puzzles-popover</property>
@@ -337,17 +348,15 @@
           </object>
         </child>
         <child>
-          <object class="GtkButton">
+          <object class="GtkMenuButton" id="game_menubutton">
             <property name="visible">True</property>
             <property name="valign">center</property>
-            <property name="use-underline">True</property>
-            <!-- Translators: in the headerbar, button that allows to directly restart the current puzzle 
(with a mnemonic that appears pressing Alt) -->
-            <property name="label" translatable="yes">_Start Over</property>
+            <property name="label">0</property>
             <property name="can-focus">True</property>
             <property name="focus-on-click">False</property>
             <!-- Translators: tooltip text of the Start Over button, in the headerbar -->
-            <property name="tooltip-text" translatable="yes">Restart the current puzzle</property>
-            <property name="action-name">win.start-game</property>
+            <property name="tooltip-text" translatable="yes">Moves counter</property>
+            <property name="menu-model">game-menu</property>
           </object>
           <packing>
             <property name="pack-type">end</property>
@@ -358,7 +367,7 @@
             <property name="visible">True</property>
             <property name="valign">center</property>
             <property name="can_focus">True</property>
-            <property name="menu-model">app-menu</property>
+            <property name="menu-model">main-menu</property>
             <child>
               <object class="GtkImage">
                 <property name="visible">True</property>
diff --git a/src/klotski-window.vala b/src/klotski-window.vala
index b89762e..4da5a65 100644
--- a/src/klotski-window.vala
+++ b/src/klotski-window.vala
@@ -48,6 +48,7 @@ private class KlotskiWindow : ApplicationWindow
     [GtkChild] private Stack stack_packs;
     [GtkChild] private Stack stack_puzzles;
     [GtkChild] private Popover puzzles_popover;
+    [GtkChild] private MenuButton game_menubutton;
     private PuzzleView view;
 
     [GtkChild] private TreeView treeview_huarong;
@@ -847,7 +848,9 @@ private class KlotskiWindow : ApplicationWindow
         view.puzzle = puzzle;
 
         update_moves_label ();
+        game_menubutton.active = false;
         start_game.set_enabled (false);
+        game_menubutton.sensitive = false;
     }
 
     private void puzzle_moved_cb ()
@@ -858,8 +861,9 @@ private class KlotskiWindow : ApplicationWindow
     private void update_moves_label ()
     {
         start_game.set_enabled (true);
+        game_menubutton.sensitive = true;
         /* Translators: headerbar subtitle; the %d is replaced by the number of moves already done in the 
current game */
-        headerbar.set_subtitle (_("Moves: %d").printf (puzzle.moves));
+        game_menubutton.set_label (puzzle.moves.to_string ());
         if (puzzle.game_over ())
         {
             /* Translators: headerbar title, when the puzzle is solved */


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