nixos-configs/modules/ags/gtk4/widget/subclasses/menubutton.ts
matt1432 ad69ef38ea
All checks were successful
Discord / discord commits (push) Has been skipped
feat(ags4): only accept widgets as children and some refactor
2025-01-12 20:12:46 -05:00

31 lines
858 B
TypeScript

import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4';
import astalify from './astalify';
export type MenuButtonProps = ConstructProps<
MenuButton,
Gtk.MenuButton.ConstructorProps & { css: string }
>;
@register({ GTypeName: 'MenuButton' })
export class MenuButton extends astalify(Gtk.MenuButton) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(props?: MenuButtonProps) { super(props as any); }
getChildren(self: MenuButton) {
return [self.popover, self.child];
}
setChildren(self: MenuButton, children: Gtk.Widget[]) {
for (const child of children) {
if (child instanceof Gtk.Popover) {
self.set_popover(child);
}
else {
self.set_child(child);
}
}
}
}