Re: how to add a column to a GtkListStore



On Wednesday 15 December 2004 23:02, edward hage wrote:

I know how to add rows, but if I am not mistaken your approach is that you
have a fixed amount of columns. The question is how to add an extra column
on an already defined GtkListStore?
Say you have defined gtk_list_store_new(2, G_TYPE_DOUBLE,G_TYPE_DOUBLE);
and you want to add a third column to this. Where can you define that the
3th column should also be a G_TYPE_DOUBLE? You can not define this with a
gtk_tree_view_insert_column_with_attributes ().

As far as I can see, you have two options:

 * write a custom GtkTreeModel that allows you to add columns on the fly.

 * have only one column in your list store of G_TYPE_POINTER, and store a 
pointer to an allocated custom struct in there, or a pointer to an array of 
doubles etc. This way you can effectively add new columns by allocating more 
memory for your array. However, you won't be able to use cell renderers with 
attributes, you will have to set up cell data functions instead (which 
shouldn't be much extra work).

Cheers
 -Tim



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]