[gnome-nibbles] Ignore clicks on the same button



commit 6f218914f3a324cb9fa5495f31fcc2d7cc6329d3
Author: Iulian Gabriel Radu <iulian radu67 gmail com>
Date:   Sat Feb 15 21:05:53 2020 +0200

    Ignore clicks on the same button
    
    Currently, on the number of players selection screen, clicking an already
    selected "number of human players" button resets the number of AI players
    selection.
    
    With this commit, clicking the same button twice will have no effect.
    
    Fixes #12.

 src/gnome-nibbles.vala | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index 9ae75cf..081158c 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -654,6 +654,7 @@ public class Nibbles : Gtk.Application
 
     private void change_number_of_players_cb (Gtk.ToggleButton button)
     {
+        var is_same_button = true;
         foreach (var other_button in number_of_players_buttons)
         {
             if (button != other_button)
@@ -666,10 +667,21 @@ public class Nibbles : Gtk.Application
                     SignalHandler.block_matched (other_button, SignalMatchType.DATA, 0, 0, null, null, this);
                     other_button.set_active (false);
                     SignalHandler.unblock_matched (other_button, SignalMatchType.DATA, 0, 0, null, null, 
this);
+                    is_same_button = false;
                     break;
                 }
             }
         }
+
+        /* Ignore clicks on the same button. */
+        if (is_same_button)
+        {
+            SignalHandler.block_matched (button, SignalMatchType.DATA, 0, 0, null, null, this);
+            button.set_active (true);
+            SignalHandler.unblock_matched (button, SignalMatchType.DATA, 0, 0, null, null, this);
+            return;
+        }
+
         button.set_active (true);
 
         int numhumans = -1;


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