[gnome-chess/gnome-3-8] Claim Draw: set sensitive only if draw can be claimed



commit 694d454a9ee3b84c400b4cae28330e193dd34dcf
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Tue Aug 13 10:55:58 2013 -0500

    Claim Draw: set sensitive only if draw can be claimed
    
    Since Claim Draw provides no user feedback when a draw cannot be
    claimed, we should not let the user select this item at all unless it
    will work.  This is for the stable branch only; for master, we want to
    actually display an informative dialog to explain what's wrong.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=703841

 src/chess-game.vala  |    2 +-
 src/gnome-chess.vala |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/chess-game.vala b/src/chess-game.vala
index 8a2451e..6fe1010 100644
--- a/src/chess-game.vala
+++ b/src/chess-game.vala
@@ -1468,7 +1468,7 @@ public class ChessGame
         ended ();
     }
 
-    private bool is_three_fold_repeat ()
+    public bool is_three_fold_repeat ()
     {
         foreach (var state in move_stack)
         {
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 033e20c..c607a23 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -861,7 +861,8 @@ public class Application : Gtk.Application
     {
         var can_resign = game.n_moves > 0 && game.current_player != opponent;
         resign_menu.sensitive = resign_button.sensitive = can_resign;
-        claim_draw_menu.sensitive = can_resign;
+        claim_draw_menu.sensitive = (game.current_state.halfmove_clock >= 100
+                                        || game.is_three_fold_repeat ());
 
         /* Can undo once the human player has made a move */
         var can_undo = game.n_moves > 0;


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