summaryrefslogtreecommitdiff
path: root/examples/gtk4/simple-bar/js/src/ts/props.ts
diff options
context:
space:
mode:
authorAylur <[email protected]>2025-03-01 20:59:09 +0100
committerAylur <[email protected]>2025-03-01 21:02:29 +0100
commit23cdbc8088b5c308a068b432a6b03213ede68f07 (patch)
tree1e8bd6ffde5273fcd80aca0d30cbb38dbe5f9461 /examples/gtk4/simple-bar/js/src/ts/props.ts
parentdfd1f23c7562694e571d44c45aa74fcea9b1ba01 (diff)
add gtk4 examples
Diffstat (limited to 'examples/gtk4/simple-bar/js/src/ts/props.ts')
-rw-r--r--examples/gtk4/simple-bar/js/src/ts/props.ts45
1 files changed, 45 insertions, 0 deletions
diff --git a/examples/gtk4/simple-bar/js/src/ts/props.ts b/examples/gtk4/simple-bar/js/src/ts/props.ts
new file mode 100644
index 0000000..dfa79ee
--- /dev/null
+++ b/examples/gtk4/simple-bar/js/src/ts/props.ts
@@ -0,0 +1,45 @@
+import GObject from "gi://GObject?version=2.0"
+
+export function string(name: string, defaultValue = "") {
+ return {
+ [name]: GObject.ParamSpec.string(
+ name,
+ null,
+ null,
+ GObject.ParamFlags.READWRITE,
+ defaultValue,
+ ),
+ }
+}
+
+export function number(
+ name: string,
+ min = -Number.MIN_SAFE_INTEGER,
+ max = Number.MAX_SAFE_INTEGER,
+ defaultValue = 0,
+) {
+ return {
+ [name]: GObject.ParamSpec.double(
+ name,
+ null,
+ null,
+ GObject.ParamFlags.READWRITE,
+ min,
+ max,
+ defaultValue,
+ ),
+ }
+}
+
+export function boolean(name: string, defaultValue = false) {
+ return {
+ [name]: GObject.ParamSpec.boolean(
+ name,
+ null,
+ null,
+ GObject.ParamFlags.READWRITE,
+ defaultValue,
+ ),
+ }
+}
+