changeset 1308:49775feefbcf

Show components and timelines in comp_dock
author Thinker K.F. Li <thinker@codemud.net>
date Thu, 20 Jan 2011 00:50:49 +0800
parents cfbc0f3e54e3
children f2b1b22f7cbc
files pyink/comp_dock.py pyink/component_dock.glade pyink/domview.py pyink/domview_ui.py
diffstat 4 files changed, 108 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/pyink/comp_dock.py	Thu Jan 20 00:34:08 2011 +0800
+++ b/pyink/comp_dock.py	Thu Jan 20 00:50:49 2011 +0800
@@ -2,10 +2,12 @@
 import os
 import data_monitor
 
+
 ## \brief User interface for management components and their timelines.
 #
 class comp_dock(object):
     __metaclass__ = data_monitor.data_monitor
+    __data_monitor_prefix__ = 'on_'
 
     def __init__(self, domview_ui, fname=None):
         super(comp_dock, self).__init__()
@@ -17,7 +19,11 @@
 
         builder = gtk.Builder()
         builder.add_from_file(fname)
+        builder.connect_signals(self)
         dock_top = builder.get_object('component_dock_top')
+        components_model = builder.get_object('components_model')
+        timelines_model = builder.get_object('timelines_model')
+        
         dock_top_parent = dock_top.get_parent()
         dock_top_parent.remove(dock_top)
 
@@ -27,6 +33,9 @@
         self._dock_top = dock_top
         self._desktop = None
         self._dock_item = None
+        
+        self._components_model = components_model
+        self._timelines_model = timelines_model
         pass
 
     def install_dock(self, desktop):
@@ -42,4 +51,46 @@
         item_vbox.pack_start(self._dock_top)
         self._dock_top.show()
         pass
+
+    ## \brief Refresh content of component list and timeline list.
+    #
+    def refresh(self):
+        components_model = self._components_model
+        components_model.clear()
+        
+        for comp_name in self._domview_ui.all_comp_names():
+            components_model.append((comp_name,))
+            pass
+
+        timelines_model = self._timelines_model
+        timelines_model.clear()
+
+        for timeline_name in self._domview_ui.all_timeline_names():
+            timelines_model.append((timeline_name,))
+            pass
+        pass
+    
+    def on_add_comp_clicked(self, *args):
+        print args
+        pass
+
+    def on_remove_comp_clicked(self, *args):
+        print args
+        pass
+
+    def on_treeview_components_cursor_changed(self, *args):
+        print args
+        pass
+    
+    def on_add_timeline_clicked(self, *args):
+        print args
+        pass
+
+    def on_remove_timeline_clicked(self, *args):
+        print args
+        pass
+
+    def on_treeview_timelines_cursor_changed(self, *args):
+        print args
+        pass
     pass
--- a/pyink/component_dock.glade	Thu Jan 20 00:34:08 2011 +0800
+++ b/pyink/component_dock.glade	Thu Jan 20 00:50:49 2011 +0800
@@ -2,6 +2,18 @@
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy project-wide -->
+  <object class="GtkListStore" id="components_model">
+    <columns>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <object class="GtkListStore" id="timelines_model">
+    <columns>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkWindow" id="window1">
     <child>
       <object class="GtkVBox" id="component_dock_top">
@@ -12,26 +24,28 @@
             <property name="visible">True</property>
             <property name="orientation">vertical</property>
             <child>
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="xalign">0</property>
-                <property name="xpad">5</property>
-                <property name="label" translatable="yes">Components</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
               <object class="GtkTreeView" id="treeview_components">
                 <property name="height_request">100</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="model">components_model</property>
+                <signal name="cursor_changed" handler="on_treeview_components_cursor_changed"/>
+                <child>
+                  <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                    <property name="sizing">autosize</property>
+                    <property name="title">Component Name</property>
+                    <property name="expand">True</property>
+                    <child>
+                      <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                      <attributes>
+                        <attribute name="text">0</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                </child>
               </object>
               <packing>
