Re: How to add callback to tell owner something



On Wed, 2005-11-30 at 10:38 -0500, Tristan Van Berkom wrote:
> rion10 (sent by Nabble.com) wrote:
> > How to tell the owner that something has done at one function in my class?
> > Just like as following:
> 
> After reading your mail, I think you are looking for
> GSignal documentation... here it is:
> 
> http://developer.gnome.org/doc/API/2.0/gobject/gobject-Signals.html
> 
> GSignal is complex, I sugest starting by finding an
> example (in the GTK+ source for instance) and working from
> there.

if you are working in C++, forget GSignal; use libsigc++ and its very
very easy:

	class MyClass : public sigc::trackable
	{
	    ...

	    sigc::signal<void,int> SomethingHappened;

	    void do_something () { 
	        int what;
	        ....
	        SomethingHappened (what);
            }
        };

  
        class MyOtherClass : public sigc::trackable
        {
	    ...
 
	    void when_something_happens (int what) {
                  ...
            }
        }

	MyClass mine;
	MyOtherClass myOther;

	mine.SomethingHappened.connect (mem_fun (myOther,
&MyOtherClass::when_something_happens);

	mine.do_something ();


please don't send email to me asking about this; the net is littered
with loads of sample code. and use gtkmm, not gtk+, your life will be
much easier.

--p





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