[gnome-nibbles/arnaudb/command-line] Fix fake bonuses.



commit 971d388e06f3e022b5bad621770a76463a2bf3d9
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Jul 9 16:31:28 2020 +0200

    Fix fake bonuses.

 data/ui/speed.ui        |  4 ++--
 src/nibbles-window.vala |  1 -
 src/speed.vala          | 20 ++++++++------------
 3 files changed, 10 insertions(+), 15 deletions(-)
---
diff --git a/data/ui/speed.ui b/data/ui/speed.ui
index 9541a2d..63229ac 100644
--- a/data/ui/speed.ui
+++ b/data/ui/speed.ui
@@ -124,14 +124,14 @@
               </object>
             </child>
             <child>
-              <object class="GtkModelButton" id="fakes_modelbutton">
+              <object class="GtkModelButton">
                 <property name="visible">True</property>
                 <property name="hexpand">True</property>
                 <property name="halign">fill</property>
                 <property name="use-underline">True</property>
                 <!-- Translators: label of a togglebutton in the "Preferences" panel displayed during game 
configuration (with a mnemonic that appears when pressing Alt); activates special bonuses -->
                 <property name="text" translatable="yes">_Enable fake bonuses</property>
-                <property name="action-name">win.fakes</property>
+                <property name="action-name">speed.toggle-fakes</property>
                 <style>
                   <class name="speed-box"/>
                 </style>
diff --git a/src/nibbles-window.vala b/src/nibbles-window.vala
index 1369750..24188a8 100644
--- a/src/nibbles-window.vala
+++ b/src/nibbles-window.vala
@@ -116,7 +116,6 @@ private class NibblesWindow : ApplicationWindow
         settings = new GLib.Settings ("org.gnome.Nibbles");
         settings.changed.connect (settings_changed_cb);
         add_action (settings.create_action ("sound"));
-        add_action (settings.create_action ("fakes"));
 
         worm_settings = new Gee.ArrayList<GLib.Settings> ();
         for (int i = 0; i < NibblesGame.MAX_WORMS; i++)
diff --git a/src/speed.vala b/src/speed.vala
index 86f9b6c..6220706 100644
--- a/src/speed.vala
+++ b/src/speed.vala
@@ -23,14 +23,12 @@ using Gtk;
 private class Speed : Box
 {
     private SimpleAction speed_action;
-
-    [GtkChild] private ModelButton fakes_modelbutton;
-    private bool fakes;
+    private SimpleAction fakes_action;
 
     private const GLib.ActionEntry [] players_action_entries =
     {
-        { "change-speed", null,         "i", "4", change_speed },
-        { "fake-bonuses", allow_fakes }
+        { "change-speed", null, "i",    "4",    change_speed },
+        { "toggle-fakes", null, null,   "true", toggle_fakes }
     };
 
     construct
@@ -40,21 +38,19 @@ private class Speed : Box
         insert_action_group ("speed", action_group);
 
         speed_action = (SimpleAction) action_group.lookup_action ("change-speed");
+        fakes_action = (SimpleAction) action_group.lookup_action ("toggle-fakes");
     }
 
     internal inline void set_values (int speed, bool fakes)
     {
         speed_action.set_state (speed);
-
-        fakes_modelbutton.active = fakes;
-        this.fakes = fakes;
+        fakes_action.set_state (fakes);
     }
 
     internal inline void get_values (out int speed, out bool fakes)
     {
         speed = speed_action.get_state ().get_int32 ();
-
-        fakes = this.fakes;
+        fakes = fakes_action.get_state ().get_boolean ();
     }
 
     private inline void change_speed (SimpleAction _speed_action, Variant variant)
@@ -65,8 +61,8 @@ private class Speed : Box
         _speed_action.set_state (speed);
     }
 
-    private void allow_fakes (/* SimpleAction _speed_action, Variant? variant */)
+    private void toggle_fakes (SimpleAction _fakes_action, Variant? variant)
     {
-        fakes = fakes_modelbutton.active;
+        _fakes_action.set_state (((!) variant).get_boolean ());
     }
 }


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