Skip to content

Commit a614101

Browse files
committed
docs: window toggling
1 parent c3093f1 commit a614101

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

core/gjs/src/astalify.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ function setChildren(parent: Gtk.Widget, children: Gtk.Widget[]) {
1919
if (ch)
2020
parent.remove(ch)
2121
}
22-
else if (parent instanceof Gtk.Container &&
23-
!(parent instanceof Astal.Box ||
24-
parent instanceof Astal.Stack)) {
25-
for(const ch of parent.get_children())
26-
parent.remove(ch)
22+
else if (
23+
parent instanceof Gtk.Container &&
24+
!(parent instanceof Astal.Box || parent instanceof Astal.Stack)
25+
) {
26+
for (const ch of parent.get_children())
27+
parent.remove(ch)
2728
}
2829

2930
// TODO: add more container types

docs/guide/ags/cli-app.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,42 @@ ags -m "return 'hello';"
9595
# hello
9696
```
9797

98+
## Toggling Windows by their name
99+
100+
In order for AGS to know about your windows, you have to register them.
101+
You can do this by specifying a **unique** `name` and calling `App.add_window`
102+
103+
```tsx
104+
import { App } from "astal"
105+
106+
function Bar() {
107+
return <window name="Bar" setup={self => App.add_window(self)}>
108+
<box />
109+
</window>
110+
}
111+
```
112+
113+
You can also invoke `App.add_window` by simply passing the `App` to the `application` prop.
114+
115+
```tsx
116+
import { App } from "astal"
117+
118+
function Bar() {
119+
return <window name="Bar" application={App}>
120+
<box />
121+
</window>
122+
}
123+
```
124+
125+
:::warning
126+
When assigning the `application` prop make sure `name` comes before.
127+
Props are set sequentially and if name is applied after application it won't work.
128+
:::
129+
130+
```sh
131+
ags -t Bar
132+
```
133+
98134
## App without AGS
99135

100136
As mentioned before AGS is only a scaffolding tool. You can setup

0 commit comments

Comments
 (0)