status/network: Bind subtitle

Instead of map the currently active items - for whatever they are -
into the quick toggle title, bind it to the subtitle.

This leaves room for setting static titles for device-backed
networks, such as Wi-Fi, Wired, Bluetooth, etc.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2619>
This commit is contained in:
Georges Basile Stavracas Neto 2023-02-04 14:57:20 -03:00
parent ec397cf604
commit ab10b95d2d

View File

@ -1319,8 +1319,8 @@ const NMToggle = GObject.registerClass({
this._itemBinding.bind('icon-name', this._itemBinding.bind('icon-name',
this, 'icon-name', GObject.BindingFlags.DEFAULT); this, 'icon-name', GObject.BindingFlags.DEFAULT);
this._itemBinding.bind_full('name', this._itemBinding.bind_full('name',
this, 'title', GObject.BindingFlags.DEFAULT, this, 'subtitle', GObject.BindingFlags.DEFAULT,
(bind, source) => [true, this._transformTitle(source)], (bind, source) => [true, this._transformSubtitle(source)],
null); null);
this.connect('clicked', () => this.activate()); this.connect('clicked', () => this.activate());
@ -1360,7 +1360,7 @@ const NMToggle = GObject.registerClass({
// transform function for property binding: // transform function for property binding:
// Ignore the provided label if there are multiple active // Ignore the provided label if there are multiple active
// items, and replace it with something like "VPN (2)" // items, and replace it with something like "VPN (2)"
_transformTitle(source) { _transformSubtitle(source) {
const nActive = this.checked const nActive = this.checked
? [...this._getActiveItems()].length ? [...this._getActiveItems()].length
: 0; : 0;