nixos-configs/modules/ags/gtk4/widget/subclasses/stack.ts
matt1432 c3c4054793
All checks were successful
Discord / discord commits (push) Has been skipped
refactor(ags4): split up astalify code
2025-01-14 10:12:20 -05:00

30 lines
845 B
TypeScript

import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4';
import astalify, { type AstalifyProps } from '../astalify';
export type StackProps = ConstructProps<
StackClass,
Gtk.Stack.ConstructorProps & AstalifyProps
>;
@register({ GTypeName: 'Stack' })
export class StackClass extends astalify(Gtk.Stack) {
constructor({ cssName = 'stack', ...props }: StackProps = {}) {
super({ cssName, ...props });
}
setChildren(self: StackClass, children: Gtk.Widget[]) {
for (const child of children) {
if (child.name !== '' && child.name !== null) {
self.add_named(child, child.name);
}
else {
self.add_child(child);
}
}
}
}
export const Stack = (props?: StackProps) => new StackClass(props);