[iagno] Remove the hack in four parts.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Remove the hack in four parts.
- Date: Wed, 25 Mar 2015 09:08:44 +0000 (UTC)
commit 6047f3152105eafa2a8bd1e4932dae768bd3d829
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Mar 25 10:08:16 2015 +0100
Remove the hack in four parts.
data/iagno-screens.ui | 74 ++++++++++++++++++------------------------------
src/iagno.vala | 35 ++--------------------
2 files changed, 32 insertions(+), 77 deletions(-)
---
diff --git a/data/iagno-screens.ui b/data/iagno-screens.ui
index 3a7c8b9..239f0a4 100644
--- a/data/iagno-screens.ui
+++ b/data/iagno-screens.ui
@@ -31,30 +31,25 @@
<property name="homogeneous">True</property>
<property name="spacing">12</property>
<child>
- <object class="GtkRadioButton" id="one">
+ <object class="GtkModelButton">
<property name="visible">True</property>
<property name="use_underline">True</property>
- <property name="label" translatable="yes">_One</property>
+ <property name="text" translatable="yes">_One</property>
<property name="action-name">app.num-players</property>
<property name="action-target">1</property>
- <property name="draw-indicator">False</property>
- <style>
- <class name="button"/>
- </style>
+ <property name="iconic">True</property>
+ <property name="centered">True</property>
</object>
</child>
<child>
- <object class="GtkRadioButton">
+ <object class="GtkModelButton">
<property name="visible">True</property>
<property name="use_underline">True</property>
- <property name="label" translatable="yes">_Two</property>
+ <property name="text" translatable="yes">_Two</property>
<property name="action-name">app.num-players</property>
<property name="action-target">2</property>
- <property name="group">one</property>
- <property name="draw-indicator">False</property>
- <style>
- <class name="button"/>
- </style>
+ <property name="iconic">True</property>
+ <property name="centered">True</property>
</object>
</child>
</object>
@@ -85,44 +80,36 @@
<property name="homogeneous">True</property>
<property name="spacing">12</property>
<child>
- <object class="GtkRadioButton" id="easy">
+ <object class="GtkModelButton">
<property name="visible">True</property>
<property name="use_underline">True</property>
- <property name="label" translatable="yes">_Easy</property>
+ <property name="text" translatable="yes">_Easy</property>
<property name="action-name">app.computer-level</property>
<property name="action-target">1</property>
- <property name="draw-indicator">False</property>
- <style>
- <class name="button"/>
- </style>
+ <property name="iconic">True</property>
+ <property name="centered">True</property>
</object>
</child>
<child>
- <object class="GtkRadioButton">
+ <object class="GtkModelButton">
<property name="visible">True</property>
<property name="use_underline">True</property>
- <property name="label" translatable="yes">_Medium</property>
+ <property name="text" translatable="yes">_Medium</property>
<property name="action-name">app.computer-level</property>
<property name="action-target">2</property>
- <property name="group">easy</property>
- <property name="draw-indicator">False</property>
- <style>
- <class name="button"/>
- </style>
+ <property name="iconic">True</property>
+ <property name="centered">True</property>
</object>
</child>
<child>
- <object class="GtkRadioButton">
+ <object class="GtkModelButton">
<property name="visible">True</property>
<property name="use_underline">True</property>
- <property name="label" translatable="yes">_Hard</property>
+ <property name="text" translatable="yes">_Hard</property>
<property name="action-name">app.computer-level</property>
<property name="action-target">3</property>
- <property name="group">easy</property>
- <property name="draw-indicator">False</property>
- <style>
- <class name="button"/>
- </style>
+ <property name="iconic">True</property>
+ <property name="centered">True</property>
</object>
</child>
</object>
@@ -153,30 +140,25 @@
<property name="homogeneous">True</property>
<property name="spacing">12</property>
<child>
- <object class="GtkRadioButton" id="play_dark">
+ <object class="GtkModelButton">
<property name="visible">True</property>
<property name="use_underline">True</property>
- <property name="label" translatable="yes">_Dark</property>
+ <property name="text" translatable="yes">_Dark</property>
<property name="action-name">app.color</property>
<property name="action-target">'dark'</property>
- <property name="draw-indicator">False</property>
- <style>
- <class name="button"/>
- </style>
+ <property name="iconic">True</property>
+ <property name="centered">True</property>
</object>
</child>
<child>
- <object class="GtkRadioButton">
+ <object class="GtkModelButton">
<property name="visible">True</property>
<property name="use_underline">True</property>
- <property name="label" translatable="yes">_Light</property>
+ <property name="text" translatable="yes">_Light</property>
<property name="action-name">app.color</property>
<property name="action-target">'light'</property>
- <property name="group">play_dark</property>
- <property name="draw-indicator">False</property>
- <style>
- <class name="button"/>
- </style>
+ <property name="iconic">True</property>
+ <property name="centered">True</property>
</object>
</child>
</object>
diff --git a/src/iagno.vala b/src/iagno.vala
index f256258..153c84e 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -141,31 +141,14 @@ public class Iagno : Gtk.Application
bool start_now = (two_players == true) || (play_first != null);
if (start_now)
settings.set_int ("num-players", two_players ? 2 : 1);
- else /* hack, part 1 of 4 */
- two_players = (settings.get_int ("num-players") == 2);
- string color;
if (play_first != null)
- {
- color = play_first ? "dark" : "light";
- settings.set_string ("color", color);
- }
- else /* hack, part 2 of 4 */
- color = settings.get_string ("color");
+ settings.set_string ("color", play_first ? "dark" : "light");
- int computer_level;
if (level == "1" || level == "2" || level == "3")
- {
- computer_level = int.parse (level);
- settings.set_int ("computer-level", computer_level);
- }
- else
- {
- if (level != null)
- stderr.printf ("%s\n", _("Level should be between 1 (easy) and 3 (hard). Settings
unchanged."));
- /* hack, part 3 of 4 */
- computer_level = settings.get_int ("computer-level");
- }
+ settings.set_int ("computer-level", int.parse (level));
+ else if (level != null)
+ stderr.printf ("%s\n", _("Level should be between 1 (easy) and 3 (hard). Settings unchanged."));
/* UI parts */
Builder builder = new Builder.from_resource ("/org/gnome/iagno/ui/iagno-screens.ui");
@@ -204,8 +187,6 @@ public class Iagno : Gtk.Application
set_accels_for_action ("win.redo", {"<Primary><Shift>z"});
set_accels_for_action ("win.back", {"Escape"});
add_action (settings.create_action ("sound"));
- /* TODO bugs when changing manually the gsettings key (not for sound);
- * solving this bug may remove the need of the hack in four parts */
add_action (settings.create_action ("color"));
add_action (settings.create_action ("num-players"));
add_action (settings.create_action ("computer-level"));
@@ -229,14 +210,6 @@ public class Iagno : Gtk.Application
start_game ();
add_window (window);
-
- /* Hack for restoring radiobuttons settings, part 4 of 4.
- * When you add_window(), settings are initialized with the value
- * of the first radiobutton of the group found in the UI file. */
- GLib.Settings.sync ();
- settings.set_string ("color", color);
- settings.set_int ("computer-level", computer_level);
- settings.set_int ("num-players", two_players ? 2 : 1);
}
protected override void activate ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]