Re: [gtkmm] Signal emission stop
- From: MHL Schulze t-online de (Martin Schulze)
- To: "Andrew E. Makeev" <andrew solvo ru>
- Cc: gtkmm-main <gtkmm-list gnome org>
- Subject: Re: [gtkmm] Signal emission stop
- Date: Wed, 23 Apr 2003 20:00:36 +0200
Am 2003.04.23 13:41 schrieb(en) Andrew E. Makeev:
Hi,
Look at the simple example below, and explain, please, how could I stop SigC
signal emission?
For gtk(mm) signals the signal emission can be stopped by returning true
(or was it false? => we have to look at the docs!) in the signal handler.
For you own SigC signals you need a Marshaller (see marshal.h) to
achieve the same:
class MyMarshal {
// both typedefs must be defined.
typedef bool InType;
typedef bool OutType;
public:
OutType stopped_emission;
// Return final return code.
OutType value()
{ return stopped_emission; }
// Captures return codes and returns TRUE to stop emission.
bool marshal(const InType& stop_emission)
{ stopped_emission=stop_emission; return stop_emission; }
MyMarshal() : stopped_emission(false) {}
};
Your example would read:
class MyClass : public SigC::Object {
public:
...
SigC::Signal0<bool,MyMarshal> test_signal;
...
};
void MyClass::some_method () {
test_signal.connect (SigC::slot (*this, &MyClass::f1));
test_signal.connect (SigC::slot (*this, &MyClass::f2));
}
bool MyClass::f1 () {
if (<expr> == true)
return true; // return true to stop emission. function f2 won't be
called
else
return false; // continue signal emission
}
bool MyClass::f2 () {
return false;
}
Cheers,
Martin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]