"can-shrink" on Picture creates empty occupied space

Setting the “can-shrink” property on a Picture causes it to generate useless space below.

image

And it seems to work fine with images that are rather wide.

The Picture doesn’t have that empty space it generates, it’s not binded to any widget. It’s simply there.

Code:

let image = gtk::Picture::builder()
            .css_name("img")
            .alternative_text(element.attributes.get("alt").unwrap().clone().unwrap())
            .css_classes(element.classes.clone())
            .halign(gtk::Align::Start)
            .valign(gtk::Align::Start)
            .can_shrink(false)
            .build();

If I try to resize the window, it occupies that empty space.

So the question is - is there a property I am missing that can fix this, or is there something else I’m doing wrong?

Hi,

When using a content-fit that preserves aspect ratio like CONTAIN (the default one), there are such weird width-for-height issues like this one, as the picture tries to allocate its height based on its allocated width, with the same ratio as the image.

An easy way to break that behavior would be to pack the Picture in a horizontal GtkBox (as single element).