[gnome-shell] status/network: Consider network-control action



commit d1333cb2490f0ca3279305785c0471237f78e8a2
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jun 8 00:17:48 2021 +0200

    status/network: Consider network-control action
    
    NetworkManager installs a `network-control` polkit action that can
    be used to disallow network configuration, except that we happily
    ignore it. Add it to the conditions that turn a network section
    insensitive.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1874>

 js/ui/status/network.js | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 3a1d47aa1c..3d336ed7e6 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1,6 +1,6 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported NMApplet */
-const { Clutter, Gio, GLib, GObject, Meta, NM, St } = imports.gi;
+const { Clutter, Gio, GLib, GObject, Meta, NM, Polkit, St } = imports.gi;
 const Signals = imports.signals;
 
 const Animation = imports.ui.animation;
@@ -1750,12 +1750,23 @@ class Indicator extends PanelMenu.SystemIndicator {
         this._client.connect('connection-added', this._connectionAdded.bind(this));
         this._client.connect('connection-removed', this._connectionRemoved.bind(this));
 
+        try {
+            this._configPermission = await Polkit.Permission.new(
+                'org.freedesktop.NetworkManager.network-control', null, null);
+        } catch (e) {
+            log('No permission to control network connections: %s'.format(e.toString()));
+            this._configPermission = null;
+        }
+
         Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
         this._sessionUpdated();
     }
 
     _sessionUpdated() {
-        let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
+        const sensitive =
+            !Main.sessionMode.isLocked &&
+            !Main.sessionMode.isGreeter &&
+            this._configPermission && this._configPermission.allowed;
         this.menu.setSensitive(sensitive);
     }
 


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