Subclassing GtkWidget: implementing widget size and layout constraints

I have created a GtkBox subclass that defines its UI in a GtkBuilder template. The box contains 3 child widgets, so it ends up looking something like this:

Screenshot from 2023-09-13 09-51-49

I’m trying to reason my way through the layout logic so that this widget can request an appropriate minimum size. Right now, I can resize the window so small that it starts to clip over other widgets in the window, like this:

When I resize the window like that, I see messages like this in the console:

(damask:2): Adwaita-WARNING **: 09:52:22.033: DamaskWindow 0x559a83b7ae80 does not have a minimum size

(damask:2): Adwaita-WARNING **: 09:52:22.033: AdwToastOverlay 0x559a83b7bbb0 exceeds DamaskWindow width: requested 241 px, 197 px available

I’m guessing I need to implement the measure vfunc, but I can’t find an example that clearly explains how. Does anyone have any working examples of how the layout and measurement system works?

No, it means you need width-request and height-request on the window.

As per docs: Adw.Window

Like AdwBreakpointBin, if breakpoints are used, AdwWindow doesn’t have a minimum size, and GtkWidget:width-request and GtkWidget:height-request properties must be set manually.

I need to make the warning clearer tho, mentioning those properties. Should be a nice last-minute fix.

Ooooh, I see. Without breakpoints, does the widget hierarchy correctly compute the required dimensions then?


extra text to have Discourse let me post this

FWIW I have clarified it for 1.4.0.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.