Blob Blame History Raw
From cd80de739be21f374a732e7cbbf8eeec655b8c2a Mon Sep 17 00:00:00 2001
From: Milan Crha <mcrha@redhat.com>
Date: Fri, 17 Apr 2020 09:21:42 +0200
Subject: [PATCH] window-list: Invalid current mode selected in Preferences

It seems that gtk+ resets the active radio whenever a new radio button
is added into the group, thus rather restore the current mode after
the group is fully populated.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/119
---
 extensions/window-list/prefs.js | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/extensions/window-list/prefs.js b/extensions/window-list/prefs.js
index bc1abcd..add134f 100644
--- a/extensions/window-list/prefs.js
+++ b/extensions/window-list/prefs.js
@@ -49,6 +49,7 @@ class WindowListPrefsWidget extends Gtk.Grid {
         };
 
         let radio = null;
+        let currentRadio = null;
         for (let i = 0; i < modes.length; i++) {
             let mode = modes[i];
             let label = modeLabels[mode];
@@ -57,17 +58,25 @@ class WindowListPrefsWidget extends Gtk.Grid {
                continue;
             }
 
-            radio = new Gtk.RadioButton({ active: currentMode == mode,
-                                          label: label,
-                                          group: radio });
+            radio = new Gtk.RadioButton({
+                active: !i,
+                label,
+                group: radio,
+            });
             grid.add(radio);
 
+            if (currentMode === mode)
+                currentRadio = radio;
+
             radio.connect('toggled', button => {
                 if (button.active)
                     this._settings.set_string('grouping-mode', mode);
             });
         }
 
+        if (currentRadio)
+            currentRadio.active = true;
+
         let check = new Gtk.CheckButton({ label: _("Show on all monitors"),
                                           margin_top: 6 });
         this._settings.bind('show-on-all-monitors', check, 'active', Gio.SettingsBindFlags.DEFAULT);
-- 
2.26.2