status/network: Use connectObject() to connect client signals

We would want the signals to be disconnected if we ever happened to
destroy the indicator. Even if we don't, connectObject() is simply
nicer when connecting half a dozen handlers at once.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2406>
This commit is contained in:
Florian Müllner 2022-08-01 01:47:22 +02:00
parent c33b5de174
commit f411228fa0

View File

@ -1783,17 +1783,19 @@ class Indicator extends PanelMenu.SystemIndicator {
this._syncMainConnection(); this._syncMainConnection();
this._syncVpnConnections(); this._syncVpnConnections();
this._client.connect('notify::nm-running', this._syncNMState.bind(this)); this._client.connectObject(
this._client.connect('notify::networking-enabled', this._syncNMState.bind(this)); 'notify::nm-running', () => this._syncNMState(),
this._client.connect('notify::state', this._syncNMState.bind(this)); 'notify::networking-enabled', () => this._syncNMState(),
this._client.connect('notify::primary-connection', this._syncMainConnection.bind(this)); 'notify::state', () => this._syncNMState(),
this._client.connect('notify::activating-connection', this._syncMainConnection.bind(this)); 'notify::primary-connection', () => this._syncMainConnection(),
this._client.connect('notify::active-connections', this._syncVpnConnections.bind(this)); 'notify::activating-connection', () => this._syncMainConnection(),
this._client.connect('notify::connectivity', this._syncConnectivity.bind(this)); 'notify::active-connections', () => this._syncVpnConnections(),
this._client.connect('device-added', this._deviceAdded.bind(this)); 'notify::connectivity', () => this._syncConnectivity(),
this._client.connect('device-removed', this._deviceRemoved.bind(this)); 'device-added', this._deviceAdded.bind(this),
this._client.connect('connection-added', this._connectionAdded.bind(this)); 'device-removed', this._deviceRemoved.bind(this),
this._client.connect('connection-removed', this._connectionRemoved.bind(this)); 'connection-added', this._connectionAdded.bind(this),
'connection-removed', this._connectionRemoved.bind(this),
this);
try { try {
this._configPermission = await Polkit.Permission.new( this._configPermission = await Polkit.Permission.new(