7.2 KiB
7.2 KiB
Builtin Intrinsic Elements
These are just Gtk widgets which can be used without explicitly importing. For
example <box /> and <Gtk.Box /> are exactly the same thing.
Gtk4
box
<box orientation={Gtk.Orientation.HORIZONTAL}>
<Child />
<Child />
<Child />
</box>
button
<button onClicked={() => print("clicked")}>
<Child />
</button>
centerbox
<centerbox orientation={Gtk.Orientation.HORIZONTAL}>
<Child $type="start" />
<Child $type="center" />
<Child $type="end" />
</centerbox>
drawingarea
<drawingarea
$={(self) =>
self.set_draw_func((area, cr, width, height) => {
//
})
}
/>
entry
<entry
placeholderText="Start typing..."
text=""
onNotifyText={({ text }) => print(text)}
/>
image
<image
file="/path/to/file.png"
iconName="system-search-symbolic"
pixelSize={16}
/>
label
<label
label="<span foreground='blue'>text</span>"
useMarkup
wrap
ellipsize={Pango.EllipsizeMode.END}
/>
levelbar
<levelbar
orientation={Gtk.Orientation.HORIZONTAL}
widthRequest={200}
value={0.5}
/>
menubutton
<menubutton>
button content
<popover>popover content</popover>
</menubutton>
overlay
<overlay>
<Child />
<Child $type="overlay" />
<Child $type="overlay" />
</overlay>
revealer
<revealer
transitionType={Gtk.RevealerTransitionType.SLIDE_RIGHT}
revealChild={true}
onNotifyChildRevealed={() => print("animation finished")}
>
<Child />
</revealer>
scrolledwindow
<scrolledwindow maxContentHeight={500}>
<Child />
</scrolledwindow>
slider
<slider
value={0.5}
min={0}
max={1}
onChangeValue={({ value }) => print(value)}
/>
stack
<stack visibleChildName="child2">
<Child $type="named" name="child1" />
<Child $type="named" name="child2" />
</stack>
switch
<switch active={true} onNotifyActive={({ active }) => print(active)} />
togglebutton
<togglebutton active={true} onToggled={({ active }) => print(active)} />
window
<window
visible
namespace="bar"
class="Bar"
monitor={0}
exclusivity={Astal.Exclusivity.EXCLUSIVE}
keymode={Astal.Keymode.ON_DEMAND}
anchor={
Astal.WindowAnchor.TOP | Astal.WindowAnchor.LEFT | Astal.WindowAnchor.RIGHT
}
/>
Warning
In Gtk4 windows are invisible by default, so don't forget to pass
visible.
Gtk3
box
<box orientation={Gtk.Orientation.HORIZONTAL}>
<Child />
<Child />
<Child />
</box>
button
<button onClicked={() => print("clicked")}>
<Child />
</button>
centerbox
<centerbox orientation={Gtk.Orientation.HORIZONTAL}>
<Child $type="start" />
<Child $type="center" />
<Child $type="end" />
</centerbox>
circularprogress
<circularprogress value={0.5} startAt={0.75} endAt={0.75}>
<icon />
</circularprogress>
circularprogress {
color: green;
background-color: black;
font-size: 6px;
margin: 2px;
min-width: 32px;
}
drawingarea
<drawingarea
onDraw={(self, cr) => {
//
}}
/>
entry
<entry
onChanged={({ text }) => print("text changed", text)}
onActivate={({ text }) => print("enter", text)}
/>
eventbox
<eventbox
onClick={(_, event) => {
print(event.modifier, event.button)
}}
/>
icon
<icon
// named icon or path to a file
icon="/path/to/file.png"
icon="missing-symbolic"
/>
icon {
font-size: 16px;
}
label
<label label="hello" maxWidthChars={16} wrap />
levelbar
<levelbar value={0.5} widthRequest={200} />
overlay
<overlay>
<Child>child</Child>
<Child>overlay 1</Child>
</overlay>
revealer
<revealer
transitionType={Gtk.RevealerTransitionType.SLIDE_RIGHT}
revealChild={true}
onNotifyChildRevealed={() => print("animation finished")}
>
<Child />
</revealer>
scrollable
<scrollable heightRequest={100}>
<Child />
</scrollable>
slider
<slider widthRequest={100} onDragged={({ value }) => print(value)} />
stack
<stack visibleChildName="child2">
<Child name="child1" />
<Child name="child2" />
</stack>
switch
<switch active={true} onNotifyActive={({ active }) => print(active)} />
overlay
<overlay>
<Child>child</Child>
<Child>overlay 1</Child>
<Child>overlay 1</Child>
</overlay>
togglebutton
<togglebutton active={true} onToggled={({ active }) => print(active)} />
window
<window
namespace="bar"
class="Bar"
monitor={0}
exclusivity={Astal.Exclusivity.EXCLUSIVE}
keymode={Astal.Keymode.ON_DEMAND}
anchor={
Astal.WindowAnchor.TOP | Astal.WindowAnchor.LEFT | Astal.WindowAnchor.RIGHT
}
/>