tasn pushed a commit to branch master. http://git.enlightenment.org/bindings/cxx/eflxx.git/commit/?id=c597faa97ce1088e5c8bdd54382a11170d771fbd
commit c597faa97ce1088e5c8bdd54382a11170d771fbd Author: Andreas Volz <[email protected]> Date: Thu Aug 5 21:36:58 2010 +0000 disconnect () and disconnectAll for signals implemented SVN revision: 50844 --- edjexx/include/edjexx/Object.h | 9 +++++++-- edjexx/src/Object.cpp | 27 +++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/edjexx/include/edjexx/Object.h b/edjexx/include/edjexx/Object.h index 2850958..c2c302c 100644 --- a/edjexx/include/edjexx/Object.h +++ b/edjexx/include/edjexx/Object.h @@ -3,6 +3,7 @@ /* STL */ #include <string> +#include <map> /* EFL++ */ #include <eflxx/Common.h> @@ -77,8 +78,10 @@ public: Eflxx::CountedPtr <Part> getPart( const std::string &partname ); /* signals and slots */ - void connect( const std::string &emission, const std::string &source, const SignalSlot& slot ); - void emit( const std::string &emission, const std::string &source ); + void connect (const std::string &emission, const std::string &source, const SignalSlot& slot); + void disconnect (const std::string &emission, const std::string &source); + void disconnectAll (); + void emit (const std::string &emission, const std::string &source); static Object *wrap( Evas_Object* o ); @@ -94,6 +97,8 @@ private: bool operator=( const Object& ); bool operator==( const Object& ); + + std::map <std::pair <std::string, std::string>, SignalSignal*> mSignalList; }; diff --git a/edjexx/src/Object.cpp b/edjexx/src/Object.cpp index 8c24714..8b1f750 100644 --- a/edjexx/src/Object.cpp +++ b/edjexx/src/Object.cpp @@ -67,7 +67,7 @@ Object::Object( Evas_Object* object) Object::~Object() { - //FIXME: Remove callbacks? + disconnectAll (); evas_object_del( o ); } @@ -115,14 +115,37 @@ Eflxx::CountedPtr <Part> Object::getPart( const std::string &partname ) throw PartNotExistingException (partname); } -void Object::connect( const std::string &emission, const std::string &source, const SignalSlot& slot ) +void Object::connect (const std::string &emission, const std::string &source, const SignalSlot& slot) { SignalSignal* signal = new SignalSignal(); + mSignalList[std::pair <std::string, std::string> (emission, source)] = signal; AllocTag( signal, emission ); signal->connect( slot ); edje_object_signal_callback_add( o, emission.c_str (), source.c_str (), &_edje_signal_handler_callback, static_cast<void*>( signal ) ); } +void Object::disconnect (const std::string &emission, const std::string &source) +{ + SignalSignal *signal = mSignalList[std::pair <std::string, std::string> (emission, source)]; + edje_object_signal_callback_del (o, emission.c_str (), source.c_str (), _edje_signal_handler_callback); + delete signal; +} + +void Object::disconnectAll () +{ + for (std::map <std::pair <std::string, std::string>, SignalSignal*>::iterator s_it = mSignalList.begin (); + s_it != mSignalList.end (); + ++s_it) + { + std::pair <std::string, std::string> emission_source = (*s_it).first; + SignalSignal *signal = (*s_it).second; + + edje_object_signal_callback_del (o, emission_source.first.c_str (), emission_source.second.c_str (), + _edje_signal_handler_callback); + delete signal; + } +} + void Object::emit( const std::string &emission, const std::string &source ) { edje_object_signal_emit( o, emission.c_str (), source.c_str () ); --
