status/network: Generalize code to hide subtitle

Commit 9d75d777c7 introduced code to hide the subtitle of the
quick setting toggle when it matches the title of the toggle.
That's because NetworkManager tries to make the network names
more palatable on its own, and reports that the name of single
wired networks is "Wired" even if it may have another name.

What that commit failed to account for, however, is that there are
other circumstances where we end up with a subtitle is exactly the
same of the title. For example, when turning off Wi-Fi or mobile
broadband connections.

The behaviour of commit 9d75d777c7 is safe enough to be applied
on other device-backed connections, so do it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2682>
This commit is contained in:
Georges Basile Stavracas Neto 2023-03-06 16:29:46 -03:00 committed by Marge Bot
parent 237c3e958d
commit 9e19f27e45

View File

@ -1611,6 +1611,13 @@ class NMDeviceToggle extends NMToggle {
return name;
}
_transformSubtitle(source) {
const subtitle = super._transformSubtitle(source);
if (subtitle === this.title)
return null;
return subtitle;
}
_loadInitialItems() {
const devices = this._client.get_devices();
for (const dev of devices)
@ -1842,13 +1849,6 @@ class NMWiredToggle extends NMDeviceToggle {
'gnome-network-panel.desktop');
}
_transformSubtitle(source) {
const subtitle = super._transformSubtitle(source);
if (subtitle === this.title)
return null;
return subtitle;
}
_createDeviceMenuItem(device) {
return new NMWiredDeviceItem(this._client, device);
}