You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using `attribute` has the benefit of it being a gobject
69
+
which means it will signal `notify::attribute` when it changes
70
+
71
+
```js
72
+
constMyWidget= () =>Widget.Button({
73
+
attribute:"anything",
74
+
setup:self=>self.on("notify::attribute", () => {
75
+
console.log(mywidget.attribute)
76
+
}),
77
+
})
78
+
79
+
constmywidget=MyWidget()
80
+
console.log(mywidget.attribute) // anything
81
+
82
+
// this line will invoke the above console.log in the setup
83
+
mywidget.attribute="something else"
84
+
```
85
+
86
+
keep in mind that `attribute` will only signal if *its value* changes
87
+
88
+
```js
89
+
constMyWidget= () =>Widget.Button({
90
+
attribute: {
91
+
someKey:"value",
92
+
key:"value",
93
+
},
94
+
setup:self=>self.on("notify::attribute", () => {
95
+
console.log(mywidget.attribute)
96
+
})
97
+
})
98
+
99
+
constmywidget=MyWidget()
100
+
101
+
// this line won't signal, because the attribute is still the same object
102
+
mywidget.attribute.key="new value"
103
+
104
+
// to have it signal, assign a new object to it
105
+
mywidget.attribute= {
106
+
...mywidget.attribute,
107
+
key:"new value"
108
+
}
109
+
```
110
+
111
+
## Common Gtk properties
112
+
22
113
Some common Gtk.Widget properties you might want for example
23
114
24
115
| Property | Type | Description |
25
116
|----------|------|-------------|
26
-
| hexpand | boolean | Expand horizontally. |
27
-
| vexpand | boolean | Expand vertically. |
28
-
| sensitive | boolean | Makes the widget interactable. |
29
-
| tooltip-text | string | Tooltip popup when the widget is hovered over. |
30
-
| visible | boolean | Visibility of the widget. Setting this to `false` doesn't have any effect if the parent container calls `show_all()`, for example when you set a Box's children dynamically. |
117
+
| hexpand |`boolean`| Expand horizontally. |
118
+
| vexpand |`boolean`| Expand vertically. |
119
+
| sensitive |`boolean`| Makes the widget interactable. |
120
+
| tooltip-text |`string`| Tooltip popup when the widget is hovered over. |
121
+
| visible |`boolean`| Visibility of the widget. Setting this to `false` doesn't have any effect if the parent container calls `show_all()`, for example when you set a Box's children dynamically. |
122
+
123
+
## toggleClassName
31
124
32
125
If you don't want to mutate the `classNames` array,
33
126
there is `toggleClassName`: `(name: string, enable: boolean) => void`
@@ -54,15 +147,15 @@ the toplevel widget that holds everything
54
147
55
148
| Property | Type | Description |
56
149
|----------|------|-------------|
57
-
| child | Widget ||
58
-
| name | string | Name of the window. This has to be unique, if you pass it in config. This will also be the name of the layer. |
59
-
| anchor | string[]| Valid values are `"top"`, `"bottom"`, `"left"`, `"right"`. Anchor points of the window. Leave it empty to make it centered. |
60
-
| exclusivity | string | Specify if the compositor should reserve space for the window automatically or how the window should interact with windows that do. Possible values: `exclusive` (space should be reserved), `normal` (the window should move if occluding another), `ignore` (the window should not be moved). Default: `normal`. |
61
-
| layer | string | Valid values are `"overlay"`, `"top"`, `"bottom"`, `"background"`. It is `"top"` by default. |
62
-
| margins | number[]| Corresponds to CSS notation, e.g `[0, 6]` would have 0 margin on the top and bottom and would have 6 on the right and left. |
63
-
| monitor | number | Which monitor to show the window on. If it is left undefined the window will show on the currently focused monitor. |
64
-
| keymode | string | Valid values are `"none"`, `"on-demand"`: can receive keyboard input if focused, `"exclusive"`: steal keyboard input on top and overlay layers |
65
-
| gdkmonitor | Gdk.Monitor | alternative to `monitor`|
150
+
| child |`Widget`||
151
+
| name |`string`| Name of the window. This has to be unique, if you pass it in config. This will also be the name of the layer. |
152
+
| anchor |`string[]`| Valid values are `"top"`, `"bottom"`, `"left"`, `"right"`. Anchor points of the window. Leave it empty to make it centered. |
153
+
| exclusivity |`string`| Specify if the compositor should reserve space for the window automatically or how the window should interact with windows that do. Possible values: `exclusive` (space should be reserved), `normal` (the window should move if occluding another), `ignore` (the window should not be moved). Default: `normal`. |
154
+
| layer |`string`| Valid values are `"overlay"`, `"top"`, `"bottom"`, `"background"`. It is `"top"` by default. |
155
+
| margins |`number[]`| Corresponds to CSS notation, e.g `[0, 6]` would have 0 margin on the top and bottom and would have 6 on the right and left. |
156
+
| monitor |`number`| Which monitor to show the window on. If it is left undefined the window will show on the currently focused monitor. |
157
+
| keymode |`string`| Valid values are `"none"`, `"on-demand"`: can receive keyboard input if focused, `"exclusive"`: steal keyboard input on top and overlay layers |
158
+
| gdkmonitor |`Gdk.Monitor`| alternative to `monitor`|
66
159
67
160
```js
68
161
constwindow=Widget.Window({
@@ -85,8 +178,8 @@ the main container widget
85
178
86
179
| Property | Type | Description |
87
180
|----------|------|-------------|
88
-
| vertical | bool | setting `vertical: true` is the same as `orientation: 1`|
89
-
| children | Widget[]| List of child widgets. |
181
+
| vertical |`bool`| setting `vertical: true` is the same as `orientation: 1`|
182
+
| children |`Widget[]`| List of child widgets. |
90
183
91
184
```js
92
185
constbox=Widget.Box({
@@ -107,7 +200,7 @@ subclass of [Gtk.Button](https://gjs-docs.gnome.org/gtk30~3.0/gtk.button)
@@ -386,8 +479,8 @@ subclass of [Gtk.Label](https://gjs-docs.gnome.org/gtk30~3.0/gtk.label)
386
479
387
480
| Property | Type | Description |
388
481
|----------|------|-------------|
389
-
| justification | string | Valid values are `"left"`, `"center"`, `"right"`, `"fill"`. Same as `justify` but represented as a string instead of enum. |
390
-
| truncate | string | Valid values are `"none"`, `"start"`, `"middle"`, `"end"`. Same as `ellipsize` but represented as a string instead of enum. |
482
+
| justification |`string`| Valid values are `"left"`, `"center"`, `"right"`, `"fill"`. Same as `justify` but represented as a string instead of enum. |
483
+
| truncate |`string`| Valid values are `"none"`, `"start"`, `"middle"`, `"end"`. Same as `ellipsize` but represented as a string instead of enum. |
391
484
392
485
```js
393
486
constlabel=Widget.Label({
@@ -410,8 +503,8 @@ subclass of [Gtk.LevelBar](https://gjs-docs.gnome.org/gtk30~3.0/gtk.levelbar)
410
503
411
504
| Property | Type | Description |
412
505
|----------|------|-------------|
413
-
| bar-mode | string | Valid values are `"continuous"`, `"discrete"`. Same as `mode` but represented as a string instead of enum. |
414
-
| vertical | bool | setting `vertical: true` is the same as `orientation: 1`|
506
+
| bar-mode |`string`| Valid values are `"continuous"`, `"discrete"`. Same as `mode` but represented as a string instead of enum. |
507
+
| vertical |`bool`| setting `vertical: true` is the same as `orientation: 1`|
415
508
416
509
```js
417
510
constcontinuous=Widget.LevelBar({
@@ -450,7 +543,7 @@ subclass of [Gtk.Menu](https://gjs-docs.gnome.org/gtk30~3.0/gtk.menu)
@@ -495,7 +588,7 @@ subclass of [Gtk.MenuItem](https://gjs-docs.gnome.org/gtk30~3.0/gtk.menuitem)
495
588
496
589
| Property | Type |
497
590
|----------|------|
498
-
| child | Widget |
591
+
| child |`Widget`|
499
592
| on-activate |`() => boolean`|
500
593
| on-select |`() => boolean`|
501
594
| on-deselect |`() => boolean`|
@@ -521,9 +614,9 @@ top of each other and won't render them outside the container.
521
614
522
615
| Property | Type | Description|
523
616
|----------|------|------------|
524
-
| child | Widget | Child which will determine the size of the overlay |
525
-
| overlays | Widget[]| Overlayed children |
526
-
| pass-through | boolean | Whether the overlay childs should pass the input through |
617
+
| child |`Widget`| Child which will determine the size of the overlay |
618
+
| overlays |`Widget[]`| Overlayed children |
619
+
| pass-through |`boolean`| Whether the overlay childs should pass the input through |
527
620
528
621
### ProgressBar
529
622
@@ -535,8 +628,8 @@ You might want to use `LevelBar` instead.
535
628
536
629
| Property | Type | Description |
537
630
|----------|------|-------------|
538
-
| vertical | bool | Setting `vertical: true` is the same as `orientation: 1`|
539
-
| value | number | Same as `ProgressBar.fraction`|
631
+
| vertical |`bool`| Setting `vertical: true` is the same as `orientation: 1`|
632
+
| value |`number`| Same as `ProgressBar.fraction`|
540
633
541
634
```js
542
635
constprogressbar=Widget.ProgressBar({
@@ -550,8 +643,8 @@ subclass of [Gtk.Revealer](https://gjs-docs.gnome.org/gtk30~3.0/gtk.revealer)
550
643
551
644
| Property | Type | Description |
552
645
|----------|------|-------------|
553
-
| child | Widget ||
554
-
| transition | string | Valid values are `"none"`, `"crossfade"`, `"slide_left"`, `"slide_right"`, `"slide_down"`, `"slide_up"`. This is `transitionType` represented as a string instead of enum. |
646
+
| child |`Widget`||
647
+
| transition |`string`| Valid values are `"none"`, `"crossfade"`, `"slide_left"`, `"slide_right"`, `"slide_down"`, `"slide_up"`. This is `transitionType` represented as a string instead of enum. |
555
648
556
649
```js
557
650
constrevealer=Widget.Revealer({
@@ -571,9 +664,9 @@ subclass of [Gtk.ScrolledWindow](https://gjs-docs.gnome.org/gtk30~3.0/gtk.scroll
0 commit comments