Re: [gtk-list] adding an additional pointer to a treeitem



"Andre' Karwath" <Andre.Karwath@informatik.tu-chemnitz.de> writes:
> I'm quite new to this list and to Gtk too and have a small problem.
> 
> I've created a gtk_tree widget where I need to add tree item widgets at
> runtime. Together with the item structure I'd like to store an
> additional information (a string) for each tree item and need therefore
> an additional pointer. I know that I can add all widgets to a
> gtk_tree_item and that the default one is a label. Now, beside this
> label I would like to store this additional pointer.

see gtk_object_set_user_data() from gtkobject.h, it can be used to attach
extra information to objects.

> I know how to do this in C++ or other OO languages, but I have no
> simple idea how I can do this in C using Gtk. Could anyone please help
> me?

you can add data to the items with inheritance with gtk+ too, but it
does involve somewhat more writing and if thats the only thing you
want to do, gtk_object_set_user_data() is the best alternative. (or
gtk_object_set_data() -- whatever)

-- 
-- Tero Pulkkinen -- terop@modeemi.cs.tut.fi --



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