From: Eric Hodel Date: 2004-04-07T18:52:47-07:00 Subject: Re: Idea: Simplified GTK --mxv5cy4qt+RJ9ypb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Gregory Millam (walker@lethalcode.net) wrote: > Well I guess it makes sense to do it anyway - even if I wouldn't use > it myself, it'd be trivial to add it. >=20 > One problem with the the whole context thing came into mind, though... >=20 > def button(label,&block) > b =3D Button.new > b.signal_attach("clicked",block) >=20 > if has_context(:color) > ... > end > if has_context(:bgcolor) > ... > end > if etcetcetc....... Gtk has what, dozens of configurable things? > fonts, and the like. > end > end That's pretty darn ugly, and it has this feeling of unmaintainability about it. I doubt this would be a workable solution, especially if there are "dozens of configurable things". Avi used a very nice solution to this problem in Seaside's HTML renderer. Its easier to show first, then explain, so in your code you do: def render_content_on(r) r.element_id 'bar' r.heading 'My Heading' r.css_class 'my-class' r.attributes['border'] =3D 1 r.attributes['cellpadding'] =3D 2 r.attributes['cellspacing'] =3D 1 r.table do ... end end The renderer collects attributes until you create an HTML element, then it saves the HTML element and starts up a new attribute collection. When you're done with the document, it gets turned into an HTML document, and set out to the client. Since the renderer handles building the documents, you can create all kinds of custom widgets quickly and easily by simply subclassing or extending the renderer. For example: def div_named(name, content, &block) element_id name div content, &block end If you'd like to look at it in Ruby, you can find it implemented in Borges here: http://rubyforge.org/cgi-bin/viewcvs/cgi/viewcvs.cgi/borges/lib/Borges/HTML= /?cvsroot=3Dborges --=20 Eric Hodel - drbrain@segment7.net - http://segment7.net All messages signed with fingerprint: FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 --mxv5cy4qt+RJ9ypb Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQFAdLBvMypVHHlsnwQRAjHDAKCIfCvWEor81RXA3ZI9cYXvJPNKaQCeJ19C vsAvcQtpNfhnligofqjBFns= =zWUd -----END PGP SIGNATURE----- --mxv5cy4qt+RJ9ypb--