summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2022-09-26 19:47:26 +0100
committerSimon McVittie <smcv@debian.org>2022-09-26 19:47:26 +0100
commitce486f7ba84f5c45efefdd7ab532eeabe12704e6 (patch)
tree94be9fca69a83a06b180d91118f31153d8e4c172
parentbb05b788814f36bb3f181089d9969e228630ea1e (diff)
parentd7e1999efde8396efc6f9d1b57005e34e26e8665 (diff)
New upstream version 30
-rw-r--r--README.md7
-rw-r--r--Settings.ui2
-rw-r--r--extension.js37
-rw-r--r--metadata.json3
-rw-r--r--quickSettings.js39
5 files changed, 74 insertions, 14 deletions
diff --git a/README.md b/README.md
index e07424f..2a654ad 100644
--- a/README.md
+++ b/README.md
@@ -19,10 +19,7 @@ https://extensions.gnome.org/extension/1401/bluetooth-quick-connect/
```
git clone https://github.com/bjarosze/gnome-bluetooth-quick-connect
cd gnome-bluetooth-quick-connect
-make
-rm -rf ~/.local/share/gnome-shell/extensions/bluetooth-quick-connect@bjarosze.gmail.com
-mkdir -p ~/.local/share/gnome-shell/extensions/bluetooth-quick-connect@bjarosze.gmail.com
-cp -r * ~/.local/share/gnome-shell/extensions/bluetooth-quick-connect@bjarosze.gmail.com
+make install
```
## Battery level
@@ -64,4 +61,4 @@ device after it was disconnected. Reinstalling bluez and rebooting system helped
```
$ sudo apt purge bluez gnome-bluetooth pulseaudio-module-bluetooth
$ sudo apt install bluez gnome-bluetooth pulseaudio-module-bluetooth
-``` \ No newline at end of file
+```
diff --git a/Settings.ui b/Settings.ui
index 5972e42..49c1e62 100644
--- a/Settings.ui
+++ b/Settings.ui
@@ -48,7 +48,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="label" translatable="yes">Checking idle inteval (seconds)</property>
+ <property name="label" translatable="yes">Checking idle interval (seconds)</property>
</object>
</child>
<child>
diff --git a/extension.js b/extension.js
index b3c7167..2802335 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) {
+ let btIndicator = quickSettings._bluetooth;
+ let oldItem = btIndicator.quickSettingsItems[0];
+ let newItem = new Me.imports.quickSettings.BluetoothToggleMenu(oldItem);
+
+ 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._client._proxy;
+ this._menu = newItem.itemsSection;
+ } 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..844e49d
--- /dev/null
+++ b/quickSettings.js
@@ -0,0 +1,39 @@
+// 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 PopupMenu = imports.ui.popupMenu;
+
+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);
+
+ this.itemsSection = new PopupMenu.PopupMenuSection();
+ this.menu.addMenuItem(this.itemsSection);
+ this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+ this.menu.addSettingsAction(_('Bluetooth Settings'), 'gnome-bluetooth-panel.desktop');
+ }
+});
+