[gnome-tetravex] Disable pause button before game has started
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tetravex] Disable pause button before game has started
- Date: Sat, 15 Feb 2014 18:18:47 +0000 (UTC)
commit c197193a3a4ae1a149ed0d03cbdb84f0f7ce4411
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sat Feb 15 12:18:09 2014 -0600
Disable pause button before game has started
https://bugzilla.gnome.org/show_bug.cgi?id=724221
src/gnome-tetravex.vala | 11 ++++++-----
src/puzzle-view.vala | 4 ++++
2 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/gnome-tetravex.vala b/src/gnome-tetravex.vala
index 5adce94..8d394d4 100644
--- a/src/gnome-tetravex.vala
+++ b/src/gnome-tetravex.vala
@@ -208,6 +208,11 @@ public class Tetravex : Gtk.Application
private void new_game ()
{
+ var pause = lookup_action ("pause") as SimpleAction;
+ pause.change_state (false);
+ pause.set_enabled (false);
+ new_game_solve_stack.set_visible_child_name ("solve");
+
if (puzzle != null)
SignalHandler.disconnect_by_func (puzzle, null, this);
@@ -215,14 +220,10 @@ public class Tetravex : Gtk.Application
puzzle = new Puzzle (size);
puzzle.tick.connect (tick_cb);
puzzle.solved.connect (solved_cb);
+ puzzle.tile_moved.connect (() => pause.set_enabled (true));
view.puzzle = puzzle;
tick_cb ();
- var pause = lookup_action ("pause") as SimpleAction;
- pause.change_state (false);
- pause.set_enabled (true);
- new_game_solve_stack.set_visible_child_name ("solve");
-
update_button_states ();
}
diff --git a/src/puzzle-view.vala b/src/puzzle-view.vala
index 96ab5a4..f3ae683 100644
--- a/src/puzzle-view.vala
+++ b/src/puzzle-view.vala
@@ -92,6 +92,9 @@ public class PuzzleView : Gtk.DrawingArea
private Timer animation_timer;
private uint animation_timeout = 0;
+ /* Emitted when a tile is moved */
+ public signal void tile_moved ();
+
public PuzzleView ()
{
set_events (Gdk.EventMask.EXPOSURE_MASK | Gdk.EventMask.BUTTON_PRESS_MASK |
Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK);
@@ -229,6 +232,7 @@ public class PuzzleView : Gtk.DrawingArea
private void tile_moved_cb (Puzzle puzzle, Tile tile, uint x, uint y)
{
move_tile_to_location (tiles.lookup (tile), x, y, 0.2);
+ tile_moved ();
}
public override bool configure_event (Gdk.EventConfigure event)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]