After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 106406 - GtkTreeView Grid Lines?
GtkTreeView Grid Lines?
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
2.2.x
Other All
: Normal enhancement
: ---
Assigned To: gtktreeview-bugs
gtktreeview-bugs
: 114768 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2003-02-18 11:54 UTC by Martyn Russell
Modified: 2011-02-04 16:10 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
first take at a patch (11.24 KB, patch)
2006-02-21 08:56 UTC, Kristian Rietveld
needs-work Details | Review
updated patch (take two) (13.95 KB, patch)
2006-03-21 13:42 UTC, Kristian Rietveld
needs-work Details | Review

Description Martyn Russell 2003-02-18 11:54:09 UTC
Can we have an option to add grid lines to the treeview, eg.

  gtk_tree_view_show_gridlines(..., TRUE | FALSE);
Comment 1 Kristian Rietveld 2003-04-09 17:34:09 UTC
Grid lines as in the dotted lines like the old Windows TreeView had?
Comment 2 Martyn Russell 2003-04-10 08:47:41 UTC
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);
Comment 3 Kristian Rietveld 2003-04-10 12:40:38 UTC
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.
Comment 4 Martyn Russell 2003-04-10 13:31:07 UTC
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).
Comment 5 Kristian Rietveld 2003-05-22 22:18:22 UTC
If we add something like this, it will require API additions.
Comment 6 Jody Goldberg 2003-06-04 23:34:25 UTC
This would be nice for gnumeric's text import dialog
Comment 7 Kristian Rietveld 2003-11-16 15:35:19 UTC
Pointed to future for now. Might get to it for 2.6.
Comment 8 joeytsai 2003-11-21 18:57:44 UTC
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. ^_^
Comment 9 Kristian Rietveld 2006-02-15 11:19:21 UTC
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?
Comment 10 Kristian Rietveld 2006-02-21 08:56:26 UTC
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).
Comment 11 Tim Janik 2006-02-21 13:20:03 UTC
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.
Comment 12 Matthias Clasen 2006-02-21 14:02:27 UTC
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
Comment 13 Kristian Rietveld 2006-02-28 22:44:25 UTC
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 ...
Comment 14 Matthias Clasen 2006-03-02 06:18:17 UTC
enable-{tree,grid}-lines + {tree,grid}-line-pattern, {tree,grid}-line-width
sounds good to me
Comment 15 Kristian Rietveld 2006-03-21 13:42:51 UTC
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 ...
Comment 16 Kristian Rietveld 2006-05-28 13:13:49 UTC
*** Bug 114768 has been marked as a duplicate of this bug. ***
Comment 17 Kristian Rietveld 2006-05-28 13:14:23 UTC
Maybe also want an option to only able horizontal or vertical grid lines.
Comment 18 Kristian Rietveld 2006-06-02 20:49:04 UTC
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?
Comment 19 Matthias Clasen 2006-06-03 01:17:39 UTC
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
Comment 20 Kristian Rietveld 2006-06-12 18:21:59 UTC
Made it to gtk+ 2.9.3.