[iagno] Delay when changing settings.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Delay when changing settings.
- Date: Sat, 9 Feb 2019 13:36:09 +0000 (UTC)
commit 5ac5af4b24ebf87933f1b3d9c8511a01896aee69
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Feb 7 22:26:53 2019 +0100
Delay when changing settings.
src/game-window.vala | 2 ++
src/iagno.vala | 63 ++++++++++++++++++++++++++++------------------------
2 files changed, 36 insertions(+), 29 deletions(-)
---
diff --git a/src/game-window.vala b/src/game-window.vala
index 36d461f..e48bea8 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -218,9 +218,11 @@ public class GameWindow : ApplicationWindow
public void shutdown (GLib.Settings settings)
{
+ settings.delay ();
settings.set_int ("window-width", window_width);
settings.set_int ("window-height", window_height);
settings.set_boolean ("window-is-maximized", maximized_state);
+ settings.apply ();
destroy ();
}
diff --git a/src/iagno.vala b/src/iagno.vala
index 50b677c..27edef4 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -160,40 +160,45 @@ public class Iagno : Gtk.Application
/* Settings */
settings = new GLib.Settings ("org.gnome.Reversi");
- if (sound != null)
- settings.set_boolean ("sound", (!) sound);
-
bool start_now = (two_players == true) || (play_first != null);
- if (start_now)
- settings.set_int ("num-players", two_players ? 2 : 1);
+ if ((sound != null) || start_now || (level != null))
+ {
+ settings.delay ();
+ if (sound != null)
+ settings.set_boolean ("sound", (!) sound);
- if (play_first != null)
- settings.set_string ("color", ((!) play_first) ? "dark" : "light");
+ if (start_now)
+ settings.set_int ("num-players", two_players ? 2 : 1);
- // TODO start one-player game immediately, if two_players == false
- if (level != null)
- {
- // TODO add a localized text option?
- switch ((!) level)
+ if (play_first != null)
+ settings.set_string ("color", ((!) play_first) ? "dark" : "light");
+
+ // TODO start one-player game immediately, if two_players == false
+ if (level != null)
{
- case "1":
- case "easy":
- case "one": settings.set_int ("computer-level", 1); break;
-
- case "2":
- case "medium":
- case "two": settings.set_int ("computer-level", 2); break;
-
- case "3":
- case "hard":
- case "three": settings.set_int ("computer-level", 3); break;
-
- default:
- /* Translators: command-line error message, displayed for an incorrect level request;
try 'iagno -l 5' */
- stderr.printf ("%s\n", _("Level should be between 1 (easy) and 3 (hard). Settings
unchanged."));
- // stderr.printf ("%s\n", _("Level should be 1 (easy), 2 (medium) or 3 (hard). Settings
unchanged.")); // TODO better?
- break;
+ // TODO add a localized text option?
+ switch ((!) level)
+ {
+ case "1":
+ case "easy":
+ case "one": settings.set_int ("computer-level", 1); break;
+
+ case "2":
+ case "medium":
+ case "two": settings.set_int ("computer-level", 2); break;
+
+ case "3":
+ case "hard":
+ case "three": settings.set_int ("computer-level", 3); break;
+
+ default:
+ /* Translators: command-line error message, displayed for an incorrect level
request; try 'iagno -l 5' */
+ stderr.printf ("%s\n", _("Level should be between 1 (easy) and 3 (hard). Settings
unchanged."));
+ // stderr.printf ("%s\n", _("Level should be 1 (easy), 2 (medium) or 3 (hard). Settings
unchanged.")); // TODO better?
+ break;
+ }
}
+ settings.apply ();
}
/* UI parts */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]