summaryrefslogtreecommitdiff
path: root/debian/patches/bluetooth-Use-a-separate-signal-for-changes-to-the-defaul.patch
blob: 4d362e86dc777ce95a95ed10e5577fd235534b6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From: Simon McVittie <smcv@debian.org>
Date: Thu, 31 Mar 2022 10:13:50 +0100
Subject: bluetooth: Use a separate signal for changes to the default adapter

In gnome-bluetooth API version 1.0 (GNOME 41 and older), the Bluetooth
adapters are part of the same GtkTreeModel as the devices attached to
them, but in gnome-bluetooth API version 3.0 (GNOME 42) they're tracked
separately.

Signed-off-by: Simon McVittie <smcv@debian.org>
Forwarded: https://github.com/bjarosze/gnome-bluetooth-quick-connect/pull/55
---
 bluetooth.js | 7 ++++++-
 extension.js | 9 ++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/bluetooth.js b/bluetooth.js
index a8ed5e0..7472b07 100644
--- a/bluetooth.js
+++ b/bluetooth.js
@@ -31,7 +31,12 @@ var BluetoothController = class {
         this._connectSignal(this._model, 'row-changed', (arg0, arg1, iter) => {
             if (iter) {
                 let device = this._buildDevice(iter);
-                this.emit('device-changed', device);
+                if (device.isDefault) {
+                    this.emit('default-adapter-changed', device);
+                }
+                else {
+                    this.emit('device-changed', device);
+                }
             }
 
         });
diff --git a/extension.js b/extension.js
index bf89429..f154581 100644
--- a/extension.js
+++ b/extension.js
@@ -82,6 +82,11 @@ class BluetoothQuickConnect {
     _connectControllerSignals() {
         this._logger.info('Connecting bluetooth controller signals');
 
+        this._connectSignal(this._controller, 'default-adapter-changed', (ctrl) => {
+            this._logger.info('Default adapter changed event');
+            this._refresh();
+        });
+
         this._connectSignal(this._controller, 'device-inserted', (ctrl, device) => {
             this._logger.info(`Device inserted event: ${device.name}`);
             if (device.isPaired) {
@@ -93,9 +98,7 @@ class BluetoothQuickConnect {
 
         this._connectSignal(this._controller, 'device-changed', (ctrl, device) => {
             this._logger.info(`Device changed event: ${device.name}`);
-            if (device.isDefault)
-                this._refresh();
-            else if (device.isPaired)
+            if (device.isPaired)
                 this._syncMenuItem(device);
             else
                 this._logger.info(`Skipping change event for unpaired device ${device.name}`);