Re: GtkTreeView



David Bryant <daveb acres com au> writes:

> I've been looking at the new tree architecture and from what I
> understand user data should be kept in the tree model rather than the
> view. For example, I am just using the GtkTreeStore class for the model,
> and when I create it I create an extra "column" for user data like this:
> 
> model = gtk_tree_store_new_with_types(3,
> 				      GDK_TYPE_PIXBUF,
> 				      G_TYPE_STRING,
> 				      G_TYPE_POINTER); /* user data */
> 
> Then I call:
> 
> gtk_tree_store_set(model, iter,
> 		   0, pixbuf,
> 		   1, text,
> 		   2, (void *)user_data,
> 		   -1);
> 
> And I get the data back by doing:
> 
> GValue value;
> memset(&value, 0, sizeof(value));	// not sure about this
> gtk_tree_model_get_value(model, iter, 2, &value);
> gpointer user_data = value.data[0].v_pointer;	// is this "right" ?
> 

Easier:

 gpointer data;
 gtk_tree_model_get (model, iter, 2, &data, NULL);

Regards,
                                        Owen




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