status/network: Only list wifi networks that can be activated

Setting up a connection for an Enterprise WPA(2) encrypted wireless
network requires Settings. That's not available when windows are
disabled via the session mode, so filter out affected entries.

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

View File

@ -1,6 +1,6 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported NMApplet */ /* exported NMApplet */
const { Clutter, Gio, GLib, GObject, NM, St } = imports.gi; const { Clutter, Gio, GLib, GObject, Meta, NM, St } = imports.gi;
const Signals = imports.signals; const Signals = imports.signals;
const Animation = imports.ui.animation; const Animation = imports.ui.animation;
@ -816,6 +816,11 @@ class NMWirelessDialog extends ModalDialog.ModalDialog {
GLib.source_remove(this._scanTimeoutId); GLib.source_remove(this._scanTimeoutId);
this._scanTimeoutId = 0; this._scanTimeoutId = 0;
} }
if (this._syncVisibilityId) {
Meta.later_remove(this._syncVisibilityId);
this._syncVisibilityId = 0;
}
} }
_onScanTimeout() { _onScanTimeout() {
@ -1149,9 +1154,32 @@ class NMWirelessDialog extends ModalDialog.ModalDialog {
this._itemBox.insert_child_at_index(network.item, newPos); this._itemBox.insert_child_at_index(network.item, newPos);
} }
this._queueSyncItemVisibility();
this._syncView(); this._syncView();
} }
_queueSyncItemVisibility() {
if (this._syncVisibilityId)
return;
this._syncVisibilityId = Meta.later_add(
Meta.LaterType.BEFORE_REDRAW,
() => {
const { hasWindows } = Main.sessionMode;
const { WPA2_ENT, WPA_ENT } = NMAccessPointSecurity;
for (const network of this._networks) {
const [firstAp] = network.accessPoints;
network.item.visible =
hasWindows ||
network.connections.length > 0 ||
(firstAp._secType !== WPA2_ENT && firstAp._secType !== WPA_ENT);
}
this._syncVisibilityId = 0;
return GLib.SOURCE_REMOVE;
});
}
_accessPointRemoved(device, accessPoint) { _accessPointRemoved(device, accessPoint) {
let res = this._findExistingNetwork(accessPoint); let res = this._findExistingNetwork(accessPoint);
@ -1200,6 +1228,7 @@ class NMWirelessDialog extends ModalDialog.ModalDialog {
_createNetworkItem(network) { _createNetworkItem(network) {
network.item = new NMWirelessDialogItem(network); network.item = new NMWirelessDialogItem(network);
network.item.setActive(network == this._selectedNetwork); network.item.setActive(network == this._selectedNetwork);
network.item.hide();
network.item.connect('selected', () => { network.item.connect('selected', () => {
Util.ensureActorVisibleInScrollView(this._scrollView, network.item); Util.ensureActorVisibleInScrollView(this._scrollView, network.item);
this._selectNetwork(network); this._selectNetwork(network);