Mercurial > MadButterfly
comparison pyink/dom_event.py @ 1253:07e0cb1e051d
Add class consistency_checker for domview_ui.
- consistency_checker is to check consistency of the DOM-tree
associated with a domview_ui.
- It is so closed to domview_ui, so it may access private
variables.
- But, it uses public interface of domview_ui if possible.
- consistency_checker is not integrated to domview_ui for separating
functions of consistency checking from the domview_ui. It collects
relative logic into a place and setups a boundary from others.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 11 Jan 2011 11:43:32 +0800 |
parents | |
children | 5313bbfafa67 |
comparison
equal
deleted
inserted
replaced
1252:71222a6b4c06 | 1253:07e0cb1e051d |
---|---|
1 import pybInkscape | |
2 | |
3 class ObjectWatcher(pybInkscape.PYNodeObserver): | |
4 def __init__(self, obj, type, func, arg): | |
5 self.obj = obj | |
6 self.type = type | |
7 self.func = func | |
8 self.arg = arg | |
9 | |
10 def notifyChildAdded(self, node, child, prev): | |
11 if self.type == 'DOMNodeInserted': | |
12 self.func(node, child) | |
13 def notifyChildRemoved(self, node, child, prev): | |
14 if self.type == 'DOMNodeRemoved': | |
15 self.func(node, child) | |
16 def notifyChildOrderChanged(self,node,child,prev): | |
17 pass | |
18 def notifyContentChanged(self,node,old_content,new_content): | |
19 if self.type == 'DOMSubtreeModified': | |
20 self.func(node) | |
21 def notifyAttributeChanged(self,node, name, old_value, new_value): | |
22 if self.type == 'DOMAttrModified': | |
23 self.func(node, name, old_value, new_value) | |
24 | |
25 def addEventListener(obj, type, func, arg): | |
26 obs = ObjectWatcher(obj, type, func, arg) | |
27 obj.addSubtreeObserver(obs) | |
28 pass | |
29 |