[Gtk-sharp-list] New Glade# hack
Miguel de Icaza
03 Jan 2003 20:26:16 -0500
Hello Rachel! [CCed to Mono Docs List]
> I was reading through monodoc sources and noticed a long method that
> basically was line after line of:
> myLabel = (Gtk.Label) gxml["my_label"];
> I'm sure we've all had to do similar things in programs that use glade
> (I know I have, at least), so I figured out a slightly cleaner way to do
> this, using attributes.
> Here's how to use it: When declaring a member which needs to be
> initialized from the Glade.XML, you can simply add a
> Gtk.Label myLabel;
OH MY GOD. This is absolutely beautiful!
This is taking advantage of the spirit that got me so interested in .NET
in the first place. It is a *beautiful* use of attributes and Glade#.
> This doesn't really save much in terms of code (for example, in
> monodoc's case, it would require breaking up member declarations of the
> same type, so the sheer number of lines of code would increase), but it
> seems conceptually cleaner to me, particularly because it lets you avoid
> an explicit cast.
Yes. But most importantly, you remove more redundant information, and
you avoid explaining why you have to cast the objects.
Mono-doc-hackers; Could we get the tutorials updated?