Within Odysseus’s addressbar popups I make extensive use of (styled) GtkLabel widgets, and GTK’s tooltips and menu options also uses it for much of their rendering.

So this morning I’ll discuss how GtkLabel works in GTK3, though it’ll mostly hand off to the text layout/rendering stack I described the other day.

Most of GtkLabel’s code is dedicated to wrapping a PangoLayoutContext with a GtkWidget, abstracting it’s capabilities behind several properties.

These layouts are repeatedly created during the sizing pass to try different widths, starting with the minimum and maximum widths (0 & NULL respectively). That’s used by the parents to compute the size for the final layout, which is what’s used for rendering.

While you might think GtkLabel is just for display, there’s a number of input gestures it supports.

There’s “mnemonics” which is rendered by Pango and registered to the container GtkWindow to dispatch to an associated widget.

There’s clickable hyperlinks that dispatches to the registered app by default.

And you can select text to be copy/pasted or drag/dropped, using a MultiPress gesture, DragGesture, or keyboard with help from Pango.

The latter two are rendered above the rest of the text.