Re: help porting from GtkClist to GtkTreeView

RamsÚs Morales <ramses computer org> writes:
> On GTK+ 1.2, to add data to a row on a GtkClist, I used
> gtk_clist_set_row_data.
> I have an idea on how to get the same effect on GtkTreeView, for
> example:
> -Create a model with TREE columns.
> -create the tree view for that model with TWO columns
> -The "invisible" column would be the "row data".
> If I want to store a struct on the model, I would use a G_TYPE_POINTER.
> Is that a good idea? Is that right? Is that how is it suposed to be?

Yes, that's one good approach.

Another thing you can do is just have one column in your model, and
have that column contain a struct like:

 struct _RowInfo
   char *whatever;
   char *whateverelse;
   Foo *mydata;
   int foobar;

Obviously the struct has whatever you want in there. Then register the
struct as a boxed type for memory management, and use
gtk_tree_view_insert_column_with_data_func() or

There's an example of this in demos/gtk-demo/stock_browser.c, run
gtk-demo and you can see it in the source tab for the stock browser


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