status/bluetooth: Show connected devices in subtitle
Now that quick toggles support subtitles, use it to indicate connected devices. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2501>
This commit is contained in:
parent
384ab9f875
commit
b7c3a7f6ed
@ -164,7 +164,27 @@ class BluetoothToggle extends QuickToggle {
|
||||
(bind, source) => [true, this._getIconNameFromState(source)],
|
||||
null);
|
||||
|
||||
this._client.connectObject(
|
||||
'devices-changed', () => this._sync(),
|
||||
this);
|
||||
|
||||
this.connect('clicked', () => this._client.toggleActive());
|
||||
|
||||
this._sync();
|
||||
}
|
||||
|
||||
_sync() {
|
||||
const connectedDevices = [...this._client.getDevices()]
|
||||
.filter(dev => dev.connected);
|
||||
const nConnected = connectedDevices.length;
|
||||
|
||||
if (nConnected > 1)
|
||||
/* Translators: This is the number of connected bluetooth devices */
|
||||
this.subtitle = ngettext('%d Connected', '%d Connected', nConnected).format(nConnected);
|
||||
else if (nConnected === 1)
|
||||
this.subtitle = connectedDevices[0].alias;
|
||||
else
|
||||
this.subtitle = null;
|
||||
}
|
||||
|
||||
_getIconNameFromState(state) {
|
||||
|
Loading…
Reference in New Issue
Block a user