Reputation: 33900
How can I make GtkTreeView look like on the picture above? Note the tree guides (dotted lines) and folder expander icons.
Upvotes: 0
Views: 103
Reputation: 2525
Tree guides are controlled by enable-tree-lines
property. Rendering icons is a bit more complicated.
First of all, you will have to add an extra field to model with icon-names. Next, you must connect to "row-collapsed"
and "row-expanded"
signals and manually change icon names in your model.
Then you make a TreeViewColumn and pack 2 renderers there with gtk_tree_view_column_pack_start
.
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (column, "title");
renderer0 = gtk_cell_renderer_pixbuf_new ();
g_object_set (renderer0, "icon-name", "folder-open", NULL); // #1
gtk_tree_view_column_pack_start (column, renderer0, FALSE);
gtk_tree_view_column_set_visible (column, TRUE);
renderer1 = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, renderer1, FALSE);
gtk_tree_view_column_set_attributes (column, renderer1, // #2
"text", NAME_COL,
NULL);
This snippet uses one icon for all rows (icon-name is set globally), but you can make it get icon-names from model.
If stock icons are not sufficient, you will have to use a GIcon or pixbuf, take a look at "gicon"
and "pixbuf"
properties of cellrendererpixbuf
EDIT: if the question was about +/- buttons instead of triangles, take a look at this answer or adjust gtk3 theme
Upvotes: 1