Le jeudi 14 avril 2005 Ã 18:23 +0100, Kris Marsh a Ãcrit : > Hi, > > I'm trying to attach extra information to each row in a list, and then > retrieve it later on from a row on > a double click (row_activated) event. > Basically, i've tried: > > g_object_set_data(G_OBJECT(&iter_child), "my_info", > GUINT_TO_POINTER(some_info)); > > Upon inserting an item into the list and then tried to retrieve it in my > callback, but it crashes on insert. > > 1) What should I be trying to link my extra data to? (I assumed the iter > that comes out from > gtk_tree_store_append), but could be wrong. You hook it as a new column of the model, for which you must give a position and a type.
> 2) How can I do this. Eventually the data is going to be either a char array > or a pointer to a structure Note that the data must be a GObject, in particular with respect to memory management (refcounting). The simple way to register your arbitrary data type is to write a clone and a free routine, and register them along with a new boxed type. See g_boxed_type_register_static: http://developer.gnome.org/doc/API/2.0/gobject/gobject-Boxed-Types.html Wrap this up in a get_my_type routine that has a static variable and does the actual call only once, and use the routine when registering the extra model column. (that's a problem I had some time ago on this list, and it didn't work out immediately) _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list