import { Accessor } from "ags"; import { tr } from "../i18n/intl"; import { CustomDialog } from "./CustomDialog"; import { Astal } from "ags/gtk4"; export type AskPopupProps = { title?: string | Accessor; text: string | Accessor; cancelText?: string; acceptText?: string; onAccept?: () => void; onCancel?: () => void; }; /** * A Popup Widget that asks yes or no to a defined promt. * Runs onAccept() when user accepts, or else onDecline() when * user doesn't accept / closes window. * This window isn't usually registered in this shell windowing * system. */ export function AskPopup(props: AskPopupProps): Astal.Window { let accepted: boolean = false; return !accepted && props.onCancel?.()} options={[ { text: props.cancelText ?? tr("cancel") }, { text: props.acceptText ?? tr("accept"), onClick: () => { accepted = true; props.onAccept?.(); } } ]} /> as Astal.Window; }