nixos-configs/modules/ags/gtk4/widget/subclasses/menubutton.ts
matt1432 c8485430b9
All checks were successful
Discord / discord commits (push) Has been skipped
refactor(ags4): improve types and remove as many 'any' as possible
2025-01-14 00:09:11 -05:00

34 lines
973 B
TypeScript

import { register } from 'astal';
import { Gtk, type ConstructProps } from 'astal/gtk4';
import astalify, { type AstalifyProps } 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);