diff options
Diffstat (limited to 'gjs/src/overrides.ts')
-rw-r--r-- | gjs/src/overrides.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gjs/src/overrides.ts b/gjs/src/overrides.ts new file mode 100644 index 0000000..e3d3df5 --- /dev/null +++ b/gjs/src/overrides.ts @@ -0,0 +1,23 @@ +import { Gtk, Astal } from "./imports.js" + +export function setChild(parent: Gtk.Widget, child: Gtk.Widget) { + if (parent instanceof Gtk.Bin) { + const rm = parent.get_child() + if (rm) + parent.remove(rm) + } + if (parent instanceof Gtk.Container) + parent.add(child) +} + +// gjs fails to map List types? +Object.defineProperty(Astal.Box.prototype, "children", { + get() { return this.get_children() }, + set(v) { this.set_children(v) }, +}) + +// gjs deprecated the child setter +Object.defineProperty(Gtk.Container.prototype, "child", { + get() { return this.get_child?.() }, + set(v) { setChild(this, v) }, +}) |