From 6a23e8ee0f4e859ac3aa0098c102d13946ac3732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 23 Aug 2022 00:06:42 +0200 Subject: [PATCH] status/bluetooth: Indicate progress on toggle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turning bluetooth on or off can be very slow ­– 10-15 seconds on my system – and we currently don't provide any feedback that something is indeed happening until the state changes at last. Address this by using the `acquiring` icon when the adapter is in a transitioning state. https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5773 Part-of: --- js/ui/status/bluetooth.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js index 9580e7b4c..d4de597ad 100644 --- a/js/ui/status/bluetooth.js +++ b/js/ui/status/bluetooth.js @@ -178,14 +178,31 @@ class BluetoothToggle extends QuickToggle { this._client.bind_property('active', this, 'checked', GObject.BindingFlags.SYNC_CREATE); - this._client.bind_property_full('active', + this._client.bind_property_full('adapter-state', this, 'icon-name', GObject.BindingFlags.SYNC_CREATE, - (bind, source) => [true, source ? 'bluetooth-active-symbolic' : 'bluetooth-disabled-symbolic'], + (bind, source) => [true, this._getIconNameFromState(source)], null); this.connect('clicked', () => this._client.toggleActive()); } + + _getIconNameFromState(state) { + switch (state) { + case AdapterState.ON: + return 'bluetooth-active-symbolic'; + case AdapterState.OFF: + case AdapterState.ABSENT: + return 'bluetooth-disabled-symbolic'; + case AdapterState.TURNING_ON: + case AdapterState.TURNING_OFF: + return 'bluetooth-acquiring-symbolic'; + default: + console.warn(`Unexpected state ${ + GObject.enum_to_string(AdapterState, state)}`); + return ''; + } + } }); var Indicator = GObject.registerClass(