On Fri, 2006-07-07 at 22:42 +0300, Paul Pogonyshev wrote: > Currently, you have to 1) set sensitivity (some state) to a computed value; > 2) track when that computed value changes its state, by connecting to the > appropriate callbacks; if the rules change, you have to not forget to keep > the computation and state tracking in sync; and 3) set the initial state > (sometimes). Note that the initial state should also be in sync with > points 1) and 2). > > I propose to do all the steps at once, using `condition's. This roughly > corresponds to step 1), while all the rest is done automatically. > > Using conditions (doesn't work currently, of course; how it should look > like): > > button->set_sensitive (entry->get_not_empty_condition () & > check_button->get_active_condition ());
This is an interesting idea, but I have no idea how you might implement it. > Traditional method: > > entry->signal_changed ().connect (sigc::mem_fun (*this, > &Windows::update_sensitivity)); > check_button->signal_toggled ().connect (sigc::mem_fun (*this, > &Windows::update_sensitivity)); > > // Set initial state. > update_sensitivity (); > > ... > > void > update_sensitivity () > { > button->set_sensitive (entry->get_text_length () > 0 && > check_button->get_active ()); > } Yes, I do this quite often. > > Note also that you can already get notification of property changes from > > gtkmm objects, like so: > > widget.property_something().signal_changed().connect( ... ) > > Yes. I propose to simplify it (writing less code) and make less error- > prone (all is done only once and in one place.) This is at a small > cost to efficiency, which is not important in GUI. > > Paul -- Murray Cumming [EMAIL PROTECTED] www.murrayc.com www.openismus.com _______________________________________________ libsigc-list mailing list libsigc-list@gnome.org http://mail.gnome.org/mailman/listinfo/libsigc-list