GNOME Bugzilla – Bug 106406
GtkTreeView Grid Lines?
Last modified: 2011-02-04 16:10:23 UTC
Can we have an option to add grid lines to the treeview, eg. gtk_tree_view_show_gridlines(..., TRUE | FALSE);
Grid lines as in the dotted lines like the old Windows TreeView had?
Perhaps. I was thinking along the lines of trying to implement something like Open Office Calc's method of grid lines (or Microsoft Excel). But now that you mention it, it would be a good idea to have another API similar to: typdef enum GtkTreeViewGridLine { GtkTreeViewGridLineNone = 1, GtkTreeViewGridLineDotted, GtkTreeViewGridLineSolid, } GtkTreeViewGridLine; gtk_tree_view_set_gridlines(treeview, GtkTreeViewGridLineType type);
Those are grid lines for tables. I thought you meant grid lines like in trees (windows explorer). I am not sure if this would be a worthwhile addition.
I actually think both are important. Apps like Nautilus would look really good and it would be easier to follow a large tree with the dotted lines you had in mind. So if I was to write an application that used a spreadsheet or similar method to play with data, how would I do it in GTK? For the most cases, this would be used with lists, I can not see much benefit from it being used with a tree. My main reason for this request, comes from the customer which this software is being written for. They wanted grid lines for data which was 7 columns wide, and between 600 and 2000 entries. The only solution at the time which could be offered was the hinting system (alternate colours per row).
If we add something like this, it will require API additions.
This would be nice for gnumeric's text import dialog
Pointed to future for now. Might get to it for 2.6.
I'm speaking of the grid lines in trees, like in a directory structure or nested newsgroup thread. I understand this ability is achieved currently through themes (is this correct?) but I think having both styles of drawing available to the application would be useful. In terms of an API addition, I was thinking of a function like gtk_tree_view_set_rules_hint, in which an application programmer would indicate that a particular treeview could get hairy and the additional grid lines would be useful (like in the cases of a directory structure or a newsgroup thread). However this is implemented, I would be willing to assist if I were given some helpful pointers. ^_^
Hmm, currently thinking of typdef { GTK_TREE_VIEW_LINE_STYLE_NONE, GTK_TREE_VIEW_LINE_STYLE_SOLID, GTK_TREE_VIEW_LINE_STYLE_DOTTED } GtkTreeViewLineStyle; void gtk_tree_view_set_grid_line_style (GtkTreeView *tree_view, GtkTreeViewLineStyle line_style); void gtk_tree_view_set_tree_line_style (GtkTreeView *tree_view, GtkTreeViewLineStyle line_style); But maybe they should really be style properties instead. Opinions?
Created attachment 59826 [details] [review] first take at a patch It felt a bit weird using GCs again, I guess I should redo the patch using cairo (though the rest of tree view isn't really using cairo either if I'm not mistaken). I didn't add the properties yet, since I don't yet know whether to use regular or style properties for this (jrb seems to prefer style properties, mclasen regular).
judging from the comments abopve, this sounds like a feature that is useful for some treeviews only. e.g. in a spreadsheet context, but not neccessarily for every file or icon browser. so i think enabling grid lines better be a reguler per-treeview property, just like you said matthias thinks about it.
we may need a combination of regular properties to turn on no/dashed/dotted lines, and themes need a way to control the actual appearance of dashed/dotted lines
I am currently wondering whether it makes sense to have enable-grid-lines and enable-tree-lines properties (both of type boolean). And to have {tree,grid}-line-pattern, {tree,grid}-line-width style properties, so the themes can control the line styles. (Compare those to focus-line-pattern and focus-line-width in GtkWidget). Any opinions / better suggestions? The other option I see is adding something like gtk_paint_line() since _paint_hline() and _paint_vline() are really for separators ...
enable-{tree,grid}-lines + {tree,grid}-line-pattern, {tree,grid}-line-width sounds good to me
Created attachment 61690 [details] [review] updated patch (take two) Updated patch, implementing the properties proposed above. Some notes: * Do we really want to use GCs here or redo the thing with cairo? * GtkTreeView doesn't take the size of the grid lines into account when requesting and allocation space, maybe it should ...
*** Bug 114768 has been marked as a duplicate of this bug. ***
Maybe also want an option to only able horizontal or vertical grid lines.
I think this is about ready to go in. Using GCs should be fine for now. And we should take the line widths into account while requesting/allocating space, weird things would happen with width > 2 if we didnt. This shouldn't be that much work to do. I am still considering splitting up the grid-line properties into horizontal-gri-line-* and vertical-grid-line-* Matthias, any comments from your side?
No, not beyond comment 14. Splitting the grid-line property sounds reasonble, if you don't want to introduce an enumeration like enum { TREE_GRID_NONE, TREE_GRID_HORIZONTAL, TREE_GRID_VERTICAL, TREE_GRID_BOTH } and use that as the type of the property
Made it to gtk+ 2.9.3.