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

Chuck Esterbrook chuck.esterbrook at gmail.com
Thu Dec 3 02:40:58 EST 2009


On Thu, Nov 26, 2009 at 9:27 PM, Andy Selvig <ajselvig at gmail.com> wrote:
> I've been reading this conversation, and just figured I'd give my two cents.
>
> I have to agree with Chris 100% on this. First off, comparing it to
> Python is a bit apples/oranges. Even though a hashtable approximates
> Python property system, that is the "Python way" to do things. It's a
> dynamic language and people use it for situations where they're okay
> with no type safety or collision avoidance.

Maybe the fact that I have cranked out mounds of Python as well as C#
is why I'm comfortable making those decisions.

On Mon, Nov 30, 2009 at 11:05 AM, Adam Tauno Williams
<awilliam at whitemice.org> wrote:
> Agree, The UserData thing is kind of lousy.  But if you wrap it in
> extension methods it can be used more gracefully.  Extension methods
> can't add attributes [variables] but they can store and retrieve stuff
> from UserData.
>
>  public static class MyWidgetMethods
>  {
>    public static void MyMethod(this Gtk.Object widget, {some params})
>    {
>        {do stuff and use this.UserData here}
>        return {whatever}
>    }
>  }

I agree this is a nice way to extend existing classes although it
inspires me to say "thank goodness for Data or this wouldn't be
possible" rather than "Data is lousy". Actually it might be possible
with weak refs; I haven't investigated that approach.

Thanks for the interesting discussion,

-Chuck


More information about the Gtk-sharp-list mailing list