♻️ refactor(pages): rename onClose function/property to actionClose
This commit is contained in:
@@ -34,7 +34,7 @@ export const BluetoothPage = () => <Page
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
]}
|
]}
|
||||||
onClose={() => AstalBluetooth.get_default().adapter.discovering &&
|
actionClose={() => AstalBluetooth.get_default().adapter.discovering &&
|
||||||
AstalBluetooth.get_default().adapter.stop_discovery()}
|
AstalBluetooth.get_default().adapter.stop_discovery()}
|
||||||
bottomButtons={[{
|
bottomButtons={[{
|
||||||
title: tr("control_center.pages.more_settings"),
|
title: tr("control_center.pages.more_settings"),
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import AstalWp from "gi://AstalWp?version=0.1";
|
|||||||
import { lookupIcon } from "../../../scripts/apps";
|
import { lookupIcon } from "../../../scripts/apps";
|
||||||
|
|
||||||
|
|
||||||
export function PageMicrophone(): Page {
|
export const PageMicrophone = () =>
|
||||||
return <Page id={"microphone"} title={tr("control_center.pages.microphone.title")}
|
<Page id={"microphone"} title={tr("control_center.pages.microphone.title")}
|
||||||
description={tr("control_center.pages.microphone.description")}>
|
description={tr("control_center.pages.microphone.description")}>
|
||||||
|
|
||||||
<Gtk.Label class={"sub-header"} label={tr("devices")} xalign={0} />
|
<Gtk.Label class={"sub-header"} label={tr("devices")} xalign={0} />
|
||||||
@@ -27,4 +27,3 @@ export function PageMicrophone(): Page {
|
|||||||
/>}
|
/>}
|
||||||
</For>
|
</For>
|
||||||
</Page> as Page;
|
</Page> as Page;
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Astal, Gtk } from "ags/gtk4";
|
|||||||
import { addSliderMarksFromMinMax } from "../../../scripts/utils";
|
import { addSliderMarksFromMinMax } from "../../../scripts/utils";
|
||||||
import { createBinding } from "ags";
|
import { createBinding } from "ags";
|
||||||
|
|
||||||
export const PageNightLight: (() => Page) = () =>
|
export const PageNightLight = () =>
|
||||||
<Page id={"night-light"} title={tr("control_center.pages.night_light.title")}
|
<Page id={"night-light"} title={tr("control_center.pages.night_light.title")}
|
||||||
description={tr("control_center.pages.night_light.description")}
|
description={tr("control_center.pages.night_light.description")}
|
||||||
class={"night-light"}>
|
class={"night-light"}>
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ import { Gtk } from "ags/gtk4";
|
|||||||
import { Separator } from "../../Separator";
|
import { Separator } from "../../Separator";
|
||||||
import { Accessor, For } from "ags";
|
import { Accessor, For } from "ags";
|
||||||
import { transform, transformWidget, variableToBoolean, WidgetNodeType } from "../../../scripts/utils";
|
import { transform, transformWidget, variableToBoolean, WidgetNodeType } from "../../../scripts/utils";
|
||||||
|
|
||||||
import Pango from "gi://Pango?version=1.0";
|
import Pango from "gi://Pango?version=1.0";
|
||||||
|
|
||||||
|
|
||||||
export type PageProps = {
|
export type PageProps = {
|
||||||
$?: () => void;
|
$?: () => void;
|
||||||
onClose?: () => void;
|
actionClose?: () => void;
|
||||||
id: string;
|
id: string;
|
||||||
class?: string | Accessor<string>;
|
class?: string | Accessor<string>;
|
||||||
title: string | Accessor<string>;
|
title: string | Accessor<string>;
|
||||||
@@ -31,27 +33,23 @@ export { Page };
|
|||||||
|
|
||||||
@register({ GTypeName: "Page" })
|
@register({ GTypeName: "Page" })
|
||||||
class Page extends Gtk.Box {
|
class Page extends Gtk.Box {
|
||||||
readonly #id: string | number;
|
#id: string | number = "";
|
||||||
readonly bottomButtons?: Array<BottomButton>;
|
readonly bottomButtons?: Array<BottomButton> = [];
|
||||||
|
|
||||||
#subs: Array<() => void> = [];
|
#subs: Array<() => void> = [];
|
||||||
#title: string | Accessor<string>;
|
#title: string | Accessor<string> = "";
|
||||||
#description?: string | Accessor<string>;
|
#description?: string | Accessor<string>;
|
||||||
|
|
||||||
public get title() { return this.#title; }
|
public get title() { return this.#title; }
|
||||||
public get description() { return this.#description; }
|
public get description() { return this.#description; }
|
||||||
public get id() { return this.#id; }
|
public get id() { return this.#id; }
|
||||||
public onClose?: () => void;
|
public actionClose?: () => void = () => {};
|
||||||
|
|
||||||
constructor(props: PageProps) {
|
constructor(props: PageProps) {
|
||||||
super({
|
super();
|
||||||
hexpand: true,
|
|
||||||
orientation: Gtk.Orientation.VERTICAL
|
|
||||||
});
|
|
||||||
|
|
||||||
this.#id = props.id;
|
this.set_hexpand(true);
|
||||||
this.#title = props.title;
|
this.set_orientation(Gtk.Orientation.VERTICAL);
|
||||||
this.#description = props.description;
|
|
||||||
|
|
||||||
if(props.class instanceof Accessor) {
|
if(props.class instanceof Accessor) {
|
||||||
this.#subs.push(props.class.subscribe(() => {
|
this.#subs.push(props.class.subscribe(() => {
|
||||||
@@ -67,6 +65,11 @@ class Page extends Gtk.Box {
|
|||||||
this.add_css_class("page");
|
this.add_css_class("page");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.#id = props.id;
|
||||||
|
this.#title = props.title;
|
||||||
|
this.#description = props.description;
|
||||||
|
this.actionClose = props.actionClose;
|
||||||
|
|
||||||
this.prepend(<Gtk.Box class={"header"} orientation={Gtk.Orientation.VERTICAL}
|
this.prepend(<Gtk.Box class={"header"} orientation={Gtk.Orientation.VERTICAL}
|
||||||
hexpand={true}>
|
hexpand={true}>
|
||||||
|
|
||||||
@@ -117,7 +120,6 @@ class Page extends Gtk.Box {
|
|||||||
)}
|
)}
|
||||||
</Gtk.Box> as Gtk.Box);
|
</Gtk.Box> as Gtk.Box);
|
||||||
|
|
||||||
this.onClose = props.onClose;
|
|
||||||
props.$?.();
|
props.$?.();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user