Controls
Two GTK controls stand on their own rather than inside a boxed list: a single-line
entry for typed text, and a drop down that picks one value from a list.
Libadwaita ships neither. Each has a boxed-list twin — Adw.EntryRow and
Adw.ComboRow — under Boxed Lists, and which one
you want is a question about the surrounding layout.
The two booleans sit here too: the checkbox with its third, half-made state, and
the light switch whose knob and trough are deliberately two different things. A
boolean in a row is a row widget instead — Adw.SwitchRow, Adw.ActionRow.
A single-line text field. Give it a placeholder to say what belongs in it
while it is empty, a value for the text itself, and disabled when it should
be read-only. For a field that belongs in a preferences group, use
Entry Row instead: the same control in
row presentation, with the label as the row title.
Drop Down
Section titled “Drop Down”Pick one value from a list. selected is the zero-based index of the chosen
option, and enable-search adds a filter field for a long list. For the same
choice presented as a boxed-list row, use
Combo Row.
Check Button
Section titled “Check Button”A label beside an indicator you can tick. On top of on and off it has a third state, indeterminate, for a selection that is only partly made — some of a range is affected — and it outranks on, exactly as it does for assistive technology. The grouped, single-choice form of a check button is a radio button; the browser port spells that Adw.Radio.
Switch
Section titled “Switch”A light switch, for a boolean that is on its own rather than in a row. Its two
properties are not the same thing, and that is the whole of Gtk.Switch: active
is where the user put it, state is what the thing being switched currently is.
Keep them equal and the switch is an ordinary toggle; let them differ and it is the
honest picture of a change that has not landed yet — the knob where you left it, the
trough still the old colour. Setting active on its own sets state too, because
GTK’s default ::state-set handler does exactly that; write state yourself, after
active, when you are driving the other half.
For a boolean with a title beside it, use Switch Row.
A slider. Gtk.Scale extends Gtk.Range, and Gtk.Range has no page of its own: it is
concrete (gtk_range_get_type() is a bare G_DEFINE_TYPE_WITH_CODE, gtkrange.c:267), but
GTK only ever builds one as the base of Gtk.Scale and Gtk.Scrollbar. Every property it
declares is therefore documented on one of those two — which is why this block reads
adjustment rather than a range.
The adjustment is the range: a JSON object with lower, upper, stepIncrement,
pageIncrement, pageSize and value. The last one is the value, so it belongs inside
the object rather than beside it. Dragging, the arrow keys and Page Up/Down all move by
stepIncrement and pageIncrement respectively, and Ctrl with an arrow pages.
digits is how many decimal places the value text carries, draw-value shows it at
all, and value-pos puts it top (the default), bottom, left or right. inverted
runs the scale the other way; for a horizontal scale it already is inverted in a
right-to-left document, which is what Gtk.Range’s flippable flag is for.
Spin Button
Section titled “Spin Button”A number field with an arrow either side of it. Its adjustment is the same JSON object the scale takes, so a range authored here is the one the scale above would use unchanged.
numeric refuses anything that is not a number as it is typed; digits is how many
decimal places the field shows and commits; snap-to-ticks moves a typed value onto the
step grid rather than leaving it between two steps; and wrap makes an arrow at a bound
jump to the other end instead of going insensitive. update-policy decides what a
rejected entry does: always clamps it into the range, if-valid leaves the committed
value alone and re-formats the field.
Password Entry
Section titled “Password Entry”A field for a secret: masked, no copy to the clipboard, and a warning while Caps Lock is engaged. show-peek-icon adds the button that reveals the contents for one look — off by default, and the only way to see them at all.
It is not a Gtk.Entry (it is a sibling that implements GtkEditable itself), but it takes
the same properties. For the row presentation, with the label as the row title, use
Password Entry Row.
Search Entry
Section titled “Search Entry”A field for typing a query. A magnifying glass leads while it is empty and a clear button
follows once it is not; clicking the clear button empties the field, exactly as C’s
edit-clear-symbolic press does.
The point of the widget is search-delay: search-changed waits 150 ms — the default —
after the last keypress, so a filter is not driven by every character. Emptying the field is
the one exception: that fires the signal at once and cancels whatever was pending.
The keys are the signals: Enter is activate, Escape is
stop-search, Ctrl+g is next-match and
Ctrl+Shift+g is previous-match.
Related
Section titled “Related”- Buttons: the plain button, its style classes and the menu button.
- Indicators: the progress bar, the level bar and the GTK spinner — how far along something is.
- Boxed Lists: the row twins of both controls, entry row, password entry row, combo row and spin row.
- Adwaita Storybook: the same widgets in a live component browser you can poke at.