nixos-configs/modules/ags/gtk4/widget/subclasses/menubutton.ts
matt1432 e7accbd7bd
All checks were successful
Discord / discord commits (push) Has been skipped
feat(ags4): write own ConstructProps to exclude props
2025-01-15 18:17:27 -05:00

34 lines
974 B
TypeScript

import { register } from 'astal';
import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type MenuButtonProps = ConstructProps<
MenuButtonClass,
Gtk.MenuButton.ConstructorProps & AstalifyProps
>;
@register({ GTypeName: 'MenuButton' })
export class MenuButtonClass extends astalify(Gtk.MenuButton) {
constructor({ cssName = 'menubutton', ...props }: MenuButtonProps = {}) {
super({ cssName, ...props });
}
getChildren(self: MenuButtonClass) {
return [self.popover, self.child];
}
setChildren(self: MenuButtonClass, children: Gtk.Widget[]) {
for (const child of children) {
if (child instanceof Gtk.Popover) {
self.set_popover(child);
}
else {
self.set_child(child);
}
}
}
}
export const MenuButton = (props?: MenuButtonProps) => new MenuButtonClass(props);