[hitori] On game over, prompt the user to play again



commit d2bf0676714bb1299766605d0a5efad3e365cd43
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Thu Jun 5 23:49:41 2014 -0500

    On game over, prompt the user to play again
    
    This allows us to simplify the UI by obviating the need to move the new
    game action from the app menu into the window. It's also simply more
    useful than an OK button.
    
    The user can instead choose to quit the app from this dialog. What a
    timesaver!
    
    https://bugzilla.gnome.org/show_bug.cgi?id=731314

 src/rules.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/rules.c b/src/rules.c
index 4749335..bde8f43 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -257,6 +257,7 @@ hitori_check_win (Hitori *hitori)
                /* Win! */
                GtkWidget *dialog;
                gchar *message;
+               gint ret;
 
                /* Tell the user they've won */
                hitori_disable_events (hitori);
@@ -264,12 +265,22 @@ hitori_check_win (Hitori *hitori)
                /* Translators: The first parameter is the number of minutes which have elapsed since the 
start of the game; the second parameter is
                 * the number of seconds. */
                message = g_strdup_printf (_("You've won in a time of %02u:%02u!"), hitori->timer_value / 60, 
hitori->timer_value % 60);
-               dialog = gtk_message_dialog_new (GTK_WINDOW (hitori->window), GTK_DIALOG_MODAL, 
GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "%s", message);
+               dialog = gtk_message_dialog_new (GTK_WINDOW (hitori->window), GTK_DIALOG_MODAL, 
GTK_MESSAGE_INFO, GTK_BUTTONS_NONE, "%s", message);
                g_free (message);
 
-               gtk_dialog_run (GTK_DIALOG (dialog));
+               gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+                                       _("_Quit"), GTK_RESPONSE_REJECT,
+                                       _("_Play Again"), GTK_RESPONSE_ACCEPT,
+                                       NULL);
+
+               ret = gtk_dialog_run (GTK_DIALOG (dialog));
                gtk_widget_destroy (dialog);
 
+               if (ret == GTK_RESPONSE_REJECT)
+                       hitori_quit (hitori);
+               else if (ret == GTK_RESPONSE_ACCEPT)
+                       hitori_new_game (hitori, hitori->board_size);
+
                return TRUE;
        }
 


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