[gnome-tetravex] Add a warning dialog when using solve game



commit 689e657b6e3cf63863736f11f500342f62f36151
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Fri May 30 21:38:20 2014 -0500

    Add a warning dialog when using solve game
    
    Since this ends the user's game, he should have a chance to change his
    mind.

 src/gnome-tetravex.vala |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/gnome-tetravex.vala b/src/gnome-tetravex.vala
index a197381..2388485 100644
--- a/src/gnome-tetravex.vala
+++ b/src/gnome-tetravex.vala
@@ -310,11 +310,25 @@ public class Tetravex : Gtk.Application
 
     private void solve_cb ()
     {
-        puzzle.solve ();
-        new_game_solve_stack.set_visible_child_name ("new-game");
+        var dialog = new Gtk.MessageDialog (window,
+                                            Gtk.DialogFlags.MODAL,
+                                            Gtk.MessageType.QUESTION,
+                                            Gtk.ButtonsType.NONE,
+                                            _("Are you sure you want to give up and view the solution?"));
 
-        var pause = lookup_action ("pause") as SimpleAction;
-        pause.set_enabled (false);
+        dialog.add_buttons (_("_Keep Playing"), Gtk.ResponseType.REJECT,
+                            _("_Give Up"), Gtk.ResponseType.ACCEPT,
+                            null);
+
+        var response = dialog.run ();
+        dialog.destroy ();
+
+        if (response == Gtk.ResponseType.ACCEPT)
+        {
+            puzzle.solve ();
+            new_game_solve_stack.set_visible_child_name ("new-game");
+            ((SimpleAction) lookup_action ("pause")).set_enabled (false);
+        }
     }
     
     private void help_cb ()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]