Best way to set a maximum size for a widget in GTK4?

I have a Picture (inside a Box) that I’d like to scale to match the parent, but not beyond a certain size. The image is user-provided so I don’t know the dimensions of the image beforehand. It is OK to shrink the image, so I’ve set can-shrink and keep-aspect-ratio to true.

I tried using set_width_request but this prevents the image from scaling smaller than the size request, so it’s not quite what I want.

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