From b002187b39246e62f812ede542aa5965b80a4fd8 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sat, 1 Jul 2023 23:14:54 +1200 Subject: [PATCH] gex: trial of updating quicktoggle with dbus signal --- desktop-extensions/gnome/src/extension.ts | 5 +++-- desktop-extensions/gnome/src/modules/dbus/platform.ts | 6 ++++++ .../gnome/src/modules/quick_toggles/panel_od.ts | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/desktop-extensions/gnome/src/extension.ts b/desktop-extensions/gnome/src/extension.ts index c5a54e0e..c324f487 100644 --- a/desktop-extensions/gnome/src/extension.ts +++ b/desktop-extensions/gnome/src/extension.ts @@ -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) { diff --git a/desktop-extensions/gnome/src/modules/dbus/platform.ts b/desktop-extensions/gnome/src/modules/dbus/platform.ts index 07126fdf..3612b120 100644 --- a/desktop-extensions/gnome/src/modules/dbus/platform.ts +++ b/desktop-extensions/gnome/src/modules/dbus/platform.ts @@ -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(); + }); } } ); diff --git a/desktop-extensions/gnome/src/modules/quick_toggles/panel_od.ts b/desktop-extensions/gnome/src/modules/quick_toggles/panel_od.ts index 6a7f0b4b..ad90e79a 100644 --- a/desktop-extensions/gnome/src/modules/quick_toggles/panel_od.ts +++ b/desktop-extensions/gnome/src/modules/quick_toggles/panel_od.ts @@ -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 });