nixos-configs/modules/ags/gtk4/widget/subclasses/centerbox.ts
matt1432 362bc7314d
All checks were successful
Discord / discord commits (push) Has been skipped
feat(ags4): start subclassing widgets
2025-01-01 02:55:15 -05:00

29 lines
828 B
TypeScript

/* eslint-disable @typescript-eslint/no-explicit-any */
import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4';
import astalify, { filter } from './astalify';
export type CenterBoxProps = ConstructProps<
CenterBox,
Gtk.CenterBox.ConstructorProps & { css: string }
>;
@register({ GTypeName: 'CenterBox' })
export class CenterBox extends astalify(Gtk.CenterBox) {
constructor(props?: CenterBoxProps) { super(props as any); }
getChildren(box: CenterBox) {
return [box.startWidget, box.centerWidget, box.endWidget];
}
setChildren(box: CenterBox, children: any[]) {
const ch = filter(children);
box.startWidget = ch[0] || new Gtk.Box();
box.centerWidget = ch[1] || new Gtk.Box();
box.endWidget = ch[2] || new Gtk.Box();
}
}