Draft: grid-cell: stop abusing AdwClamp
Hi,
I'm working on fixing and improving various things about the GTK layout mechanism. I noticed that NautilusGridCell
abuses AdwClampLayout
to prevent widgets from growing beyond their minimum size, because apparently doing this in more direct ways
causes allocation warnings and visual glytches (labels overflowing the height of their container)
(from 2b42311b)
There are indeed known issues around box & label measurements, these are hopefully getting fixed this cycle. (If you're still having layout issues with boxes and labels at the end of this cycle, please let me know!) But, even ignoring that,
if what you want is to assign a fixed width to the cell (so, the image and the labels), there is a simple way to do it: just write your own layout which requests exactly that size! It's better because:
- it doesn't abuse
AdwClamp
(two of them!) for something it was not designed to do, - it does exactly what you want, directly,
- it is very unlikely to break various height-for-width logic elsewhere (in label, box, and
AdwClamp
), or cause other layout issues, - the whole cell can be
GTK_SIZE_REQUEST_CONSTANT_SIZE
rather thanGTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH
, which is always a big win.
The only downside is you have to write a little bit of C code. This MR is a quick attempt to do just that.
This MR is marked as draft, because:
-
there's also NautilusNameCell
which contains something calledfixed_height_box
, and so needs to be looked at, -
NautilusGridCell
is (indirectly) derived fromAdwBin
, which makes it kind of awkward to implement your own layout.
How would you prefer the latter issue to be handled? Should I make NautilusViewCell
not derive from AdwBin
, and instead assign GtkBinLayout
to individual cell types that want it (but not NautilusGridCell
)? Or maybe should NautilusGridCell
be a bin that contains something that is not?