diff options
author | Bartosz Jaroszewski <b.jarosze@gmail.com> | 2018-06-21 21:29:08 +0200 |
---|---|---|
committer | Bartosz Jaroszewski <b.jarosze@gmail.com> | 2018-06-21 21:29:08 +0200 |
commit | 5049e93dab523ef00694a7074d48dbf75ade802b (patch) | |
tree | c3bae80f970a3019c4f86606384c9c7d2b7c84f6 | |
parent | d09b5ce03aba1574e47541ac4e0f8862a3218c7b (diff) |
reload bluetooth model when enabling
-rw-r--r-- | extension.js | 22 | ||||
-rw-r--r-- | metadata.json | 3 |
2 files changed, 22 insertions, 3 deletions
diff --git a/extension.js b/extension.js index ff210f9..19b15de 100644 --- a/extension.js +++ b/extension.js @@ -59,26 +59,43 @@ class BluetoothDevice { class BluetoothQuickConnect { constructor(bluetooth) { - this._model = bluetooth._model; - this._getDefaultAdapter = bluetooth._getDefaultAdapter; this._menu = bluetooth._item.menu; this._signals = []; } enable() { + this._loadBluetoothModel(); let signal = this._menu.connect('open-state-changed', (menu, isOpen) => { if (isOpen) this._sync(); }); this._signals.push(signal); + this._sync(); } disable() { this._destroy(); } + _loadBluetoothModel() { + this._client = new GnomeBluetooth.Client(); + this._model = this._client.get_model(); + } + + _getDefaultAdapter() { + let [ret, iter] = this._model.get_iter_first(); + while (ret) { + let isDefault = this._model.get_value(iter, GnomeBluetooth.Column.DEFAULT); + let isPowered = this._model.get_value(iter, GnomeBluetooth.Column.POWERED); + if (isDefault && isPowered) + return iter; + ret = this._model.iter_next(iter); + } + return null; + } + _getPairedDevices() { let adapter = this._getDefaultAdapter(); if (!adapter) @@ -126,6 +143,7 @@ class BluetoothQuickConnect { } } +let bluetoothQuickConnect = null; function init() { let bluetooth = Main.panel.statusArea.aggregateMenu._bluetooth; diff --git a/metadata.json b/metadata.json index 2230e23..884be9d 100644 --- a/metadata.json +++ b/metadata.json @@ -4,6 +4,7 @@ "uuid": "bluetooth-quick-connect@bjarosze.gmail.com", "url": "https://github.com/bjarosze/gnome-bluetooth-quick-connect", "shell-version": [ - "3.26.2" + "3.26.2", + "3.28" ] } |