[gnome-mahjongg] Use reasonable response types for the no moves left dialog



commit 61166c87b76d2659203b708c25d803773b505576
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Aug 17 14:17:03 2014 -0500

    Use reasonable response types for the no moves left dialog
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732225

 src/gnome-mahjongg.vala |   30 ++++++++++++++++++++----------
 1 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/src/gnome-mahjongg.vala b/src/gnome-mahjongg.vala
index c02d8e4..6e3d11e 100644
--- a/src/gnome-mahjongg.vala
+++ b/src/gnome-mahjongg.vala
@@ -356,6 +356,14 @@ public class Mahjongg : Gtk.Application
         settings.set_string ("mapset", maps.nth_data (widget.active).name);
     }
 
+    enum NoMovesDialogResponse
+    {
+        UNDO,
+        SHUFFLE,
+        RESTART,
+        NEW_GAME
+    }
+
     private void moved_cb ()
     {
         update_ui ();
@@ -380,27 +388,29 @@ public class Mahjongg : Gtk.Application
                                                 Gtk.ButtonsType.NONE,
                                                 "%s", _("There are no more moves."));
             dialog.format_secondary_text (_("Each puzzle has at least one solution.  You can undo your moves 
and try and find the solution, restart this game, or start a new one. You can also try to reshuffle the game, 
but this does not guarantee a solution."));
-            dialog.add_buttons (_("_Undo"), Gtk.ResponseType.REJECT,
-                                _("_Restart"), Gtk.ResponseType.CANCEL,
-                                _("_New game"), Gtk.ResponseType.ACCEPT,
-                                _("_Shuffle"), Gtk.ResponseType.DELETE_EVENT);
+            dialog.add_buttons (_("_Undo"), NoMovesDialogResponse.UNDO,
+                                _("_Restart"), NoMovesDialogResponse.RESTART,
+                                _("_New game"), NoMovesDialogResponse.NEW_GAME,
+                                _("_Shuffle"), NoMovesDialogResponse.SHUFFLE);
 
-            dialog.set_default_response (Gtk.ResponseType.ACCEPT);
             switch (dialog.run ())
             {
-            case Gtk.ResponseType.REJECT:
+            case NoMovesDialogResponse.UNDO:
                 undo_cb ();
                 break;
-            case Gtk.ResponseType.DELETE_EVENT:
+            case NoMovesDialogResponse.SHUFFLE:
                 shuffle_cb ();
                 break;
-            case Gtk.ResponseType.CANCEL:
+            case NoMovesDialogResponse.RESTART:
                 restart_game ();
                 break;
-            default:
-            case Gtk.ResponseType.ACCEPT:
+            case NoMovesDialogResponse.NEW_GAME:
                 new_game ();
                 break;
+            case Gtk.ResponseType.DELETE_EVENT:
+                break;
+            default:
+                assert_not_reached ();
             }
             dialog.destroy ();
         }


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