/* eslint-disable max-len */ import Gtk from "gi://Gtk" import Astal from "gi://Astal" import { kebabify } from "../src/binding.js" import proxy, { type ConstructProps, type Widget } from "../src/astalify.js" const proxify = proxy(Gtk, prop => `set_${kebabify(prop).replaceAll("-", "_")}`, { cssGetter: Astal.widget_get_css, cssSetter: Astal.widget_set_css, classGetter: Astal.widget_get_class_names, classSetter: Astal.widget_set_class_names, cursorGetter: Astal.widget_get_cursor, cursorSetter: Astal.widget_set_cursor, }) export function astalify< C extends typeof Gtk.Widget, P extends Record, N extends string = "Widget", >(klass: C) { // eslint-disable-next-line @typescript-eslint/no-unused-vars type Astal = Omit & { new(props?: P, ...children: Gtk.Widget[]): Widget (props?: P, ...children: Gtk.Widget[]): Widget } return proxify(klass) as unknown as Astal } // Label export const Label = astalify(Gtk.Label) export type LabelProps = ConstructProps // Icon export const Icon = astalify(Astal.Icon) export type IconProps = ConstructProps // Button export const Button = astalify(Astal.Button) export type ButtonProps = ConstructProps) => void }> // Window export const Window = astalify(Astal.Window) export type WindowProps = ConstructProps // Box export const Box = astalify(Astal.Box) export type BoxProps = ConstructProps // CenterBox export const CenterBox = astalify(Astal.CenterBox) export type CenterBoxProps = ConstructProps // EventBox export const EventBox = astalify(Astal.EventBox) export type EventBoxProps = ConstructProps