From: Kero Date: 2004-04-10T17:19:16+09:00 Subject: Re: Idea: Simplified GTK >> Since the only thing that can happen to a button is that someone >> clicks it it might be more concise to leave the onclick out. >> Something like: >> >> button "name" { >> ... >> } button "Options..." { options_dialog { are_you_sure_dialog { process_new_options } } } Even when I'm putting widgets in these blocks, I'm not doing any layout. There is logic in this, to some extent only :( button { image "funny.png" label "Options..." } which may be about layout, such that button { label "Options" image "funny.png" } has the image on the other side... Personally, I prefer to put extra options in the parameter list, since a block has two meanings (for containers and non-containers), i.e. button("Options...", :image=>"funny.png") { # pop up dialog, etc } and I'd even assume the text is centered, normally, so the image can be on either side, until you specify :align=>:right or :left which will put the image on the right and align the text to it. And in case you hadn't noticed: I prefer to mention default things (text and action for buttons) without explicitely naming them. It allows for shorter code, but should never be confusing like widget("foo", "bar", "baz"). I am thinking whether to pick this up with Wise :) http://wise.rubyforge.org/ this declarative way of putting things, takes out the mess with parent-widgets I have there :) As a challenge to you: how should a tree-widget be declared? Totally disregard the current gtk-api, 'coz that's waaay too inconvenient for my taste. Please improve on this: tree(:columns=>["ID", "name", "grade", "remark"]) { branch(1, "Kero", "B") { branch(nil, "math", "B") branch(nil, "cs", "A", "MSc :)") branch(nil, "physics", "C") } } [snip] > My own idea was having it closer to this: > > button { > label "name" > on_click { ... } > (right click, mouseover, etc can be set here too) > } > > With a shortcut: > > button_onclick "name" { > ... > } > > The big question we should be asking ourselves here - which one follows > the POLS? ;). Since button() {} will return the button itself (well, what else could it return? it should return something...) you could do this: button("name", :tooltip=>"this does...") { # do it }.bind(:mouse_over) { # mention something in a statusbar or so } The desire for mouse_over falls in the "everything must be possible" category, imho, whereas the default action comes from "things you do often should be easy". The :tooltip handles the mouse-over, but also the associated timing issues. This already works in Wise :) and for those that don't like the default block to execute (block only for layout) button("name").bind(:action) { # do it } or maybe without :action, since that would be default? Bye, Kero. -- wanna keep developing software? http://demo.ffii.org/index.php +--- Kero ----------------------- kero@chello@nl ---+ | all the meaningless and empty words I spoke | | Promises -- The Cranberries | +--- M38c --- http://httpd.chello.nl/k.vangelder ---+