[gnome-shell] status/network: Add activate() in NMSection



commit 88262a104263a4c4ae6b527dea050d35c1db9e16
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Aug 3 06:44:36 2022 +0200

    status/network: Add activate() in NMSection
    
    As the sections are about to turn into quick toggles, they need
    to be able to perform an action on click.
    
    Add an activate() method for that purpose, which either disconnects
    all active items, or connects the primary item.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2408>

 js/ui/status/network.js | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 1beab28c1f..994c35c134 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1343,6 +1343,15 @@ const NMSection = GObject.registerClass({
         this.menu.actor.visible = visible;
     }
 
+    activate() {
+        const activeItems = [...this._getActiveItems()];
+
+        if (activeItems.length > 0)
+            activeItems.forEach(i => i.activate());
+        else
+            this._itemBinding.source?.activate();
+    }
+
     _loadInitialItems() {
         throw new GObject.NotImplementedError();
     }


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