[gnome-taquin] Show game name when playing.



commit 476841e6ee87cae1ced2e8ad2a6256e08e5b8b6a
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Dec 4 10:04:17 2019 +0100

    Show game name when playing.

 src/game-headerbar.vala | 10 ++++++++--
 src/game-window.vala    |  6 ++++++
 src/taquin-main.vala    |  5 +++++
 3 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/game-headerbar.vala b/src/game-headerbar.vala
index 1a69d12..fcd521d 100644
--- a/src/game-headerbar.vala
+++ b/src/game-headerbar.vala
@@ -27,8 +27,8 @@ private class GameHeaderBar : BaseHeaderBar, AdaptativeWidget
     [GtkChild] private Button       new_game_button;
     [GtkChild] private Button       back_button;
 
-    [CCode (notify = false)] public bool window_has_name { private get; protected construct; default = 
false; }
-    [CCode (notify = false)] public string window_name   { private get; internal  construct; default = ""; }
+    [CCode (notify = false)] public bool window_has_name { private get; protected construct    ; default = 
false; }
+    [CCode (notify = false)] public string window_name   { private get; protected construct set; default = 
""; }
 
     [CCode (notify = false)] public bool has_sound { private get; protected construct; default = false; }
     [CCode (notify = false)] public bool show_undo { private get; protected construct; default = false; }
@@ -164,6 +164,12 @@ private class GameHeaderBar : BaseHeaderBar, AdaptativeWidget
         last_moves_count = moves_count;
     }
 
+    internal void update_title (string new_title)
+    {
+        window_name = new_title;
+        set_default_widgets_default_states (this);
+    }
+
     /*\
     * * hamburger menu
     \*/
diff --git a/src/game-window.vala b/src/game-window.vala
index 67cc958..fcae467 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -132,6 +132,11 @@ private class GameWindow : BaseWindow, AdaptativeWidget
         back ();
     }
 
+    internal void set_title (string game_name)
+    {
+        headerbar.update_title (game_name);
+    }
+
     /*\
     * * showing the stack
     \*/
@@ -139,6 +144,7 @@ private class GameWindow : BaseWindow, AdaptativeWidget
     private void show_new_game_screen ()
     {
         hide_notification ();
+        headerbar.update_title (Taquin.PROGRAM_NAME);
         bool grabs_focus = headerbar.show_new_game_screen (game_finished);
         game_view.show_new_game_box (/* grab focus */ !grabs_focus);
     }
diff --git a/src/taquin-main.vala b/src/taquin-main.vala
index 88c2d37..cd3dcb2 100644
--- a/src/taquin-main.vala
+++ b/src/taquin-main.vala
@@ -286,6 +286,11 @@ private class Taquin : Gtk.Application, BaseApplication
         GameType type = (GameType) settings.get_enum ("type");
         int8 size = (int8) settings.get_int ("size"); /* 2 <= size <= 9 */
         game = new Game (type, size);
+        /* Translators: name of one of the games, as displayed in the headerbar when playing */
+        window.set_title (type == GameType.FIFTEEN ? _("15-Puzzle")
+
+        /* Translators: name of one of the games, as displayed in the headerbar when playing */
+                                                   : _("16-Puzzle"));
         view.game = (!) game;
         window.move_done (0);
         move_done = false;


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