changeset 1311:e6bb9d00341f

Make content dom and comp_dock synchronized
author Thinker K.F. Li <thinker@codemud.net>
date Thu, 20 Jan 2011 13:08:26 +0800
parents 85d04ba11146
children 89e640789750
files pyink/comp_dock.py pyink/domview_ui.py
diffstat 2 files changed, 51 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pyink/comp_dock.py	Thu Jan 20 12:44:37 2011 +0800
+++ b/pyink/comp_dock.py	Thu Jan 20 13:08:26 2011 +0800
@@ -66,7 +66,13 @@
         components_model.clear()
         
         for comp_name in self._domview_ui.all_comp_names():
-            components_model.append((comp_name, True))
+            if comp_name == 'main':
+                editable = False
+            else:
+                editable = True
+                pass
+            
+            components_model.append((comp_name, editable))
             pass
 
         timelines_model = self._timelines_model
@@ -77,6 +83,46 @@
             pass
         pass
 
+    def dom_add_component(self, name):
+        model = self._components_model
+        model.append((name, True))
+        pass
+
+    def dom_rm_component(self, name):
+        model = self._components_model
+        
+        itr = model.get_iter_first()
+        while itr:
+            itr_name = model.get_value(itr, 0)
+            if itr_name == name:
+                model.remove(itr)
+                return
+            
+            itr = itr.iter_next()
+            pass
+        
+        raise ValueError, 'unknown component name - %s' % (name)
+
+    def dom_add_timeline(self, name):
+        model = self._timelines_model
+        model.append((name, True))
+        pass
+
+    def dom_rm_timeline(self, name):
+        model = self._timelines_model
+        
+        itr = model.get_iter_first()
+        while itr:
+            itr_name = model.get_value(itr, 0)
+            if itr_name == name:
+                model.remove(itr)
+                return
+            
+            itr = itr.iter_next()
+            pass
+        
+        raise ValueError, 'unknown component name - %s' % (name)
+
     def _current_component(self):
         treeview = self._components_treeview
         path, col = treeview.get_cursor()
--- a/pyink/domview_ui.py	Thu Jan 20 12:44:37 2011 +0800
+++ b/pyink/domview_ui.py	Thu Jan 20 13:08:26 2011 +0800
@@ -400,10 +400,12 @@
     
     def add_component(self, name):
         self._dom.add_component(name)
+        self._comp_dock.dom_add_component(name)
         pass
 
     def rm_component(self, name):
         self._dom.rm_component(name)
+        self._comp_dock.dom_rm_component(name)
         pass
 
     def switch_component(self, name):
@@ -420,10 +422,12 @@
 
     def add_timeline(self, name):
         self._dom.add_timeline(name)
+        self._comp_dock.dom_add_timeline(name)
         pass
 
     def rm_timeline(self, name):
         self._dom.rm_timeline(name)
+        self._comp_dock.dom_rm_timeline(name)
         pass
 
     def switch_timeline(self, name):