views:

296

answers:

2

How can I set the horizontal size of a specific column on a GTK-TreeView? 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 os set a fixed width on all columns?

+1  A: 

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.

Torsten Marek
A: 

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
Fu86