comparison pyink/MBScene.py @ 1130:37a0f6ab2f91

Lock the UI from refreshing during the update procedure
author wycc
date Sat, 18 Dec 2010 10:00:01 +0800
parents b65ac686a7c5
children 3ec0ad89e443
comparison
equal deleted inserted replaced
1128:b65ac686a7c5 1130:37a0f6ab2f91
81 def notifyContentChanged(self,node,old_content,new_content): 81 def notifyContentChanged(self,node,old_content,new_content):
82 print 'cont' 82 print 'cont'
83 if self.type == 'DOMSubtreeModified': 83 if self.type == 'DOMSubtreeModified':
84 self.func(node) 84 self.func(node)
85 def notifyAttributeChanged(self,node, name, old_value, new_value): 85 def notifyAttributeChanged(self,node, name, old_value, new_value):
86 print 'attr' 86 print 'attr',node,name,old_value,new_value
87 if self.type == 'DOMAttrModified': 87 if self.type == 'DOMAttrModified':
88 self.func(node,name) 88 self.func(node,name)
89 89
90 def addEventListener(obj, type, func,arg): 90 def addEventListener(obj, type, func,arg):
91 obs = ObjectWatcher(obj,type,func,arg) 91 obs = ObjectWatcher(obj,type,func,arg)
129 self.scenemap = None 129 self.scenemap = None
130 self.top = None 130 self.top = None
131 self.last_update = None 131 self.last_update = None
132 pybInkscape.inkscape.connect('change_selection', self.show_selection) 132 pybInkscape.inkscape.connect('change_selection', self.show_selection)
133 self.last_select = None 133 self.last_select = None
134 self.lockui=False
134 pass 135 pass
135 136
136 def startPolling(self): 137 def startPolling(self):
137 objs = self.desktop.selection.list() 138 objs = self.desktop.selection.list()
138 if len(objs) != 1: 139 if len(objs) != 1:
281 self.parseMetadata(node) 282 self.parseMetadata(node)
282 pass 283 pass
283 elif node.name() == 'svg:g': 284 elif node.name() == 'svg:g':
284 oldscene = None 285 oldscene = None
285 #obs = LayerAttributeWatcher(self) 286 #obs = LayerAttributeWatcher(self)
286 addEventListener(doc,'DOMAttrModified',self.updateUI,None) 287 #addEventListener(doc,'DOMAttrModified',self.updateUI,None)
287 #node.addObserver(obs) 288 #node.addObserver(obs)
288 lyobj = Layer(node) 289 lyobj = Layer(node)
289 self.layers.append(lyobj) 290 self.layers.append(lyobj)
290 lyobj.current_scene = [] 291 lyobj.current_scene = []
291 for scene in node.childList(): 292 for scene in node.childList():
820 821
821 def onCellClick(self,line,frame,but): 822 def onCellClick(self,line,frame,but):
822 self.last_line = line 823 self.last_line = line
823 self.last_frame = frame 824 self.last_frame = frame
824 self.last_line.active_frame(frame) 825 self.last_line.active_frame(frame)
826 self.lockui = True
825 self.doEditScene(frame) 827 self.doEditScene(frame)
828 self.lockui = False
826 829
827 830
828 def _remove_active_frame(self,widget,event): 831 def _remove_active_frame(self,widget,event):
829 """ 832 """
830 Hide all hover frames. This is a hack. We should use the lost focus event 833 Hide all hover frames. This is a hack. We should use the lost focus event
1052 self.OK = True 1055 self.OK = True
1053 gtk.main_quit() 1056 gtk.main_quit()
1054 pass 1057 pass
1055 1058
1056 def updateUI(self,node=None,arg=None): 1059 def updateUI(self,node=None,arg=None):
1060 if self.lockui: return
1061 self.lockui = True
1062 self._updateUI()
1063 self.lockui = False
1064 def _updateUI(self,node=None,arg=None):
1057 if self.last_update!= None: 1065 if self.last_update!= None:
1058 glib.source_remove(self.last_update) 1066 glib.source_remove(self.last_update)
1059 self.last_update = glib.timeout_add(300,self.show) 1067 self.last_update = glib.timeout_add(300,self.show)
1060 def show(self): 1068 def show(self):
1061 self.OK = True 1069 self.OK = True