GTK 4 columnview specific row color

Hi

Is there a way using code (not themes or css files) to give specific rows of a GTK 4 columnview another color?

AFAIK, styling specific rows using CSS alone is not possible (as it requires logic), though something limited like even / odd rows should be possible in GTK css.

For your case, I’d guess you should have a column in your model / backend of GtkColumnView to have a boolean flag (true for special rows etc) and add styling using css / renderers only for rows that have flag set to true.

That’s just my understanding. GTK devs should have better answers.

All recycling views (GtkListView, GtkColumnView, GtkGridView) do not support first/last/nth pseudo selectors, because the row widgets get repurposed; contributions are welcome to make that happen, but it’s a very complex functionality.

Nevertheless, inside the bind/unbind phase, you can assign and remove CSS classes depending on some logic.

2 Likes

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