[gnome-chess] Cancel move if promotion type selector is closed
- From: Sahil Sareen <ssareen src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Cancel move if promotion type selector is closed
- Date: Sun, 11 Jan 2015 18:25:09 +0000 (UTC)
commit ed9ffc4ba2147b252b22122ff6be35d5b894583b
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Jan 11 11:35:07 2015 -0600
Cancel move if promotion type selector is closed
https://bugzilla.gnome.org/show_bug.cgi?id=742762
src/chess-scene.vala | 6 ++++--
src/gnome-chess.vala | 7 ++-----
2 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/src/chess-scene.vala b/src/chess-scene.vala
index 640c528..9d9ea5e 100644
--- a/src/chess-scene.vala
+++ b/src/chess-scene.vala
@@ -77,7 +77,7 @@ public class ChessScene : Object
private double animation_time;
public signal bool is_human (ChessPlayer player);
- public signal PieceType choose_promotion_type ();
+ public signal PieceType? choose_promotion_type ();
public signal void changed ();
public int selected_rank = -1;
@@ -229,7 +229,9 @@ public class ChessScene : Object
(rank == 0 || rank == 7))
{
/* Prompt user for selecting promotion type */
- PieceType promotion_selection = choose_promotion_type ();
+ PieceType? promotion_selection = choose_promotion_type ();
+ if (promotion_selection == null)
+ return;
game.current_player.move_with_coords (selected_rank,
selected_file, rank, file, true, promotion_selection);
selected_rank = selected_file = -1;
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 65a3cd4..8887581 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -261,7 +261,7 @@ public class ChessApplication : Gtk.Application
window.show ();
}
- public PieceType show_promotion_type_selector ()
+ public PieceType? show_promotion_type_selector ()
{
Gtk.Builder promotion_type_selector_builder;
@@ -298,7 +298,7 @@ public class ChessApplication : Gtk.Application
promotion_type_selector_builder.connect_signals (this);
- PieceType selection;
+ PieceType? selection = null;
int choice = promotion_type_selector_dialog.run ();
switch (choice)
{
@@ -314,9 +314,6 @@ public class ChessApplication : Gtk.Application
case PromotionTypeSelected.BISHOP:
selection = PieceType.BISHOP;
break;
- default:
- selection = PieceType.QUEEN;
- break;
}
promotion_type_selector_dialog.destroy ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]