GtkListBox

When you type something in Odysseus’s addressbar, it will autocomplete to a web address. By implying https:// and querying your browser history or maybe DuckDuckGo.

GTK does have a built in autocompletion widget, but I find myself needing to implement my own to feed it “live” autocompletions and emphasise more human readable labels. Most of which is handled by Gtk’s Popover and ListBox widgets.

This morning I will describe the latter.

GtkListBox wraps a GSequence of GtkListBoxRows “bins” (for per-row state/style), and does little more than position them vertically and interpret input events. These input events are pre-parsed using a GtkBindingEntry and GtkGestureMultiPress.

Interestingly, GtkListBox implements it’s own hittesting optimized for it’s invariants.

And usually it’s wrapped in a GtkScrolledWindow which I might discuss tomorrow.

Sorry, that was GtkGestureClick for interpreting mouse events.

This gesture wraps the widget’s “event” signal to check if the cursor/finger hasn’t moved too much before it fires it’s “click” signal, and it uses timeouts to differentitate single clicks from double clicks.

GtkBinding[Entry] meanwhile basically maps GDK keyboard events to the “signals” on some GObject class via a GHashTable.

Though it does also implement parsers, including one you can trigger from a CSS file. Meaning GtkEntry also uses this infrastructure.