status/network: Override activate() for wireless

Wireless items represent a single adapter, but wireless connectivity
is controlled globally under NetworkManager.

So instead of delegating activation to items, bind the :checked
property to the global :wireless-enabled property and toggle it
on activate.

As any wireless devices will change their state to UNAVAILABLE
when wireless is disabled, don't remove corresponding items in
that case to keep the section visible.

We don't want to hide the button to turn Wi-Fi back on when toggled
off :-)

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2408>
This commit is contained in:
Florian Müllner 2022-08-03 23:24:53 +02:00 committed by Marge Bot
parent 1cc07716fa
commit 791c65a5f9

View File

@ -1699,9 +1699,32 @@ class NMWirelessSection extends NMDeviceSection {
'gnome-wifi-panel.desktop');
}
setClient(client) {
super.setClient(client);
this._client?.bind_property('wireless-enabled',
this, 'checked',
GObject.BindingFlags.SYNC_CREATE);
}
activate() {
this._client.wireless_enabled = !this._client.wireless_enabled;
}
_createDeviceMenuItem(device) {
return new NMWirelessDeviceItem(this._client, device);
}
_updateChecked() {
// handled via a property binding
}
_shouldShowDevice(device) {
// don't disappear if wireless-enabled is false
if (device.state === NM.DeviceState.UNAVAILABLE)
return true;
return super._shouldShowDevice(device);
}
});
const NMWiredSection = GObject.registerClass(