[gnome-shell] status/network: Use property bindings for global visibility
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] status/network: Use property bindings for global visibility
- Date: Sun, 7 Aug 2022 22:08:37 +0000 (UTC)
commit 54a1c34f6e345e05e84ddc0d53fc4fcdc9b7b28e
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Aug 1 01:41:01 2022 +0200
status/network: Use property bindings for global visibility
There is a straight mapping between running/enabled and visibility,
so bind them instead of using a signal handler.
_syncConnectivity() is called both from _syncMainConnection() and
on connectivity changes, which should cover any running/enabled
changes.
That just leaves updating the icon on state changes.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2406>
js/ui/status/network.js | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 65e91b35e9..a8fddaad0b 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1779,14 +1779,18 @@ class Indicator extends PanelMenu.SystemIndicator {
this._readConnections();
this._readDevices();
- this._syncNMState();
this._syncMainConnection();
this._syncVpnConnections();
+ this._client.bind_property('nm-running',
+ this, 'visible',
+ GObject.BindingFlags.SYNC_CREATE);
+ this._client.bind_property('networking-enabled',
+ this.menu.actor, 'visible',
+ GObject.BindingFlags.SYNC_CREATE);
+
this._client.connectObject(
- 'notify::nm-running', () => this._syncNMState(),
- 'notify::networking-enabled', () => this._syncNMState(),
- 'notify::state', () => this._syncNMState(),
+ 'notify::state', () => this._updateIcon(),
'notify::primary-connection', () => this._syncMainConnection(),
'notify::activating-connection', () => this._syncMainConnection(),
'notify::active-connections', () => this._syncVpnConnections(),
@@ -2061,14 +2065,6 @@ class Indicator extends PanelMenu.SystemIndicator {
}
}
- _syncNMState() {
- this.visible = this._client.nm_running;
- this.menu.actor.visible = this._client.networking_enabled;
-
- this._updateIcon();
- this._syncConnectivity();
- }
-
_flushConnectivityQueue() {
for (let item of this._connectivityQueue)
this._portalHelperProxy?.CloseAsync(item);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]