diff options
author | Simon McVittie <smcv@debian.org> | 2022-04-01 11:59:58 +0100 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2022-04-01 11:59:58 +0100 |
commit | 5cdc9b0b30700ab2215df4d01917950da18ffc11 (patch) | |
tree | c30ee227123cb1a609b57f3cf154b470ef3a0be6 | |
parent | 7e1227d1917a1b861329336f6cf5ee49dc92fc07 (diff) |
Add compatibility with GNOME Shell 42
Closes: #1008120
-rw-r--r-- | debian/control | 2 | ||||
-rw-r--r-- | debian/patches/bluetooth-Use-GListStore-for-GNOME-Shell-42.patch | 166 | ||||
-rw-r--r-- | debian/patches/bluetooth-Use-a-separate-signal-for-changes-to-the-defaul.patch | 61 | ||||
-rw-r--r-- | debian/patches/power-Use-var-syntax-to-export-object.patch | 26 | ||||
-rw-r--r-- | debian/patches/series | 3 |
5 files changed, 257 insertions, 1 deletions
diff --git a/debian/control b/debian/control index 37cb370..6928ee9 100644 --- a/debian/control +++ b/debian/control @@ -17,7 +17,7 @@ Package: gnome-shell-extension-bluetooth-quick-connect Architecture: all Depends: bluez, - gnome-shell (<< 42~), + gnome-shell (<< 43~), gnome-shell (>= 40~), ${misc:Depends}, Recommends: 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" + ] + } diff --git a/debian/patches/bluetooth-Use-a-separate-signal-for-changes-to-the-defaul.patch b/debian/patches/bluetooth-Use-a-separate-signal-for-changes-to-the-defaul.patch new file mode 100644 index 0000000..4d362e8 --- /dev/null +++ b/debian/patches/bluetooth-Use-a-separate-signal-for-changes-to-the-defaul.patch @@ -0,0 +1,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}`); diff --git a/debian/patches/power-Use-var-syntax-to-export-object.patch b/debian/patches/power-Use-var-syntax-to-export-object.patch new file mode 100644 index 0000000..f78f353 --- /dev/null +++ b/debian/patches/power-Use-var-syntax-to-export-object.patch @@ -0,0 +1,26 @@ +From: Simon McVittie <smcv@debian.org> +Date: Thu, 31 Mar 2022 00:17:29 +0100 +Subject: power: Use var syntax to export object + +As per <https://gjs.guide/guides/gjs/intro.html#imports-and-modules>. +This seems to be required by GNOME Shell 42 (gjs 1.72). + +Signed-off-by: Simon McVittie <smcv@debian.org> +Forwarded: https://github.com/bjarosze/gnome-bluetooth-quick-connect/pull/55 +--- + power.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/power.js b/power.js +index 2d82ad1..e15e24b 100644 +--- a/power.js ++++ b/power.js +@@ -3,7 +3,7 @@ const UPower = imports.gi.UPowerGlib; + const Me = ExtensionUtils.getCurrentExtension(); + const Utils = Me.imports.utils; + +-class UPowerBatteryProvider { ++var UPowerBatteryProvider = class { + constructor(logger) { + this._upower_client = UPower.Client.new(); + this._logger = logger; diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..7140a30 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,3 @@ +power-Use-var-syntax-to-export-object.patch +bluetooth-Use-a-separate-signal-for-changes-to-the-defaul.patch +bluetooth-Use-GListStore-for-GNOME-Shell-42.patch |