[gnome-games] Confirmation when a user clicks the face before new game
- From: Jason Clinton <jclinton src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] Confirmation when a user clicks the face before new game
- Date: Wed, 26 Oct 2011 00:43:44 +0000 (UTC)
commit 7e5287b620ab397cb1c0cbf525284086a0cd2c6b
Author: Sophia Yu <sophia receiving gmail com>
Date: Tue Oct 25 19:40:49 2011 -0500
Confirmation when a user clicks the face before new game
Signed-off-by: Jason D. Clinton <jclinton google com>
gnomine/gnomine.c | 31 ++++++++++++++++++++++++++++++
gnomine/org.gnome.gnomine.gschema.xml.in | 6 +++++
2 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/gnomine/gnomine.c b/gnomine/gnomine.c
index 94edf99..ae3803c 100644
--- a/gnomine/gnomine.c
+++ b/gnomine/gnomine.c
@@ -70,6 +70,7 @@
#define KEY_USE_QUESTION_MARKS "use-question-marks"
#define KEY_USE_OVERMINE_WARNING "use-overmine-warning"
#define KEY_USE_AUTOFLAG "use-autoflag"
+#define KEY_USE_NEWGAME_CONFIRM "use-newgame-confirm"
static GtkWidget *mfield;
static GtkWidget *pref_dialog = NULL;
@@ -89,6 +90,7 @@ gint nmines = -1;
gint fsize = -1;
gboolean use_question_marks = TRUE;
gboolean use_overmine_warning = TRUE;
+gboolean use_newgame_confirm = TRUE;
gboolean use_autoflag = FALSE;
GtkAction *hint_action;
@@ -110,6 +112,7 @@ GamesScores *highscores;
* hide-the-window-to-stop cheating thing. */
gboolean disable_hiding = FALSE;
+
#if 0
static void
play_sound (int id)
@@ -261,8 +264,31 @@ new_game (void)
gint x, y;
static gint size_table[3][3] = { {8, 8, 10}, {16, 16, 40}, {30, 16, 99} };
GtkMineField *mf = GTK_MINEFIELD (mfield);
+ GtkWidget *dialog;
games_clock_stop (GAMES_CLOCK (clk));
+
+ /* We only need to confirm a new start in a running game session. */
+ if (use_newgame_confirm &&
+ (gtk_widget_get_visible (pm_cool) || gtk_widget_get_visible (pm_worried))) {
+ dialog = gtk_dialog_new_with_buttons (_("Confirmation"),
+ GTK_WINDOW (window),
+ GTK_DIALOG_MODAL,
+ _("Start New Game"),
+ GTK_RESPONSE_ACCEPT,
+ _("Keep Current Game"),
+ GTK_RESPONSE_REJECT,
+ NULL);
+
+ gint result = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (result == GTK_RESPONSE_REJECT) {
+ games_clock_start (GAMES_CLOCK (clk)); /* resume clock */
+ return;
+ }
+ }
+
games_clock_reset (GAMES_CLOCK (clk));
show_face (pm_smile);
@@ -493,6 +519,9 @@ conf_value_changed_cb (GSettings *settings, gchar *key)
gtk_minefield_set_use_autoflag (GTK_MINEFIELD (mfield),
use_autoflag);
}
+ if (strcmp (key, KEY_USE_NEWGAME_CONFIRM) == 0) {
+ use_newgame_confirm = g_settings_get_boolean (settings, key);
+ }
if (strcmp (key, KEY_XSIZE) == 0) {
int i;
i = g_settings_get_int (settings, key);
@@ -984,6 +1013,8 @@ main (int argc, char *argv[])
g_settings_get_boolean (settings, KEY_USE_QUESTION_MARKS);
use_overmine_warning =
g_settings_get_boolean (settings, KEY_USE_OVERMINE_WARNING);
+ use_newgame_confirm =
+ g_settings_get_boolean (settings, KEY_USE_NEWGAME_CONFIRM);
use_autoflag =
g_settings_get_boolean (settings, KEY_USE_AUTOFLAG);
diff --git a/gnomine/org.gnome.gnomine.gschema.xml.in b/gnomine/org.gnome.gnomine.gschema.xml.in
index 6a090a7..8de08d1 100644
--- a/gnomine/org.gnome.gnomine.gschema.xml.in
+++ b/gnomine/org.gnome.gnomine.gschema.xml.in
@@ -10,6 +10,12 @@
<_summary>Warning about too many flags</_summary>
<_description>Set to true to enable warning icons when too many flags are placed.</_description>
</key>
+ <key type="b" name="use-newgame-confirm">
+ <default>false</default>
+ <summary>Confirm before a new game</summary>
+ <description>When click the smiley face a confirmation messagebox will pop up. This
+ prevents the current game session from getting lost when you click the smiley face accidentally</description>
+ </key>
<key name="use-autoflag" type="b">
<default>false</default>
<_summary>Enable automatic placing of flags</_summary>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]