status/bluetooth: Expose adapter-state
GnomeBluetooth now exposes a more precise state than the binary "adapter fully powerered on/off" property. Expose that on the BtClient object to make it available to the toggle and indicator. https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5773 Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2444>
This commit is contained in:
parent
9bda370636
commit
d54dc08a32
@ -7,6 +7,8 @@ const {QuickToggle, SystemIndicator} = imports.ui.quickSettings;
|
|||||||
|
|
||||||
const {loadInterfaceXML} = imports.misc.fileUtils;
|
const {loadInterfaceXML} = imports.misc.fileUtils;
|
||||||
|
|
||||||
|
const {AdapterState} = GnomeBluetooth;
|
||||||
|
|
||||||
const BUS_NAME = 'org.gnome.SettingsDaemon.Rfkill';
|
const BUS_NAME = 'org.gnome.SettingsDaemon.Rfkill';
|
||||||
const OBJECT_PATH = '/org/gnome/SettingsDaemon/Rfkill';
|
const OBJECT_PATH = '/org/gnome/SettingsDaemon/Rfkill';
|
||||||
|
|
||||||
@ -23,6 +25,9 @@ const BtClient = GObject.registerClass({
|
|||||||
'active': GObject.ParamSpec.boolean('active', '', '',
|
'active': GObject.ParamSpec.boolean('active', '', '',
|
||||||
GObject.ParamFlags.READABLE,
|
GObject.ParamFlags.READABLE,
|
||||||
false),
|
false),
|
||||||
|
'adapter-state': GObject.ParamSpec.enum('adapter-state', '', '',
|
||||||
|
GObject.ParamFlags.READABLE,
|
||||||
|
AdapterState, AdapterState.ABSENT),
|
||||||
},
|
},
|
||||||
Signals: {
|
Signals: {
|
||||||
'devices-changed': {},
|
'devices-changed': {},
|
||||||
@ -38,6 +43,8 @@ const BtClient = GObject.registerClass({
|
|||||||
this.notify('active');
|
this.notify('active');
|
||||||
this.notify('available');
|
this.notify('available');
|
||||||
});
|
});
|
||||||
|
this._client.connect('notify::default-adapter-state',
|
||||||
|
() => this.notify('adapter-state'));
|
||||||
this._client.connect('notify::default-adapter', () => {
|
this._client.connect('notify::default-adapter', () => {
|
||||||
const newAdapter = this._client.default_adapter ?? null;
|
const newAdapter = this._client.default_adapter ?? null;
|
||||||
|
|
||||||
@ -95,6 +102,10 @@ const BtClient = GObject.registerClass({
|
|||||||
return this._client.default_adapter_powered;
|
return this._client.default_adapter_powered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get adapter_state() {
|
||||||
|
return this._client.default_adapter_state;
|
||||||
|
}
|
||||||
|
|
||||||
toggleActive() {
|
toggleActive() {
|
||||||
this._proxy.BluetoothAirplaneMode = this.active;
|
this._proxy.BluetoothAirplaneMode = this.active;
|
||||||
if (!this._client.default_adapter_powered)
|
if (!this._client.default_adapter_powered)
|
||||||
|
Loading…
Reference in New Issue
Block a user