[gnome-2048/arnaudb/wip/gtk4: 30/48] Do not use headerbar subtitle.




commit cb066ea5f96f62e6f133b537f5b40ce9816e0c2b
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon Jul 13 16:53:33 2020 +0200

    Do not use headerbar subtitle.

 data/mainwindow.ui      |  6 ++++++
 src/game-headerbar.vala | 13 -------------
 src/game-window.vala    |  7 ++++---
 3 files changed, 10 insertions(+), 16 deletions(-)
---
diff --git a/data/mainwindow.ui b/data/mainwindow.ui
index 8ecadb3..7db0bb1 100644
--- a/data/mainwindow.ui
+++ b/data/mainwindow.ui
@@ -32,6 +32,12 @@
         <child>
           <object class="GtkAspectFrame" id="_frame"/>
         </child>
+        <child type="overlay">
+          <object class="GtkLabel" id="_gameover_label">
+            <property name="visible">False</property>
+            <property name="label" translatable="yes">Game Over</property>
+          </object>
+        </child>
         <child type="overlay">
           <object class="GtkButton" id="_unfullscreen_button">
             <property name="visible">False</property>
diff --git a/src/game-headerbar.vala b/src/game-headerbar.vala
index 50e1fe5..4793915 100644
--- a/src/game-headerbar.vala
+++ b/src/game-headerbar.vala
@@ -59,19 +59,6 @@ private class GameHeaderBar : Widget
     * * texts
     \*/
 
-    internal void clear_subtitle ()
-    {
-        _headerbar.set_subtitle (null);
-        _headerbar.set_has_subtitle (false);
-    }
-
-    internal void finished ()
-    {
-        _headerbar.set_has_subtitle (true);
-        /* Translators: subtitle of the headerbar, when the user cannot move anymore */
-        _headerbar.subtitle = _("Game Over");
-    }
-
     internal void set_score (Object game, ParamSpec unused)
     {
         _score.label = ((Game) game).score.to_string ();
diff --git a/src/game-window.vala b/src/game-window.vala
index 13c0aad..af77582 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -31,6 +31,7 @@ private class GameWindow : ApplicationWindow
                private Game             _game;
 
     [GtkChild] private Button           _unfullscreen_button;
+    [GtkChild] private Label            _gameover_label;
 
     public uint8 cli_cols { private get; protected construct; default = 0; }
     public uint8 cli_rows { private get; protected construct; default = 0; }
@@ -95,7 +96,7 @@ private class GameWindow : ApplicationWindow
         _game = new Game (ref _settings);
         _game.notify ["score"].connect (_header_bar.set_score);
         _game.finished.connect ((show_scores) => {
-                _header_bar.finished ();
+                _gameover_label.show ();
 
                 if (show_scores)
                     _show_best_scores ();
@@ -257,14 +258,14 @@ private class GameWindow : ApplicationWindow
         if (!_settings.get_boolean ("allow-undo"))   // for the keyboard shortcut
             return;
 
-        _header_bar.clear_subtitle ();
+        _gameover_label.hide ();
         _game.undo ();
         _game.grab_focus ();
     }
 
     private void new_game_cb (/* SimpleAction action, Variant? variant */)
     {
-        _header_bar.clear_subtitle ();
+        _gameover_label.hide ();
         _game.new_game (ref _settings);
         _game.grab_focus ();
     }


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