Mercurial > MadButterfly
annotate pyink/comp_dock.py @ 1315:fcff6978f9bf
User can switch components.
- component_manager will change domview._scenes_node and
domview._layers_parent for switching component and timeline.
- domview relys on domview._scenes_node and domview._layers_parent to
find scene nodes and layers.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sat, 22 Jan 2011 14:23:42 +0800 |
parents | 2aa3770f02bf |
children | 9ab8d50dcf7e |
rev | line source |
---|---|
1303 | 1 import gtk |
2 import os | |
1304
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
3 import data_monitor |
1303 | 4 |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
5 |
1303 | 6 ## \brief User interface for management components and their timelines. |
7 # | |
1312
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
8 # This class provide base functions to show components and timelines. |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
9 # |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
10 class comp_dock_base(object): |
1304
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
11 def __init__(self, domview_ui, fname=None): |
1312
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
12 super(comp_dock_base, self).__init__(domview_ui, fname) |
1303 | 13 |
14 if not fname: | |
15 dirname = os.path.dirname(__file__) | |
16 fname = os.path.join(dirname, 'component_dock.glade') | |
17 pass | |
18 | |
19 builder = gtk.Builder() | |
20 builder.add_from_file(fname) | |
21 dock_top = builder.get_object('component_dock_top') | |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
22 components_model = builder.get_object('components_model') |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
23 timelines_model = builder.get_object('timelines_model') |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
24 components_treeview = builder.get_object('treeview_components') |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
25 timelines_treeview = builder.get_object('treeview_timelines') |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
26 |
1303 | 27 dock_top_parent = dock_top.get_parent() |
28 dock_top_parent.remove(dock_top) | |
29 | |
1304
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
30 self._domview_ui = domview_ui |
1303 | 31 self._builder = builder |
32 self._dock_top = dock_top | |
33 self._desktop = None | |
34 self._dock_item = None | |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
35 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
36 self._components_model = components_model |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
37 self._timelines_model = timelines_model |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
38 self._components_treeview = components_treeview |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
39 self._timelines_treeview = timelines_treeview |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
40 |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
41 self._cur_component = -1 |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
42 self._cur_timeline = -1 |
1303 | 43 pass |
44 | |
45 def install_dock(self, desktop): | |
46 self._desktop = desktop | |
47 | |
48 dock = desktop.getDock() | |
49 item = dock.new_item('component_dock', | |
50 'Component and timeline manager', | |
51 'feBlend-icon', dock.ITEM_ST_DOCKED_STATE) | |
52 item_vbox = item.get_vbox() | |
53 self._dock_item = item | |
54 | |
1304
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
55 item_vbox.pack_start(self._dock_top) |
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
56 self._dock_top.show() |
1303 | 57 pass |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
58 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
59 ## \brief Refresh content of component list and timeline list. |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
60 # |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
61 def refresh(self): |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
62 components_model = self._components_model |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
63 components_model.clear() |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
64 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
65 for comp_name in self._domview_ui.all_comp_names(): |
1311
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
66 if comp_name == 'main': |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
67 editable = False |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
68 else: |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
69 editable = True |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
70 pass |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
71 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
72 components_model.append((comp_name, editable)) |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
73 pass |
1313
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
74 |
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
75 self._components_treeview.set_cursor((0,)) |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
76 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
77 timelines_model = self._timelines_model |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
78 timelines_model.clear() |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
79 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
80 for timeline_name in self._domview_ui.all_timeline_names(): |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
81 timelines_model.append((timeline_name, True)) |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
82 pass |
1313
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
83 |
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
84 self._timelines_treeview.set_cursor((0,)) |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
85 pass |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
86 |
1311
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
87 def dom_add_component(self, name): |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
88 model = self._components_model |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
89 model.append((name, True)) |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
90 pass |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
91 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
92 def dom_rm_component(self, name): |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
93 model = self._components_model |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
94 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
95 itr = model.get_iter_first() |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
96 while itr: |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
97 itr_name = model.get_value(itr, 0) |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
98 if itr_name == name: |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
99 model.remove(itr) |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
100 return |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
101 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
102 itr = itr.iter_next() |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
103 pass |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
104 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
105 raise ValueError, 'unknown component name - %s' % (name) |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
106 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
107 def dom_add_timeline(self, name): |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
108 model = self._timelines_model |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
109 model.append((name, True)) |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
110 pass |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
111 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
112 def dom_rm_timeline(self, name): |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
113 model = self._timelines_model |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
114 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
115 itr = model.get_iter_first() |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
116 while itr: |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
117 itr_name = model.get_value(itr, 0) |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
118 if itr_name == name: |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
119 model.remove(itr) |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
120 return |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
121 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
122 itr = itr.iter_next() |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
123 pass |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
124 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
125 raise ValueError, 'unknown component name - %s' % (name) |
1312
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
126 pass |
1311
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
127 |
1312
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
128 ## \brief UI interactive handlers |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
129 # |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
130 # A mix-in to handle UI events. |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
131 # |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
132 class comp_dock_ui(object): |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
133 __metaclass__ = data_monitor.data_monitor |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
134 __data_monitor_prefix__ = 'on_' |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
135 |
1313
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
136 def __init__(self, domview_ui, fname=None): |
1312
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
137 super(comp_dock_ui, self).__init__() |
1313
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
138 |
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
139 self._locker = domview_ui |
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
140 pass |
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
141 |
1314
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1313
diff
changeset
|
142 ## \brief Start handle UI events. |
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1313
diff
changeset
|
143 # |
1313
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
144 def start_handle_ui_events(self): |
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
145 self._builder.connect_signals(self) |
1312
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
146 pass |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
147 |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
148 def _current_component(self): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
149 treeview = self._components_treeview |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
150 path, col = treeview.get_cursor() |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
151 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
152 model = self._components_model |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
153 itr = model.get_iter(path) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
154 name = model.get_value(itr, 0) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
155 return name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
156 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
157 def _current_timeline(self): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
158 treeview = self._timelines_treeview |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
159 path, col = treeview.get_cursor() |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
160 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
161 model = self._timelines_model |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
162 itr = model.get_iter(path) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
163 name = model.get_value(itr, 0) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
164 return name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
165 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
166 def _add_component(self): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
167 def _make_component_name(): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
168 comp_name = 'New Component' |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
169 idx = 0 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
170 while comp_name in self._domview_ui.all_comp_names(): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
171 comp_name = 'New Component %d' % (idx) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
172 idx = idx + 1 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
173 pass |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
174 return comp_name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
175 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
176 comp_name = _make_component_name() |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
177 print comp_name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
178 self._domview_ui.add_component(comp_name) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
179 pass |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
180 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
181 def _rm_component(self): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
182 if self._current_component() == 'main': |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
183 return |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
184 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
185 treeview = self._components_treeview |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
186 path, col = treeview.get_cursor() |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
187 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
188 model = self._components_model |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
189 itr = model.get_iter(path) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
190 comp_name = model.get_value(itr, 0) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
191 print comp_name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
192 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
193 self._domview_ui.rm_component(comp_name) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
194 pass |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
195 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
196 def _add_timeline(self): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
197 def _make_timeline_name(): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
198 tl_name = 'New Timeline' |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
199 idx = 0 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
200 while tl_name in self._domview_ui.all_timeline_names(): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
201 tl_name = 'New Timeline %d' % (idx) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
202 idx = idx + 1 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
203 pass |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
204 return tl_name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
205 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
206 if self._current_component() == 'main': |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
207 return |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
208 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
209 tl_name = _make_timeline_name() |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
210 print tl_name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
211 self._domview_ui.add_timeline(tl_name) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
212 pass |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
213 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
214 def _rm_timeline(self): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
215 if self._current_component() == 'main': |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
216 return |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
217 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
218 treeview = self._timelines_treeview |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
219 path, col = treeview.get_cursor() |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
220 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
221 model = self._timelines_model |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
222 itr = model.get_iter(path) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
223 tl_name = model.get_value(itr, col) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
224 print tl_name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
225 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
226 self._domview_ui.rm_timeline(tl_name) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
227 pass |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
228 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
229 def on_add_comp_clicked(self, *args): |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
230 self._add_component() |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
231 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
232 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
233 def on_remove_comp_clicked(self, *args): |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
234 self._rm_component() |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
235 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
236 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
237 def on_treeview_components_cursor_changed(self, *args): |
1315
fcff6978f9bf
User can switch components.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
238 comp_name = self._current_component() |
fcff6978f9bf
User can switch components.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
239 print comp_name |
fcff6978f9bf
User can switch components.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
240 |
fcff6978f9bf
User can switch components.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
241 domview_ui = self._domview_ui |
fcff6978f9bf
User can switch components.
Thinker K.F. Li <thinker@codemud.net>
parents:
1314
diff
changeset
|
242 domview_ui.switch_component(comp_name) |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
243 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
244 |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
245 def on_cellrenderer_comp_edited(self, renderer, path, |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
246 new_text, *args): |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
247 print '%s - %s' % (path, new_text) |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
248 pass |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
249 |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
250 def on_add_timeline_clicked(self, *args): |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
251 self._add_timeline() |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
252 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
253 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
254 def on_remove_timeline_clicked(self, *args): |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
255 self._rm_timeline() |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
256 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
257 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
258 def on_treeview_timelines_cursor_changed(self, *args): |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
259 print args |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
260 pass |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
261 |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
262 def on_cellrenderer_timelines_edited(self, renderer, path, |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
263 new_text, *args): |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
264 print '%s - %s' % (path, new_text) |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
265 pass |
1303 | 266 pass |
1312
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
267 |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
268 ## \brief Component dock |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
269 # |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
270 # Mix base functions and event handlers together. |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
271 # |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
272 class comp_dock(comp_dock_base, comp_dock_ui): |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
273 def __init__(self, domview_ui, fname=None): |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
274 super(comp_dock, self).__init__(domview_ui, fname) |
1314
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1313
diff
changeset
|
275 |
1313
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
276 self.start_handle_ui_events() |
1312
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
277 pass |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
278 pass |