Question

how can I obtain height of treeview/treeviewcolumn, please? I have simple code with layout (inside is big treeview) and vertical scrollbar in the table. When I set small height of layout, I do not see all items of treeview and when I set it big, I see whole table with empty space at the bottom of layout. Is it possible to set layout, that it will have exactly same height like treeview or the biggest from treeviewcolumns ? Thanks in advance. A piece of code:

tree = new Gtk.TreeView();
vadjustment = new Gtk.Adjustment(0, 0, 0, 0, 0, 0);
vscrollbar = new Gtk.VScrollbar(vadjustment);
Lyout layout = new Layout(null, vadjustment);
layout.Put(tree, 0, 0);
Table table =  new Table(1, 2, false);
table.Attach(layout, 0, 1, 0, 1, Gtk.AttachOptions.Expand|Gtk.AttachOptions.Fill, Gtk.AttachOptions.Expand|Gtk.AttachOptions.Fill, 0, 0);
table.Attach(vscrollbar, 1, 2, 0, 1, Gtk.AttachOptions.Shrink, Gtk.AttachOptions.Shrink|Gtk.AttachOptions.Fill, 0, 0);
box.PackStart (table, true, true, 4);
vbox1.Add(box);
...
TreeViewColumn first = new TreeViewColumn();
first.Title=h1;
Gtk.CellRendererText first_name_cell = new Gtk.CellRendererText ();
first.PackStart(prvy_name_cell, true);
first_name_cell.Width=20;
...
tree.AppendColumn (first);
layout.SetSize(800, ???);

And one another question - is it possible to apply black border color for treeview items?

Was it helpful?

Solution

You should be able to get the size of the treeview reliably in its expose/draw event. If you hook into that, you can use its height to adjust the layout size. You can guess an initial large layout size, and the first expose will trim it down. Expose is called often, and you shouldn't resize often, so logic to detect that the new height is different should be used. You might also guard against early calls of expose where the treeview height might have a crazy value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top