GNOME Bugzilla – Bug 757495
GtkTreeView odd/even row styling no longer works
Last modified: 2018-05-02 16:50:05 UTC
As of Gtk 3.18, rows could be styled to be different colours if the were odd or even using something along the lines of: GtkTreeView row:even { background-color: @row_even; } GtkTreeView row:odd { background-color: @row_odd; } However, this seems to have been removed in 3.19.1, as the rows are not effected by these colors. Adding the other css does not effect it either: -GtkTreeView-odd-row-color: @row_odd; -GtkTreeView-even-row-color: @row_even; Downstrea: https://bugs.sugarlabs.org/ticket/4908
This is part of the removal of regions. GtkTreeView cells no longer support the "row" or "column" elements. I didn't much time thinking about the removal at the time because none of the themes seemed to use it...
Yeah. Is there a way that this could be implemented without using the regions? Even if it's only changing the colours that would be 100% ok.
The way to bring this back would be to make two css nodes for rendering cells, and make them match cell:row-even and cell:row-odd, or something like that. Or maybe you can get away making cell:nth-child(event) cell:nth-child(odd) work, by using a setup like cells +- cell <- use this node for odd rows +- cell <- use this node for even rows
Created attachment 327103 [details] [review] Patch to add "row.even" and "row.odd" css nodes This is my first patch for Gtk+, so I'm pretty hyped. Please inform me of the noob mistakes that I have made.
Created attachment 327104 [details] [review] Try 2 This patch fixes an unintended added line in the previous patch. To test, open the gtk3-widget-factory, go to the 3rd page (with the tree view), open gtk+ inspetor and add the following css: row.odd { background: blue; } When you go back to the window, the odd rows will have a blue bg.
Hello, are there any updates on reviewing this patch?
sorry, I tried it last week and forgot to comment here: It is a nice start, thanks for doing this patch. There are a few issues though. One is that I noticed you don't treat separator rows specially when calculating the row color, which looks wrong (you can see that in the treeview on page 3 of widget-factory. Another one is problems with selection color - maybe that just needs the theme to be expanded to cover even/odd rows. And sometimes, the drawing seems to go entirely wrong, mainly when scrolling around. Haven't investigated that further yet.
You can do the same thing as the removed code in commit b65f400d565a3d30a9cd8b686296176f00abefee to get the even/odd thing right. The parity boolean is still present in the current code even.
Created attachment 329033 [details] [review] Try 3 Patch Thanks for the review. Sorry for taking my time on this one. I think I fixed the separator issue, I now use the same logic as the previous implementation did. I also bound it to the styled-changed signal, so that hopefully fixes some of the visual glitches that you are seeing.
Hello, Do I need to update a tag to indicate that there is a new patch for review? Thanks, Sam
Review of attachment 329033 [details] [review]: Is it necessary to have two additional CSS nodes? Wouldn't it be enough to have a single row node to which you can apply different classes when drawing? ::: gtk/gtktreeview.c @@ +5274,3 @@ node->children?TRUE:FALSE); + if (_gtk_rbtree_node_get_index (tree, node) % 2) { Coding style: opening brace goes on a new line, and a new indentation level. @@ +5276,3 @@ + if (_gtk_rbtree_node_get_index (tree, node) % 2) { + gtk_style_context_save_to_node (context, tree_view->priv->odd_node); + } else { Coding style: closing brace and else go on two separate new lines, i.e. ... } else { ... But since you're using a single statement, you can drop the braces altogether.
Hi, In which version of gtk+ the patch will be added ? Would not be more simple to add again the lines which have been deleted corresponding to row and column attributs ? Cheers
When this patch will be included to GTK3? Or when this problem will be solved? Ability to color odd/even rows in `treeview` is very useful and important. Please, implement it.
treeview { -GtkTreeView-allow-rules: true; -GtkTreeView-even-row-color: red; -GtkTreeView-odd-row-color: blue; } This code placed in `~/.config/gtk-3.0/gtk.css` does not work. Will be possible to color odd/even rows in the future?
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/581.