[gnome-chess] Do not directly pause/unpause the chess clock
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Do not directly pause/unpause the chess clock
- Date: Sun, 6 Jul 2014 17:11:10 +0000 (UTC)
commit a4148ca589e02caa4cede986b8c5f8413506fd67
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Jul 6 12:07:40 2014 -0500
Do not directly pause/unpause the chess clock
https://bugzilla.gnome.org/show_bug.cgi?id=728202
lib/chess-game.vala | 5 ++++-
src/chess-view.vala | 4 ++--
src/gnome-chess.vala | 15 ++++-----------
3 files changed, 10 insertions(+), 14 deletions(-)
---
diff --git a/lib/chess-game.vala b/lib/chess-game.vala
index e3e1ea0..d88b8b7 100644
--- a/lib/chess-game.vala
+++ b/lib/chess-game.vala
@@ -51,6 +51,7 @@ public class ChessGame : Object
public signal void ended ();
public bool is_paused { get; private set; default = false; }
+ public bool should_show_paused_overlay { get; private set; default = false; }
public ChessState current_state
{
@@ -298,12 +299,13 @@ public class ChessGame : Object
get { return move_stack.length() - 1; }
}
- public void pause ()
+ public void pause (bool show_overlay = true)
{
if (clock != null && result == ChessResult.IN_PROGRESS && !is_paused)
{
clock.pause ();
is_paused = true;
+ should_show_paused_overlay = show_overlay;
paused ();
}
}
@@ -314,6 +316,7 @@ public class ChessGame : Object
{
clock.unpause ();
is_paused = false;
+ should_show_paused_overlay = false;
unpaused ();
}
}
diff --git a/src/chess-view.vala b/src/chess-view.vala
index c2dc394..a8f3f29 100644
--- a/src/chess-view.vala
+++ b/src/chess-view.vala
@@ -213,7 +213,7 @@ public class ChessView : Gtk.DrawingArea
}
/* Draw pause overlay */
- if (scene.game.is_paused)
+ if (scene.game.should_show_paused_overlay)
{
c.rotate (Math.PI * scene.board_angle / 180.0);
draw_paused_overlay (c);
@@ -273,7 +273,7 @@ public class ChessView : Gtk.DrawingArea
public override bool button_press_event (Gdk.EventButton event)
{
- if (scene.game == null || event.button != 1 || scene.game.is_paused)
+ if (scene.game == null || event.button != 1 || scene.game.should_show_paused_overlay)
return false;
int file = (int) Math.floor((event.x - 0.5 * get_allocated_width () + square_size * 4) /
square_size);
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 7c9e215..be08214 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -1381,9 +1381,7 @@ public class ChessApplication : Gtk.Application
private void present_claim_draw_dialog ()
requires (game.can_claim_draw ())
{
- /* Manually since we don't want to show the pause overlay */
- if (game.clock != null)
- game.clock.pause ();
+ game.pause (false);
var dialog = new Gtk.MessageDialog (window,
Gtk.DialogFlags.MODAL,
@@ -1426,9 +1424,7 @@ public class ChessApplication : Gtk.Application
{
/* Display this dialog only once per game */
allow_claim_draw_dialog = false;
-
- if (game.clock != null)
- game.clock.unpause ();
+ game.unpause ();
}
}
@@ -1440,9 +1436,7 @@ public class ChessApplication : Gtk.Application
public void resign_cb ()
{
- /* Manually since we don't want to show the pause overlay */
- if (game.clock != null)
- game.clock.pause ();
+ game.pause (false);
var dialog = new Gtk.MessageDialog (window,
Gtk.DialogFlags.MODAL,
@@ -1471,8 +1465,7 @@ public class ChessApplication : Gtk.Application
}
else
{
- if (game.clock != null)
- game.clock.unpause ();
+ game.unpause ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]