aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-07-09 21:57:32 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-09-14 17:39:10 (GMT)
commitd338e6c003cca84733c7900be256a991790f7018 (patch)
tree9ca835fea2be6fb06357c60c62f81c916be18148 /src/FbTk
parentbca20c5db4b991f6404050bd79a1c354295ceb7f (diff)
downloadfluxbox-d338e6c003cca84733c7900be256a991790f7018.zip
fluxbox-d338e6c003cca84733c7900be256a991790f7018.tar.bz2
Signal::connect now also accepts an already-constructed Slot
This way we can use Commands as signal handlers out-of-the-box.
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/Signal.hh30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/FbTk/Signal.hh b/src/FbTk/Signal.hh
index 31fd840..7de3893 100644
--- a/src/FbTk/Signal.hh
+++ b/src/FbTk/Signal.hh
@@ -143,6 +143,10 @@ public:
143 new SlotImpl<Functor, void, Arg1, Arg2, Arg3>(functor) 143 new SlotImpl<Functor, void, Arg1, Arg2, Arg3>(functor)
144 )); 144 ));
145 } 145 }
146
147 SlotID connect(const RefCount<FbTk::Slot<void, Arg1, Arg2, Arg3> > &slot) {
148 return SignalHolder::connect(slot);
149 }
146}; 150};
147 151
148/// Specialization for two arguments. 152/// Specialization for two arguments.
@@ -164,6 +168,10 @@ public:
164 new SlotImpl<Functor, void, Arg1, Arg2>(functor) 168 new SlotImpl<Functor, void, Arg1, Arg2>(functor)
165 )); 169 ));
166 } 170 }
171
172 SlotID connect(const RefCount<FbTk::Slot<void, Arg1, Arg2> > &slot) {
173 return SignalHolder::connect(slot);
174 }
167}; 175};
168 176
169/// Specialization for one argument. 177/// Specialization for one argument.
@@ -185,6 +193,10 @@ public:
185 new SlotImpl<Functor, void, Arg1>(functor) 193 new SlotImpl<Functor, void, Arg1>(functor)
186 )); 194 ));
187 } 195 }
196
197 SlotID connect(const RefCount<FbTk::Slot<void, Arg1> > &slot) {
198 return SignalHolder::connect(slot);
199 }
188}; 200};
189 201
190/// Specialization for no arguments. 202/// Specialization for no arguments.
@@ -206,6 +218,10 @@ public:
206 new SlotImpl<Functor, void>(functor) 218 new SlotImpl<Functor, void>(functor)
207 )); 219 ));
208 } 220 }
221
222 SlotID connect(const RefCount<FbTk::Slot<void> > &slot) {
223 return SignalHolder::connect(slot);
224 }
209}; 225};
210 226
211/** 227/**
@@ -225,9 +241,17 @@ public:
225 241
226 /// Starts tracking a signal. 242 /// Starts tracking a signal.
227 /// @return A tracking ID 243 /// @return A tracking ID
228 template <typename Signal, typename Functor> 244 template<typename Arg1, typename Arg2, typename Arg3, typename Functor>
229 TrackID join(Signal& sig, const Functor& functor) { 245 TrackID join(Signal<Arg1, Arg2, Arg3> &sig, const Functor &functor) {
230 ValueType value = ValueType(&sig, sig.connect(functor)); 246 return join(sig, RefCount<Slot<void, Arg1, Arg2, Arg3> >(
247 new SlotImpl<Functor, void, Arg1, Arg2, Arg3>(functor)
248 ));
249 }
250
251 template<typename Arg1, typename Arg2, typename Arg3>
252 TrackID
253 join(Signal<Arg1, Arg2, Arg3> &sig, const RefCount<Slot<void, Arg1, Arg2, Arg3> > &slot) {
254 ValueType value = ValueType(&sig, sig.connect(slot));
231 std::pair<TrackID, bool> ret = m_connections.insert(value); 255 std::pair<TrackID, bool> ret = m_connections.insert(value);
232 if ( !ret.second ) { 256 if ( !ret.second ) {
233 // failed to insert this functor 257 // failed to insert this functor