Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / xml / helper-observer.cpp
1 #include "helper-observer.h"
3 namespace Inkscape {
4 namespace XML {
6 // Very simple observer that just emits a signal if anything happens to a node
7 SignalObserver::SignalObserver()
8     : _oldsel(0)
9 {}
11 // Add this observer to the SPObject and remove it from any previous object
12 void SignalObserver::set(SPObject* o)
13 {
14   // XML Tree being used direcly in this function in the following code
15   //   while it shouldn't be
16     if(_oldsel && _oldsel->getRepr())
17         _oldsel->getRepr()->removeObserver(*this);
18     if(o && o->getRepr())
19         o->getRepr()->addObserver(*this);
20     _oldsel = o;
21 }
23 void SignalObserver::notifyChildAdded(XML::Node&, XML::Node&, XML::Node*)
24 { signal_changed()(); }
26 void SignalObserver::notifyChildRemoved(XML::Node&, XML::Node&, XML::Node*)
27 { signal_changed()(); }
29 void SignalObserver::notifyChildOrderChanged(XML::Node&, XML::Node&, XML::Node*, XML::Node*)
30 { signal_changed()(); }
32 void SignalObserver::notifyContentChanged(XML::Node&, Util::ptr_shared<char>, Util::ptr_shared<char>)
33 {}
35 void SignalObserver::notifyAttributeChanged(XML::Node&, GQuark, Util::ptr_shared<char>, Util::ptr_shared<char>)
36 { signal_changed()(); }
38 sigc::signal<void>& SignalObserver::signal_changed()
39 {
40     return _signal_changed;
41 }
43 } //namespace XML
44 } //namespace Inkscape