Struggling to Implement GtkFlowBox layout

As a TL;DR, I’m trying to implement a layout like this:

Every box is the same height, but a dynamic width; the number of widgets per row is also dynamic. These widgets in my case are always GtkPictures.

I’ve looked through GTK4’s layout containers, and it seems like GtkFlowBox is the best, but I’ve struggled to wrangle it.

The furthest I’ve gotten is with something like this:

<object class="GtkFlowBox">
  <property name="max-children-per-line">3</property>
  <property name="min-children-per-line">3</property>
  <child>
    <object class="GtkFlowBoxChild">
      <child>
        <object class="GtkPicture">
          <property name="file">..</property>
        </object>
      </child>
    </object>
  </child>
  [.. above repeated n times ..]
</object>

This appears to work, at least in Cambalache, but the images are scaled to that their widths are equal, rather than their heights, and only min-children-per-line images will fill each line. Given the opportunity, every image is put on its own row.

Thanks in advance!

Hi,

That looks a lot like a Adw.WrapBox
If you can’t use libadwaita, you can look in their source how Adw.WrapLayout is implemented.

Indeed, the layout you’re describing looks like Adw.WrapBox and not Gtk.FlowBox.