[iagno] Make an action private.



commit c7718ba21d7cfbbf7007efeeb8c29e1d638b9577
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Feb 28 14:55:37 2019 +0100

    Make an action private.

 src/game-window.vala | 13 +++++++++----
 src/iagno.vala       |  9 +++------
 2 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/src/game-window.vala b/src/game-window.vala
index 8c56d11..d7ec120 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -165,9 +165,8 @@ private class GameWindow : ApplicationWindow
     \*/
 
     private SimpleAction back_action;
-
-    internal SimpleAction undo_action;
- // internal SimpleAction redo_action;
+    private SimpleAction undo_action;
+ // private SimpleAction redo_action;
 
     private void install_ui_action_entries ()
     {
@@ -260,7 +259,13 @@ private class GameWindow : ApplicationWindow
         view.grab_focus ();
     }
 
-    internal void set_subtitle (string? subtitle)
+    internal void new_turn_start (bool can_undo)
+    {
+        undo_action.set_enabled (can_undo);
+        headerbar.set_subtitle (null);
+    }
+
+    internal void set_subtitle (string subtitle)
     {
         headerbar.set_subtitle (subtitle);
     }
diff --git a/src/iagno.vala b/src/iagno.vala
index 2d1fd95..e281175 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -379,21 +379,18 @@ private class Iagno : Gtk.Application
         else
             player_one = Player.DARK;
 
+        first_player_is_human = (player_one == Player.DARK) || (computer == null);
         update_ui ();
 
         if (player_one != Player.DARK && computer != null)
             ((!) computer).move_async.begin (MODERATE_MOVE_DELAY);     // TODO MODERATE_MOVE_DELAY = 1.0, 
but after the sliding animation…
     }
 
+    private bool first_player_is_human = false;
     private void update_ui ()
         requires (game_is_set)
     {
-        window.set_subtitle (null);
-
-        if (player_one == Player.DARK || computer == null)
-            window.undo_action.set_enabled (game.number_of_moves >= 1);
-        else
-            window.undo_action.set_enabled (game.number_of_moves >= 2);
+        window.new_turn_start (/* can undo */ first_player_is_human ? (game.number_of_moves >= 1) : 
(game.number_of_moves >= 2));
 
         /* Translators: this is a 2 digit representation of the current score. */
         dark_score_label.set_text (_("%.2d").printf (game.n_dark_tiles));


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