status/network: Disable modem connection when windows aren't allowed

The item launches the corresponding Settings panel when activated, which
doesn't work when windows are disabled by the session mode. Rather than
failing silently, turn the item insensitive.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1874>
This commit is contained in:
Florian Müllner 2021-06-07 17:49:57 +02:00 committed by Marge Bot
parent 6203668b6c
commit 25793b9d97

View File

@ -563,6 +563,10 @@ var NMDeviceModem = class extends NMConnectionDevice {
this._iconChanged();
});
}
this._sessionUpdatedId =
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
this._sessionUpdated();
}
get category() {
@ -573,6 +577,10 @@ var NMDeviceModem = class extends NMConnectionDevice {
launchSettingsPanel('network', 'connect-3g', this._device.get_path());
}
_sessionUpdated() {
this._autoConnectItem.sensitive = Main.sessionMode.hasWindows;
}
destroy() {
if (this._operatorNameId) {
this._mobileDevice.disconnect(this._operatorNameId);
@ -582,6 +590,10 @@ var NMDeviceModem = class extends NMConnectionDevice {
this._mobileDevice.disconnect(this._signalQualityId);
this._signalQualityId = 0;
}
if (this._sessionUpdatedId) {
Main.sessionMode.disconnect(this._sessionUpdatedId);
this._sessionUpdatedId = 0;
}
super.destroy();
}