summaryrefslogtreecommitdiff
path: root/gjs/src/overrides.ts
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-06-07 00:50:17 +0200
committerAylur <[email protected]>2024-06-07 00:50:17 +0200
commit900a7420bd9aa92fc8b528636908de09f88bc2eb (patch)
tree0c7188853999a291e21e485e29b5cd77420bac04 /gjs/src/overrides.ts
parent100502a23344aa96c22faa70ea65529789624017 (diff)
add overrides
* Gtk.Container.child * Astal.Box.children
Diffstat (limited to 'gjs/src/overrides.ts')
-rw-r--r--gjs/src/overrides.ts23
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) },
+})