-                <property name="position">1</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
@@ -46,6 +60,7 @@
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
                     <property name="use_stock">True</property>
+                    <signal name="clicked" handler="on_add_comp_clicked"/>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -60,6 +75,7 @@
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
                     <property name="use_stock">True</property>
+                    <signal name="clicked" handler="on_remove_comp_clicked"/>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -72,7 +88,7 @@
                 <property name="expand">False</property>
                 <property name="fill">False</property>
                 <property name="padding">1</property>
-                <property name="position">2</property>
+                <property name="position">1</property>
               </packing>
             </child>
           </object>
@@ -96,26 +112,29 @@
             <property name="visible">True</property>
             <property name="orientation">vertical</property>
             <child>
-              <object class="GtkLabel" id="label2">
-                <property name="visible">True</property>
-                <property name="xalign">0</property>
-                <property name="xpad">5</property>
-                <property name="label" translatable="yes">Actions / timelines</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
               <object class="GtkTreeView" id="treeview_timelines">
                 <property name="height_request">100</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="model">timelines_model</property>
+                <property name="search_column">1</property>
+                <property name="level_indentation">9</property>
+                <property name="enable_grid_lines">horizontal</property>
+                <signal name="cursor_changed" handler="on_treeview_timelines_cursor_changed"/>
+                <child>
+                  <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+                    <property name="title">Action/Timeline Name</property>
+                    <child>
+                      <object class="GtkCellRendererText" id="cellrenderertext2"/>
+                      <attributes>
+                        <attribute name="text">0</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                </child>
               </object>
               <packing>
-                <property name="position">1</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
@@ -124,12 +143,13 @@
                 <property name="spacing">5</property>
                 <property name="layout_style">start</property>
                 <child>
-                  <object class="GtkButton" id="add_timline">
+                  <object class="GtkButton" id="add_timeline">
                     <property name="label">gtk-add</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
                     <property name="use_stock">True</property>
+                    <signal name="clicked" handler="on_add_timeline_clicked"/>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -144,6 +164,7 @@
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
                     <property name="use_stock">True</property>
+                    <signal name="clicked" handler="on_remove_timeline_clicked"/>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -156,7 +177,7 @@
                 <property name="expand">False</property>
                 <property name="fill">False</property>
                 <property name="padding">2</property>
-                <property name="position">2</property>
+                <property name="position">1</property>
               </packing>
             </child>
           </object>
--- a/pyink/domview.py	Thu Jan 20 00:34:08 2011 +0800
+++ b/pyink/domview.py	Thu Jan 20 00:50:49 2011 +0800
@@ -17,7 +17,7 @@
         pass
 
     def name(self):
-        name = self.node.getAttribute('name')
+        name = self.scenes_node.getAttribute('name')
         return name
     pass
 
--- a/pyink/domview_ui.py	Thu Jan 20 00:34:08 2011 +0800
+++ b/pyink/domview_ui.py	Thu Jan 20 00:50:49 2011 +0800
@@ -379,7 +379,8 @@
 ## \biref Components and timelines management for domview.
 #
 # This is mix-in for domview_ui to provide components and timelines
-# management functions.
+# management functions.  This class expose a lot of methods from class
+# component_manager.
 #
 class domview_ui_comp(object):
     def __init__(self):
@@ -394,7 +395,7 @@
     #
     def set_desktop(self, desktop):
         self._desktop = desktop
-        self._comp_dock.install_dock(desktop) # from component_manager
+        self._comp_dock.install_dock(desktop)
         pass
     
     def add_component(self, name):
@@ -498,6 +499,7 @@
 	self._fl_stack.init_framelines()
 	self._add_frameline_for_every_layer()
 	self._fl_stack.show_framelines()
+        self._comp_dock.refresh() # from domview_ui_comp
 
         self._doc = doc
         self._root = root