From d72d0412a5507f55ddbd25d56a4ca28f5b7b5da0 Mon Sep 17 00:00:00 2001 From: retrozinndev Date: Thu, 28 Aug 2025 18:52:03 -0300 Subject: [PATCH] :wrench: chore(control-center/pages/backlight): load the default backlight from user data --- src/widget/control-center/pages/Backlight.tsx | 11 +++++++++++ src/widget/control-center/pages/Page.tsx | 8 +++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/widget/control-center/pages/Backlight.tsx b/src/widget/control-center/pages/Backlight.tsx index e75c67f..d083a7f 100644 --- a/src/widget/control-center/pages/Backlight.tsx +++ b/src/widget/control-center/pages/Backlight.tsx @@ -11,6 +11,17 @@ export const PageBacklight = new Page({ id: "backlight", title: tr("control_center.pages.backlight.title"), description: tr("control_center.pages.backlight.description"), + $: () => { + const dataDefaultBacklight = userData.getProperty("control_center.default_backlight", "any"); + if(typeof dataDefaultBacklight === "string" && + Backlights.getDefault().default?.name !== dataDefaultBacklight) { + + const bk = Backlights.getDefault().backlights.filter(b => b.name === dataDefaultBacklight)[0]; + if(!bk) return; + + Backlights.getDefault().setDefault(bk); + } + }, content: () => ( {(bklights: Array) => bklights.length > 0 && diff --git a/src/widget/control-center/pages/Page.tsx b/src/widget/control-center/pages/Page.tsx index 4a684d6..33badca 100644 --- a/src/widget/control-center/pages/Page.tsx +++ b/src/widget/control-center/pages/Page.tsx @@ -10,6 +10,7 @@ export type PageProps = { id: string; title: string; description?: string; + $?: (self: Gtk.Box) => void; headerButtons?: Array | Accessor>; bottomButtons?: Array | Accessor>; orientation?: Gtk.Orientation | Accessor; @@ -42,6 +43,7 @@ export class Page { #spacing: number|Accessor = 4; #headerButtons?: Array|Accessor>; #bottomButtons?: Array|Accessor>; + #setup?: (self: Gtk.Box) => void; readonly #id?: string; readonly #create: () => WidgetNodeType; @@ -67,12 +69,16 @@ export class Page { if(props.headerButtons != null) this.#headerButtons = props.headerButtons; + + if(props.$ != null) + this.#setup = props.$; } public create(): Gtk.Box { return createRoot((dispose) => dispose()}> + orientation={Gtk.Orientation.VERTICAL} onUnmap={() => dispose()} + $={this.#setup}>