Re: [sigc] conditions in libsigc



On Monday 03 July 2006 12:36, Paul Pogonyshev wrote:
> Roel Vanhout wrote:
> > If I understand what you describe correctly, I think it would be very
> > useful, but only is it's not restricted to bool variables. I'd like to
> > have a way to 'mark' a (member) variable (eg by wrapping it in a
> > template) which would then automagically emit a signal when that
> > variable is changed (that is what you're proposing, right?), but in my
> > usecases that would hardly ever be a bool, more likely a string, numeric
> > value or complex type. Then again, how would this work with complex
> > types? Say:
> >
> > class A
> > {
> > public:
> >    int m_Int;
> > }
> >
> > class B
> > {
> > public:
> >    A m_A;
> > }
> >
> > B.m_A.m_Int = 5;
> >
> > Who should emit a signal - only m_Int or m_A also, because that object
> > has changed, too?
> >
> > I'm drifting away from the original question I'm afraid, I was just
> > braindumping :)

You can do something as simple as that just with a class with an 
accessor/mutator method to a private variable that emits a signal if the 
value changes.  (If you are concerned with built-in types such as bool, you 
will have to do something similar to that).  What is the point of building 
this into libsigc?

> Yes, it is useful, but I was thinking of something like this
>
>   sigc::condition  condition = entry.is_not_empty_trimmed () &
> check_box.is_selected (); Gtk::SensivityController  controller (condition,
> some_widget);
>
> You hardly need anything other than boolean variables for this kind of
> stuff.  (Pointer vs. reference stuff etc. is not thought off yet, I'm
> basing on a Java implementation.)
>
> Any type of variable might be useful, but standard operators for
> boolean variables (and, or, not) are _very_ convenient to have.

You refer to Gtk, so are you confusing libsigc with the glib event loop?  
Firstly, libsigc of itself knows nothing of Gtk/Gdk events: it is just a 
callback mechanism.  Secondly, gtkmm classes already have signals 
(implemented with libsigc) which you can connect to, which indicate whether 
the state of a widget has changed.  For example, classes derived from 
Gtk::Widget emit state events if a widget is maximised or iconised, as well 
as visibility, style and size events (and many others).  As you refer to a 
"check_box", Gtk::CheckButton emits activate, clicked and toggle events.

Chris




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]