Question

How can I set the horizontal size of a specific column on a GtkTreeView? I have 4 columns on my TreeView and the last one expands on the rest of the free space. How can I set the first or second column to be expanded on the free space to set a fixed width on all columns?

Was it helpful?

Solution

You can use gtk_tree_view_get_column to get the nth column of a treeview and then use gtk_tree_view_column_set_sizing with GTK_TREE_VIEW_COLUMN_FIXED on it.

You can also tell columns to expand via gtk_tree_view_column_set_expand. To quote the docs:

Sets the column to take available extra space. This space is shared equally amongst all columns that have the expand set to TRUE. If no column has this option set, then the last column gets all extra space. By default, every column is created with this FALSE.

OTHER TIPS

Sample for Ruby:

col = Gtk::TreeViewColumn.new("Headline", renderer, :text => 1)
col.expand = true # Expands the column

col.sizing = Gtk::TreeViewColumn::FIXED # Sets the column on a fixed width
col.min_width = 150
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top