gex: trial of updating quicktoggle with dbus signal

This commit is contained in:
Luke D. Jones
2023-07-01 23:14:54 +12:00
parent 13965b2261
commit b002187b39
3 changed files with 12 additions and 5 deletions

View File

@@ -20,7 +20,7 @@ class Extension {
public _dbus_power!: Power;
public _dbus_anime!: AnimeDbus;
public dbus_platform!: Platform;
public dbus_platform: Platform = new Platform;
public dbus_supported!: Supported;
constructor() {
@@ -33,7 +33,7 @@ class Extension {
this.dbus_supported = new Supported();
this.dbus_supported.start();
this.dbus_platform = new Platform();
// this.dbus_platform = new Platform();
this.dbus_platform.start();
this._dbus_power = new Power();
@@ -55,6 +55,7 @@ class Extension {
if (this.dbus_supported.supported.rog_bios_ctrl.panel_overdrive) {
if (this._quickPanelOd == null) {
this._quickPanelOd = new QuickPanelOd(this.dbus_platform);
this.dbus_platform.notifyPanelOdSubscribers.push(this._quickPanelOd);
}
}
if (this.dbus_supported.supported.anime_ctrl) {

View File

@@ -12,6 +12,9 @@ export class Platform extends DbusBase {
mini_led_mode: false
};
// TODO: interface or something to enforce requirement of "sync()" method
public notifyPanelOdSubscribers: any[] = [];
constructor() {
super("org-asuslinux-platform-4", "/org/asuslinux/Platform");
}
@@ -142,6 +145,9 @@ export class Platform extends DbusBase {
if (proxy) {
//@ts-ignore
log(`NotifyPanelOd has changed to ${data}.`);
this.notifyPanelOdSubscribers.forEach(sub => {
sub.sync();
});
}
}
);

View File

@@ -35,17 +35,17 @@ export const QuickPanelOd = GObject.registerClass(
this, "checked",
Gio.SettingsBindFlags.DEFAULT);
this._sync();
this.sync();
addQuickSettingsItems([this]);
}
_toggleMode() {
this._dbus_platform.setPanelOd(this.checked);
this._sync();
this.sync();
}
_sync() {
sync() {
const checked = this._dbus_platform.getPanelOd();
if (this.checked !== checked)
this.set({ checked });