[gnome-chess] Handle pause correctly before the game has started
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Handle pause correctly before the game has started
- Date: Sat, 3 Aug 2013 19:28:56 +0000 (UTC)
commit 6d95ad3b3ae82eede021a3cdd0391a29f7f001a1
Author: Michael Catanzaro <mike catanzaro gmail com>
Date: Sat Aug 3 14:06:55 2013 -0500
Handle pause correctly before the game has started
Since the clock doesn't start until after White's first move, it
shouldn't be possible to pause/unpause the game during this time,
either. This means the pause button must be insensitive, and we don't
want to see any warnings if we unfocus the window prior to making the
first move.
src/chess-clock.vala | 2 +-
src/gnome-chess.vala | 11 ++++++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/chess-clock.vala b/src/chess-clock.vala
index 7fb70c3..7487a58 100644
--- a/src/chess-clock.vala
+++ b/src/chess-clock.vala
@@ -81,7 +81,7 @@ public class ChessClock : Object
private bool is_active
{
- get { return expire_timeout_id != 0; }
+ get { return timer != null && expire_timeout_id != 0; }
}
public void start ()
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index b7183fe..453c4ff 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -495,7 +495,6 @@ public class Application : Gtk.Application
scene.game = game;
info_bar.hide ();
save_button.sensitive = false;
- pause_button.sensitive = (game.clock != null);
update_history_panel ();
update_control_buttons ();
@@ -564,7 +563,14 @@ public class Application : Gtk.Application
game.start ();
if (moves.length > 0 && game.clock != null)
+ {
game.clock.start ();
+ pause_button.sensitive = true;
+ }
+ else
+ {
+ pause_button.sensitive = false;
+ }
if (game.result != ChessResult.IN_PROGRESS)
game_end_cb (game);
@@ -673,6 +679,9 @@ public class Application : Gtk.Application
private void game_turn_cb (ChessGame game, ChessPlayer player)
{
+ if (game.clock != null)
+ pause_button.sensitive = true;
+
if (game.is_started && opponent_engine != null && player == opponent)
opponent_engine.request_move ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]