[gnome-tetravex] Disable some actions on finish.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tetravex] Disable some actions on finish.
- Date: Mon, 16 Sep 2019 17:58:38 +0000 (UTC)
commit 3ebab9303273038fe8ff6a9c99a29c07b4d2487d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Mon Sep 16 19:58:03 2019 +0200
Disable some actions on finish.
Commit a2c861ceab causes some
problems, as it does allow to
click "solve" or "pause" even
with the game finished. Oops.
src/gnome-tetravex.vala | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/gnome-tetravex.vala b/src/gnome-tetravex.vala
index 8cb0b50..c0fe670 100644
--- a/src/gnome-tetravex.vala
+++ b/src/gnome-tetravex.vala
@@ -35,6 +35,9 @@ private class Tetravex : Gtk.Application
private Stack new_game_solve_stack;
private Stack play_pause_stack;
+ private SimpleAction solve_action;
+ private SimpleAction pause_action;
+
private const OptionEntry[] option_entries =
{
{ "version", 'v', 0, OptionArg.NONE, null, N_("Print release version and exit"), null },
@@ -115,6 +118,9 @@ private class Tetravex : Gtk.Application
game_size = settings.get_int (KEY_GRID_SIZE);
(lookup_action ("size") as SimpleAction).set_state ("%d".printf (game_size));
+ pause_action = (SimpleAction) lookup_action ("pause");
+ solve_action = (SimpleAction) lookup_action ("solve");
+
HeaderBar headerbar = new HeaderBar ();
headerbar.title = _("Tetravex");
headerbar.show_close_button = true;
@@ -273,9 +279,9 @@ private class Tetravex : Gtk.Application
private void new_game ()
{
- SimpleAction pause = lookup_action ("pause") as SimpleAction;
- pause.change_state (false);
- pause.set_enabled (true);
+ pause_action.change_state (false);
+ pause_action.set_enabled (true);
+ solve_action.set_enabled (true);
new_game_solve_stack.set_visible_child_name ("solve");
if (puzzle != null)
@@ -318,6 +324,9 @@ private class Tetravex : Gtk.Application
history.add (entry);
history.save ();
+ pause_action.set_enabled (false);
+ solve_action.set_enabled (false);
+
int score_dialog_action = show_scores (entry, true);
if (score_dialog_action == ResponseType.CLOSE)
window.destroy ();
@@ -379,7 +388,7 @@ private class Tetravex : Gtk.Application
{
puzzle.solve ();
new_game_solve_stack.set_visible_child_name ("new-game");
- ((SimpleAction) lookup_action ("pause")).set_enabled (false);
+ pause_action.set_enabled (false);
}
}
@@ -473,7 +482,7 @@ private class Tetravex : Gtk.Application
private void update_button_states ()
{
- ((SimpleAction) lookup_action ("solve")).set_enabled (!puzzle.paused);
+ solve_action.set_enabled (!puzzle.paused);
play_pause_stack.set_visible_child_name (puzzle.paused ? "play" : "pause");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]