GtkColumnView ignores inner listview node's padding/margin
Reproducible with GTK 4 up to current main branch.
Steps to reproduce
- Run
gtk4-demo
. - Run the Lists → Settings demo.
- Open GTK Inspector to inject the testcase CSS.
columnview
Test case A: Padding on CSS
columnview {
padding-left: 24px;
padding-right: 24px;
}
columnview > listview > row > * {
margin: 1px;
border: solid 1px green;
}
Result
CORRECT
columnview > listview
Test case B: Padding on CSS
columnview > listview,
columnview > header {
padding-left: 24px;
padding-right: 24px;
}
columnview > listview > row > * {
margin: 1px;
border: solid 1px green;
}
Result
WRONG
Note there is no horizontal scrolling. The columns are translated to the right.
columnview > listview
Test case C: Margin on CSS
columnview > listview,
columnview > header {
margin-left: 24px;
margin-right: 24px;
}
columnview > listview > row > * {
margin: 1px;
border: solid 1px green;
}
Result
WRONG
Note how the last column is clipped.
Why not use test case A, then?
Because I want to be able to start rubberbanding from the padding around the rows and rubberbanding is done by the inner listview. So, I need to set padding around the list view itself (Test case B).
Ugly workaround in nautilus
I set GtkWidget:margin-start
and GtkWidget:margin-end
on each individual row (which is a very bad hack because I'm not supposed to access the rows in GtkColumnView's inner listview from application code). But this results in clipping of the last that's not enough: I also add a extra dummy column at the end with a fixed width that's equal to margin-start
+margin-end
to circumvent the clipping. Which is another very bad hack.
But these two hacks together succeed to workaround this bug to achieve the desired result: