Mercurial > MadButterfly
view pyink/dom_event.py @ 1342:972d749b9656
Move component_manager to a separated object.
- component_manager is a mixin for domview.
- domview inherit component_manager to mixing-in component_manager.
- There is no boundary between component_manager and domview, hard
to be managed and reused.
- component_manager is a separated object that hold a reference to
corresponding domview.
- domview delegate attribute accessing to component_manager object to
expose attributes and methods of component_manager. (__getattr__())
- component_manager is still a mix-in of domview.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 08 Feb 2011 13:05:07 +0800 |
parents | 07e0cb1e051d |
children | 5313bbfafa67 |
line wrap: on
line source
import pybInkscape class ObjectWatcher(pybInkscape.PYNodeObserver): def __init__(self, obj, type, func, arg): self.obj = obj self.type = type self.func = func self.arg = arg def notifyChildAdded(self, node, child, prev): if self.type == 'DOMNodeInserted': self.func(node, child) def notifyChildRemoved(self, node, child, prev): if self.type == 'DOMNodeRemoved': self.func(node, child) def notifyChildOrderChanged(self,node,child,prev): pass def notifyContentChanged(self,node,old_content,new_content): if self.type == 'DOMSubtreeModified': self.func(node) def notifyAttributeChanged(self,node, name, old_value, new_value): if self.type == 'DOMAttrModified': self.func(node, name, old_value, new_value) def addEventListener(obj, type, func, arg): obs = ObjectWatcher(obj, type, func, arg) obj.addSubtreeObserver(obs) pass