[gnome-robots] Add a warning dialog when pressing New Game



commit 5a3777cb002ddd8134d949cdb0ddfad718bc2152
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Jun 21 10:35:07 2014 -0500

    Add a warning dialog when pressing New Game

 src/gnobots.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/gnobots.c b/src/gnobots.c
index 8c4f911..f26abb2 100644
--- a/src/gnobots.c
+++ b/src/gnobots.c
@@ -191,7 +191,23 @@ quit_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data)
 static void
 new_game_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data)
 {
-  start_new_game ();
+  GtkWidget *dialog;
+  int ret;
+
+  dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL,
+                                   GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
+                                   _("Are you sure you want to discard the current game?"));
+
+  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+                          _("Keep _Playing"), GTK_RESPONSE_REJECT,
+                          _("_New Game"), GTK_RESPONSE_ACCEPT,
+                          NULL);
+
+  ret = gtk_dialog_run (GTK_DIALOG (dialog));
+  gtk_widget_destroy (dialog);
+
+  if (ret == GTK_RESPONSE_ACCEPT)
+    start_new_game ();
 }
 
 static void


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