summaryrefslogtreecommitdiff
path: root/debian/patches/bluetooth-Use-GListStore-for-GNOME-Shell-42.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/bluetooth-Use-GListStore-for-GNOME-Shell-42.patch')
-rw-r--r--debian/patches/bluetooth-Use-GListStore-for-GNOME-Shell-42.patch166
1 files changed, 166 insertions, 0 deletions
diff --git a/debian/patches/bluetooth-Use-GListStore-for-GNOME-Shell-42.patch b/debian/patches/bluetooth-Use-GListStore-for-GNOME-Shell-42.patch
new file mode 100644
index 0000000..03e3fb7
--- /dev/null
+++ b/debian/patches/bluetooth-Use-GListStore-for-GNOME-Shell-42.patch
@@ -0,0 +1,166 @@
+From: Simon McVittie <smcv@debian.org>
+Date: Thu, 31 Mar 2022 10:37:54 +0100
+Subject: bluetooth: Use GListStore for GNOME Shell 42
+
+GNOME 42 has a new version of the GnomeBluetooth library, with a
+different API. Adjust to this.
+
+Signed-off-by: Simon McVittie <smcv@debian.org>
+Forwarded: https://github.com/bjarosze/gnome-bluetooth-quick-connect/pull/55
+---
+ bluetooth.js | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
+ metadata.json | 3 +-
+ 2 files changed, 83 insertions(+), 8 deletions(-)
+
+diff --git a/bluetooth.js b/bluetooth.js
+index 7472b07..f8c938d 100644
+--- a/bluetooth.js
++++ b/bluetooth.js
+@@ -24,10 +24,41 @@ const Utils = Me.imports.utils;
+ var BluetoothController = class {
+ constructor() {
+ this._client = new GnomeBluetooth.Client();
++
++ if (this._client.get_devices) {
++ /* >= 42 */
++ this._deviceNotifyConnected = new Set();
++ this._store = this._client.get_devices();
++ return;
++ }
++
++ /* <= 41 */
+ this._model = this._client.get_model();
+ }
+
+ enable() {
++ if (this._store) {
++ /* >= 42 */
++ this._client.connect('notify::default-adapter', () => {
++ this._deviceNotifyConnected.clear();
++ this.emit('default-adapter-changed');
++ });
++ this._client.connect('notify::default-adapter-powered', () => {
++ this._deviceNotifyConnected.clear();
++ this.emit('default-adapter-changed');
++ });
++ this._client.connect('device-removed', (c, path) => {
++ this._deviceNotifyConnected.delete(path);
++ this.emit('device-deleted');
++ });
++ this._client.connect('device-added', (c, device) => {
++ this._connectDeviceNotify(device);
++ this.emit('device-inserted', this._buildDevice(device));
++ });
++ return;
++ }
++
++ /* <= 41 */
+ this._connectSignal(this._model, 'row-changed', (arg0, arg1, iter) => {
+ if (iter) {
+ let device = this._buildDevice(iter);
+@@ -51,13 +82,36 @@ var BluetoothController = class {
+ });
+ }
+
++ _connectDeviceNotify(device) {
++ /* >= 42 only */
++ const path = device.get_object_path();
++
++ if (this._deviceNotifyConnected.has(path))
++ return;
++
++ device.connect('notify', (device) => {
++ this.emit('device-changed', this._buildDevice(device));
++ });
++ }
++
+ getDevices() {
++ let devices = [];
++
++ if (this._store) {
++ /* >= 42 */
++ for (let i = 0; i < this._store.get_n_items(); i++) {
++ let device = this._buildDevice(this._store.get_item(i));
++ devices.push(device);
++ }
++
++ return devices;
++ }
++
++ /* <= 41 */
+ let adapter = this._getDefaultAdapter();
+ if (!adapter)
+ return [];
+
+- let devices = [];
+-
+ let [ret, iter] = this._model.iter_children(adapter);
+ while (ret) {
+ let device = this._buildDevice(iter);
+@@ -79,6 +133,7 @@ var BluetoothController = class {
+ }
+
+ _getDefaultAdapter() {
++ /* <= 41 only */
+ let [ret, iter] = this._model.get_iter_first();
+ while (ret) {
+ let isDefault = this._model.get_value(iter, GnomeBluetooth.Column.DEFAULT);
+@@ -90,8 +145,14 @@ var BluetoothController = class {
+ return null;
+ }
+
+- _buildDevice(iter) {
+- return new BluetoothDevice(this._model, iter);
++ _buildDevice(devOrIter) {
++ if (this._store) {
++ /* >= 42 */
++ return new BluetoothDevice(null, devOrIter);
++ }
++
++ /* <= 41 */
++ return new BluetoothDevice(this._model, devOrIter);
+ }
+ }
+
+@@ -99,12 +160,25 @@ Signals.addSignalMethods(BluetoothController.prototype);
+ Utils.addSignalsHelperMethods(BluetoothController.prototype);
+
+ var BluetoothDevice = class {
+- constructor(model, iter) {
++ constructor(model, devOrIter) {
+ this._model = model;
+- this.update(iter);
++ this.update(devOrIter);
+ }
+
+- update(iter) {
++ update(devOrIter) {
++ if (!this._model) {
++ /* >= 42 */
++ const dev = devOrIter;
++ this.name = dev.alias || dev.name;
++ this.isConnected = dev.connected;
++ this.isPaired = dev.paired;
++ this.mac = dev.address;
++ this.isDefault = false;
++ return;
++ }
++
++ /* <= 41 */
++ const iter = devOrIter;
+ this.name = this._model.get_value(iter, GnomeBluetooth.Column.ALIAS) || this._model.get_value(iter, GnomeBluetooth.Column.NAME);
+ this.isConnected = this._model.get_value(iter, GnomeBluetooth.Column.CONNECTED);
+ this.isPaired = this._model.get_value(iter, GnomeBluetooth.Column.PAIRED);
+diff --git a/metadata.json b/metadata.json
+index 68effed..1a68657 100644
+--- a/metadata.json
++++ b/metadata.json
+@@ -7,6 +7,7 @@
+ "gettext-domain": "bluetooth-quick-connect",
+ "shell-version": [
+ "40",
+- "41"
++ "41",
++ "42"
+ ]
+ }