summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2022-09-18 18:02:07 +0100
committerSimon McVittie <smcv@debian.org>2022-09-18 20:22:29 +0100
commitb16e6edd25a70076e2d60c1044a091fc77a5c5e6 (patch)
tree9111ec20dd957b8dee6a35fb93b0f8f4ec62e791
parent0e105d9936c414256ba352c658e2a8680e7e76a9 (diff)
Integrate with Quick Settings menu in GNOME 43
Bug: https://github.com/bjarosze/gnome-bluetooth-quick-connect/issues/65 Bug-Debian: https://bugs.debian.org/1018186 Signed-off-by: Simon McVittie <smcv@debian.org> Forwarded: https://github.com/bjarosze/gnome-bluetooth-quick-connect/pull/66 Gbp-Pq: Name Integrate-with-Quick-Settings-menu-in-GNOME-43.patch
-rw-r--r--extension.js37
-rw-r--r--metadata.json3
-rw-r--r--quickSettings.js32
3 files changed, 64 insertions, 8 deletions
diff --git a/extension.js b/extension.js
index b3c7167..5cd5331 100644
--- a/extension.js
+++ b/extension.js
@@ -31,11 +31,24 @@ const BatteryProvider = Me.imports.power.UPowerBatteryProvider;
class BluetoothQuickConnect {
- constructor(bluetooth, settings) {
+ constructor(quickSettings, bluetooth, settings) {
this._logger = new Utils.Logger(settings);
this._logger.info('Initializing extension');
- this._menu = bluetooth._item.menu;
- this._proxy = bluetooth._proxy;
+ if (quickSettings) {
+ this._quickSettings = quickSettings;
+ this._btIndicator = quickSettings._bluetooth;
+ let oldItem = this._btIndicator.quickSettingsItems[0];
+ let newItem = new Me.imports.quickSettings.BluetoothToggleMenu(oldItem);
+ this._btIndicator.quickSettingsItems = [newItem];
+ quickSettings.menu.addItem(newItem);
+ quickSettings.menu._grid.set_child_below_sibling(newItem, oldItem);
+ quickSettings.menu._grid.remove_child(oldItem);
+ this._proxy = oldItem._proxy;
+ this._menu = newItem.menu;
+ } else {
+ this._menu = bluetooth._item.menu;
+ this._proxy = bluetooth._proxy;
+ }
this._controller = new Bluetooth.BluetoothController();
this._settings = settings;
this._battery_provider = new BatteryProvider(this._logger);
@@ -218,10 +231,20 @@ let bluetoothQuickConnect = null;
function init() {}
function enable() {
- bluetoothQuickConnect = new BluetoothQuickConnect(
- Main.panel.statusArea.aggregateMenu._bluetooth,
- new Settings()
- );
+ if (Main.panel.statusArea.quickSettings) {
+ bluetoothQuickConnect = new BluetoothQuickConnect(
+ Main.panel.statusArea.quickSettings,
+ null,
+ new Settings()
+ );
+ } else {
+ bluetoothQuickConnect = new BluetoothQuickConnect(
+ null,
+ Main.panel.statusArea.aggregateMenu._bluetooth,
+ new Settings()
+ );
+ }
+
bluetoothQuickConnect.test();
bluetoothQuickConnect.enable();
}
diff --git a/metadata.json b/metadata.json
index 924d940..7ccace1 100644
--- a/metadata.json
+++ b/metadata.json
@@ -8,6 +8,7 @@
"shell-version": [
"40",
"41",
- "42"
+ "42",
+ "43"
]
}
diff --git a/quickSettings.js b/quickSettings.js
new file mode 100644
index 0000000..d521811
--- /dev/null
+++ b/quickSettings.js
@@ -0,0 +1,32 @@
+// Copyright 2010-2022 GNOME Shell contributors
+// Copyright 2022 Simon McVittie
+// SPDX-License-Identifier: GPL-2.0-or-later
+//
+// Adapted from gnome-shell js/ui/status/bluetooth.js
+
+/* exported BluetoothToggleMenu */
+
+const {GObject} = imports.gi;
+const {QuickMenuToggle} = imports.ui.quickSettings;
+
+var BluetoothToggleMenu = GObject.registerClass(
+class BluetoothToggleMenu extends QuickMenuToggle {
+ _init(originalBluetoothToggle) {
+ super._init({label: originalBluetoothToggle.label});
+
+ this._original = originalBluetoothToggle;
+ this._client = this._original._client;
+
+ this._original.bind_property('visible', this, 'visible',
+ GObject.BindingFlags.SYNC_CREATE);
+ this._original.bind_property('checked', this, 'checked',
+ GObject.BindingFlags.SYNC_CREATE);
+ this._original.bind_property('icon-name', this, 'icon-name',
+ GObject.BindingFlags.SYNC_CREATE);
+
+ this.connect('clicked', () => this._client.toggleActive());
+
+ this.menu.setHeader('bluetooth-active-symbolic', originalBluetoothToggle.label);
+ }
+});
+