summaryrefslogtreecommitdiff
path: root/core/gjs/src/widgets.ts
diff options
context:
space:
mode:
Diffstat (limited to 'core/gjs/src/widgets.ts')
-rw-r--r--core/gjs/src/widgets.ts154
1 files changed, 96 insertions, 58 deletions
diff --git a/core/gjs/src/widgets.ts b/core/gjs/src/widgets.ts
index 82d3b8f..e14ca0b 100644
--- a/core/gjs/src/widgets.ts
+++ b/core/gjs/src/widgets.ts
@@ -1,18 +1,23 @@
/* eslint-disable max-len */
-import { Astal, Gtk } from "./imports.js"
-import astalify, { type ConstructProps, type Widget } from "./astalify.js"
+import { Astal, GObject, Gtk } from "./imports.js"
+import astalify, { type ConstructProps, type BindableChild } from "./astalify.js"
export { astalify, ConstructProps }
// Box
-export type Box = Widget<Astal.Box>
-export const Box = astalify<typeof Astal.Box, BoxProps, "Box">(Astal.Box)
-export type BoxProps = ConstructProps<Astal.Box, Astal.Box.ConstructorProps>
+Object.defineProperty(Astal.Box.prototype, "children", {
+ get() { return this.get_children() },
+ set(v) { this.set_children(v) },
+})
+
+export type BoxProps = ConstructProps<Box, Astal.Box.ConstructorProps>
+export class Box extends astalify(Astal.Box) {
+ static { GObject.registerClass({ GTypeName: "Box" }, this) }
+ constructor(props?: BoxProps, ...children: Array<BindableChild>) { super({ children, ...props } as any) }
+}
// Button
-export type Button = Widget<Astal.Button>
-export const Button = astalify<typeof Astal.Button, ButtonProps, "Button">(Astal.Button)
-export type ButtonProps = ConstructProps<Astal.Button, Astal.Button.ConstructorProps, {
+export type ButtonProps = ConstructProps<Button, Astal.Button.ConstructorProps, {
onClicked: []
onClick: [event: Astal.ClickEvent]
onClickRelease: [event: Astal.ClickEvent]
@@ -20,97 +25,130 @@ export type ButtonProps = ConstructProps<Astal.Button, Astal.Button.ConstructorP
onHoverLost: [event: Astal.HoverEvent]
onScroll: [event: Astal.ScrollEvent]
}>
+export class Button extends astalify(Astal.Button) {
+ static { GObject.registerClass({ GTypeName: "Button" }, this) }
+ constructor(props?: ButtonProps, child?: BindableChild) { super({ child, ...props } as any) }
+}
// CenterBox
-export type CenterBox = Widget<Astal.CenterBox>
-export const CenterBox = astalify<typeof Astal.CenterBox, CenterBoxProps, "CenterBox">(Astal.CenterBox)
-export type CenterBoxProps = ConstructProps<Astal.CenterBox, Astal.CenterBox.ConstructorProps>
+export type CenterBoxProps = ConstructProps<CenterBox, Astal.CenterBox.ConstructorProps>
+export class CenterBox extends astalify(Astal.CenterBox) {
+ static { GObject.registerClass({ GTypeName: "CenterBox" }, this) }
+ constructor(props?: CenterBoxProps, ...children: Array<BindableChild>) { super({ children, ...props } as any) }
+}
// CircularProgress
-export type CircularProgress = Widget<Astal.CircularProgress>
-export const CircularProgress = astalify<typeof Astal.CircularProgress, CircularProgressProps, "CircularProgress">(Astal.CircularProgress)
-export type CircularProgressProps = ConstructProps<Astal.CircularProgress, Astal.CircularProgress.ConstructorProps>
-
+export type CircularProgressProps = ConstructProps<CircularProgress, Astal.CircularProgress.ConstructorProps>
+export class CircularProgress extends astalify(Astal.CircularProgress) {
+ static { GObject.registerClass({ GTypeName: "CircularProgress" }, this) }
+ constructor(props?: CircularProgressProps, child?: BindableChild) { super({ child, ...props } as any) }
+}
// DrawingArea
-export type DrawingArea = Widget<Gtk.DrawingArea>
-export const DrawingArea = astalify<typeof Gtk.DrawingArea, DrawingAreaProps, "DrawingArea">(Gtk.DrawingArea)
-export type DrawingAreaProps = ConstructProps<Gtk.DrawingArea, Gtk.DrawingArea.ConstructorProps, {
+export type DrawingAreaProps = ConstructProps<DrawingArea, Gtk.DrawingArea.ConstructorProps, {
onDraw: [cr: any] // TODO: cairo types
}>
+export class DrawingArea extends astalify(Gtk.DrawingArea) {
+ static { GObject.registerClass({ GTypeName: "DrawingArea" }, this) }
+ constructor(props?: DrawingAreaProps) { super(props as any) }
+}
// Entry
-export type Entry = Widget<Gtk.Entry>
-export const Entry = astalify<typeof Gtk.Entry, EntryProps, "Entry">(Gtk.Entry)
-export type EntryProps = ConstructProps<Gtk.Entry, Gtk.Entry.ConstructorProps, {
+export type EntryProps = ConstructProps<Entry, Gtk.Entry.ConstructorProps, {
onChanged: []
onActivate: []
}>
+export class Entry extends astalify(Gtk.Entry) {
+ static { GObject.registerClass({ GTypeName: "Entry" }, this) }
+ constructor(props?: EntryProps) { super(props as any) }
+}
// EventBox
-export type EventBox = Widget<Astal.EventBox>
-export const EventBox = astalify<typeof Astal.EventBox, EventBoxProps, "EventBox">(Astal.EventBox)
-export type EventBoxProps = ConstructProps<Astal.EventBox, Astal.EventBox.ConstructorProps, {
+export type EventBoxProps = ConstructProps<EventBox, Astal.EventBox.ConstructorProps, {
onClick: [event: Astal.ClickEvent]
onClickRelease: [event: Astal.ClickEvent]
onHover: [event: Astal.HoverEvent]
onHoverLost: [event: Astal.HoverEvent]
onScroll: [event: Astal.ScrollEvent]
}>
-
-// TODO: Fixed
-// TODO: FlowBox
-
+export class EventBox extends astalify(Astal.EventBox) {
+ static { GObject.registerClass({ GTypeName: "EventBox" }, this) }
+ constructor(props?: EventBoxProps, child?: BindableChild) { super({ child, ...props } as any) }
+}
+
+// // TODO: Fixed
+// // TODO: FlowBox
+//
// Icon
-export type Icon = Widget<Astal.Icon>
-export const Icon = astalify<typeof Astal.Icon, IconProps, "Icon">(Astal.Icon)
-export type IconProps = ConstructProps<Astal.Icon, Astal.Icon.ConstructorProps>
+export type IconProps = ConstructProps<Icon, Astal.Icon.ConstructorProps>
+export class Icon extends astalify(Astal.Icon) {
+ static { GObject.registerClass({ GTypeName: "Icon" }, this) }
+ constructor(props?: IconProps) { super(props as any) }
+}
// Label
-export type Label = Widget<Astal.Label>
-export const Label = astalify<typeof Astal.Label, LabelProps, "Label">(Astal.Label)
-export type LabelProps = ConstructProps<Astal.Label, Astal.Label.ConstructorProps>
+export type LabelProps = ConstructProps<Label, Astal.Label.ConstructorProps>
+export class Label extends astalify(Astal.Label) {
+ static { GObject.registerClass({ GTypeName: "Label" }, this) }
+ constructor(props?: LabelProps) { super(props as any) }
+}
// LevelBar
-export type LevelBar = Widget<Astal.LevelBar>
-export const LevelBar = astalify<typeof Astal.LevelBar, LevelBarProps, "LevelBar">(Astal.LevelBar)
-export type LevelBarProps = ConstructProps<Astal.LevelBar, Astal.LevelBar.ConstructorProps>
+export type LevelBarProps = ConstructProps<LevelBar, Astal.LevelBar.ConstructorProps>
+export class LevelBar extends astalify(Astal.LevelBar) {
+ static { GObject.registerClass({ GTypeName: "LevelBar" }, this) }
+ constructor(props?: LevelBarProps) { super(props as any) }
+}
// TODO: ListBox
// Overlay
-export type Overlay = Widget<Astal.Overlay>
-export const Overlay = astalify<typeof Astal.Overlay, OverlayProps, "Overlay">(Astal.Overlay)
-export type OverlayProps = ConstructProps<Astal.Overlay, Astal.Overlay.ConstructorProps>
+export type OverlayProps = ConstructProps<Overlay, Astal.Overlay.ConstructorProps>
+export class Overlay extends astalify(Astal.Overlay) {
+ static { GObject.registerClass({ GTypeName: "Overlay" }, this) }
+ constructor(props?: OverlayProps, ...children: Array<BindableChild>) { super({ children, ...props } as any) }
+}
// Revealer
-export type Revealer = Widget<Gtk.Revealer>
-export const Revealer = astalify<typeof Gtk.Revealer, RevealerProps, "Revealer">(Gtk.Revealer)
-export type RevealerProps = ConstructProps<Gtk.Revealer, Gtk.Revealer.ConstructorProps>
+export type RevealerProps = ConstructProps<Revealer, Gtk.Revealer.ConstructorProps>
+export class Revealer extends astalify(Gtk.Revealer) {
+ static { GObject.registerClass({ GTypeName: "Revealer" }, this) }
+ constructor(props?: RevealerProps, child?: BindableChild) { super({ child, ...props } as any) }
+}
// Scrollable
-export type Scrollable = Widget<Astal.Scrollable>
-export const Scrollable = astalify<typeof Astal.Scrollable, ScrollableProps, "Scrollable">(Astal.Scrollable)
-export type ScrollableProps = ConstructProps<Astal.Scrollable, Astal.Scrollable.ConstructorProps>
+export type ScrollableProps = ConstructProps<Scrollable, Astal.Scrollable.ConstructorProps>
+export class Scrollable extends astalify(Astal.Scrollable) {
+ static { GObject.registerClass({ GTypeName: "Scrollable" }, this) }
+ constructor(props?: ScrollableProps, child?: BindableChild) { super({ child, ...props } as any) }
+}
// Slider
-export type Slider = Widget<Astal.Slider>
-export const Slider = astalify<typeof Astal.Slider, SliderProps, "Slider">(Astal.Slider)
-export type SliderProps = ConstructProps<Astal.Slider, Astal.Slider.ConstructorProps, {
+export type SliderProps = ConstructProps<Slider, Astal.Slider.ConstructorProps, {
onDragged: []
}>
+export class Slider extends astalify(Astal.Slider) {
+ static { GObject.registerClass({ GTypeName: "Slider" }, this) }
+ constructor(props?: SliderProps) { super(props as any) }
+}
// Stack
-export type Stack = Widget<Astal.Stack>
-export const Stack = astalify<typeof Astal.Stack, StackProps, "Stack">(Astal.Stack)
-export type StackProps = ConstructProps<Astal.Stack, Astal.Stack.ConstructorProps>
+export type StackProps = ConstructProps<Stack, Astal.Stack.ConstructorProps>
+export class Stack extends astalify(Astal.Stack) {
+ static { GObject.registerClass({ GTypeName: "Stack" }, this) }
+ constructor(props?: StackProps, ...children: Array<BindableChild>) { super({ children, ...props } as any) }
+}
// Switch
-export type Switch = Widget<Gtk.Switch>
-export const Switch = astalify<typeof Gtk.Switch, SwitchProps, "Switch">(Gtk.Switch)
-export type SwitchProps = ConstructProps<Gtk.Switch, Gtk.Switch.ConstructorProps>
+export type SwitchProps = ConstructProps<Switch, Gtk.Switch.ConstructorProps>
+export class Switch extends astalify(Gtk.Switch) {
+ static { GObject.registerClass({ GTypeName: "Switch" }, this) }
+ constructor(props?: SwitchProps) { super(props as any) }
+}
// Window
-export type Window = Widget<Astal.Window>
-export const Window = astalify<typeof Astal.Window, WindowProps, "Window">(Astal.Window)
-export type WindowProps = ConstructProps<Astal.Window, Astal.Window.ConstructorProps>
+export type WindowProps = ConstructProps<Window, Astal.Window.ConstructorProps>
+export class Window extends astalify(Astal.Window) {
+ static { GObject.registerClass({ GTypeName: "Window" }, this) }
+ constructor(props?: WindowProps, child?: BindableChild) { super({ child, ...props } as any) }
+}