[Gtk-sharp-list] Associate user data object with a widget

Chuck Esterbrook chuck.esterbrook at gmail.com
Thu Nov 26 01:56:21 EST 2009


On Wed, Nov 25, 2009 at 9:21 PM, Chuck Esterbrook
<chuck.esterbrook at gmail.com> wrote:
> Hi,
>
> I'd like to associate an arbitrary Mono/.NET object with a widget.

After more digging, I found out that this feature was apparently
considered useful enough that it was moved up from gtk_object to
g_object, in the core C libraries. Here is some of the C API:

http://www.gtk.org/api/2.6/gobject/gobject-The-Base-Object-Type.html#g-object-get-data

But unfortunately, it doesn't really survive the Mono/.NET threshold
as there are apparently garbage collection problems with it:

http://www.go-mono.com/docs/index.aspx?link=P%3aGLib.Object.Data

Although I'm not sure why a UserData for the Mono/.NET object itself
could not have been provided. It would not be "seen" by any C-based
code, but it wouldn't typically be used for such a purpose anyway.

Are the hash codes for GLib.Object and descendants stable so they can
always be safely used as keys in a dictionary?

-Chuck


More information about the Gtk-sharp-list mailing list