changeset 1304:94e6594dea59

Make comp_dock being instantiated by domview_ui
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 19 Jan 2011 17:56:21 +0800
parents cf2691a18a7a
children 573a51b1eb37
files pyink/MBScene.py pyink/comp_dock.py pyink/domview_ui.py
diffstat 3 files changed, 24 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/pyink/MBScene.py	Wed Jan 19 14:52:29 2011 +0800
+++ b/pyink/MBScene.py	Wed Jan 19 17:56:21 2011 +0800
@@ -58,7 +58,6 @@
 	self.desktop = desktop
 	self.window = win
 	self.top = None
-	self._comp_dock = None
 	self.last_update = None
 	pybInkscape.inkscape.connect('change_selection', self.do_selection)
 	self.last_select = None
@@ -356,8 +355,6 @@
 	pass
 
     def show(self):
-	from comp_dock import comp_dock
-	
 	self.OK = True
 	if not self._root:
 	    self._root = self.desktop.doc().root().repr
@@ -365,6 +362,7 @@
 	
 	self.document = self.desktop.doc().rdoc
 	
+	self._domviewui.set_desktop(self.desktop)
 	self._domviewui.handle_doc_root(self.document, self._root)
 	self._domviewui.register_active_frame_callback(self.do_CellClick)
 	self._director = scenes_director(self._domviewui)
@@ -386,10 +384,6 @@
 	self._add_buttons(hbox)
 	vbox.pack_start(hbox, expand=False)
 
-	dock = comp_dock()
-	dock.install_dock(self.desktop)
-	self._comp_dock = dock
-
 	self.top.show_all()
 	self.last_update = None
 	return False
--- a/pyink/comp_dock.py	Wed Jan 19 14:52:29 2011 +0800
+++ b/pyink/comp_dock.py	Wed Jan 19 17:56:21 2011 +0800
@@ -1,10 +1,13 @@
 import gtk
 import os
+import data_monitor
 
 ## \brief User interface for management components and their timelines.
 #
-class comp_dock(gtk.VBox):
-    def __init__(self, fname=None):
+class comp_dock(object):
+    __metaclass__ = data_monitor.data_monitor
+
+    def __init__(self, domview_ui, fname=None):
         super(comp_dock, self).__init__()
         
         if not fname:
@@ -18,9 +21,9 @@
         dock_top = builder.get_object('component_dock_top')
         dock_top_parent = dock_top.get_parent()
         dock_top_parent.remove(dock_top)
-        self.pack_start(dock_top)
-        dock_top.show()
 
+        self._domview_ui = domview_ui
+        self._locker = domview_ui
         self._builder = builder
         self._dock_top = dock_top
         self._desktop = None
@@ -35,9 +38,9 @@
                              'Component and timeline manager',
                              'feBlend-icon', dock.ITEM_ST_DOCKED_STATE)
         item_vbox = item.get_vbox()
-        item_vbox.pack_start(self)
         self._dock_item = item
         
-        self.show()
+        item_vbox.pack_start(self._dock_top)
+        self._dock_top.show()
         pass
     pass
--- a/pyink/domview_ui.py	Wed Jan 19 14:52:29 2011 +0800
+++ b/pyink/domview_ui.py	Wed Jan 19 17:56:21 2011 +0800
@@ -383,9 +383,14 @@
     _tween_type_names = ('normal', 'scale')
     
     def __init__(self):
+        from comp_dock import comp_dock
+        
 	super(domview_ui, self).__init__()
+        
 	self._fl_stack = frameline_stack()
 	self._dom = domview()
+        self._comp_dock = comp_dock(self)
+        self._desktop = None
         self._doc = None
         self._root = None
         self._lock = False
@@ -426,6 +431,15 @@
 	    pass
 	pass
     
+    ## \brief Setup desktop that the document will be serviced.
+    #
+    # This method must be called before handle_doc_root.
+    #
+    def set_desktop(self, desktop):
+        self._desktop = desktop
+        self._comp_dock.install_dock(desktop) # from component_manager
+        pass
+    
     ## \brief This method is called to handle a new document.
     #
     def handle_doc_root(self, doc, root):