Re: GtkTreeView



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" ?

Hope this helps,
Dave

On 11 Aug 2001 14:37:18 -0400, Charlie Schmidt wrote:
> -
> 
> does anyone using the new GtkTreeView widget know if there is a function
> to provide what gtk_clist_set_row_data() did for each GtkTreeIter in the
> GtkTreeView?  that is to say, a way to provide a unique piece of data for
> each row/node in the GtkTreeView?
> 
> -- 
> Charlie Schmidt - <ishamael themes org>
> 
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list






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