Mercurial > MadButterfly
annotate pyink/comp_dock.py @ 1335:194c7a831083
Consistent checking for components and timelines
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 31 Jan 2011 23:21:20 +0800 |
parents | 3cbc1ab15541 |
children | 0b5ee9c90af7 |
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') |
1331
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
25 components_menu = builder.get_object('components_menu') |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
26 timelines_treeview = builder.get_object('treeview_timelines') |
1331
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
27 timelines_menu = builder.get_object('timelines_menu') |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
28 |
1303 | 29 dock_top_parent = dock_top.get_parent() |
30 dock_top_parent.remove(dock_top) | |
31 | |
1304
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
32 self._domview_ui = domview_ui |
1303 | 33 self._builder = builder |
34 self._dock_top = dock_top | |
35 self._desktop = None | |
36 self._dock_item = None | |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
37 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
38 self._components_model = components_model |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
39 self._timelines_model = timelines_model |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
40 self._components_treeview = components_treeview |
1331
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
41 self._components_menu = components_menu |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
42 self._timelines_treeview = timelines_treeview |
1331
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
43 self._timelines_menu = timelines_menu |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
44 |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
45 self._cur_component = -1 |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
46 self._cur_timeline = -1 |
1303 | 47 pass |
48 | |
49 def install_dock(self, desktop): | |
50 self._desktop = desktop | |
51 | |
52 dock = desktop.getDock() | |
53 item = dock.new_item('component_dock', | |
54 'Component and timeline manager', | |
55 'feBlend-icon', dock.ITEM_ST_DOCKED_STATE) | |
56 item_vbox = item.get_vbox() | |
57 self._dock_item = item | |
58 | |
1304
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
59 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
|
60 self._dock_top.show() |
1303 | 61 pass |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
62 |
1316
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
63 ## \brief Update the list of components. |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
64 # |
1316
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
65 # The cursor is still keeping on the name of current component. |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
66 # |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
67 def refresh_components(self): |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
68 components_model = self._components_model |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
69 components_model.clear() |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
70 |
1316
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
71 all_comp_names = self._domview_ui.all_comp_names() |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
72 for comp_name in all_comp_names: |
1330
c2a693a27eb9
Double click to switch component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
73 editable = False |
1311
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
74 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
|
75 pass |
1313
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
76 |
1316
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
77 cur_comp_name = self._domview_ui.get_current_component() |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
78 cur_comp_idx = all_comp_names.index(cur_comp_name) |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
79 self._components_treeview.set_cursor((cur_comp_idx,)) |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
80 pass |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
81 |
1316
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
82 ## \brief Update the list of timelines. |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
83 # |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
84 # The cursor is still keeping on the name of current component. |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
85 # |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
86 def refresh_timelines(self): |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
87 timelines_model = self._timelines_model |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
88 timelines_model.clear() |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
89 |
1316
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
90 all_timeline_names = self._domview_ui.all_timeline_names() |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
91 for timeline_name in all_timeline_names: |
1330
c2a693a27eb9
Double click to switch component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
92 timelines_model.append((timeline_name, False)) |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
93 pass |
1313
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
94 |
1316
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
95 cur_tl_name = self._domview_ui.get_current_timeline() |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
96 cur_tl_idx = all_timeline_names.index(cur_tl_name) |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
97 self._timelines_treeview.set_cursor((cur_tl_idx,)) |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
98 pass |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
99 |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
100 ## \brief Refresh content of component list and timeline list. |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
101 # |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
102 def refresh(self): |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
103 self.refresh_components() |
9ab8d50dcf7e
Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents:
1315
diff
changeset
|
104 self.refresh_timelines() |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
105 pass |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
106 |
1311
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
107 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
|
108 model = self._components_model |
1330
c2a693a27eb9
Double click to switch component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
109 model.append((name, False)) |
1311
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_component(self, name): |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
113 model = self._components_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) |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
126 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
127 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
|
128 model = self._timelines_model |
1330
c2a693a27eb9
Double click to switch component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
129 model.append((name, False)) |
1311
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
130 pass |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
131 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
132 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
|
133 model = self._timelines_model |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
134 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
135 itr = model.get_iter_first() |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
136 while itr: |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
137 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
|
138 if itr_name == name: |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
139 model.remove(itr) |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
140 return |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
141 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
142 itr = itr.iter_next() |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
143 pass |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
144 |
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
145 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
|
146 pass |
1311
e6bb9d00341f
Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents:
1310
diff
changeset
|
147 |
1312
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
148 ## \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
|
149 # |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
150 # 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
|
151 # |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
152 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
|
153 __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
|
154 __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
|
155 |
1313
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
156 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
|
157 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
|
158 |
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
159 self._locker = domview_ui |
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
160 pass |
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
161 |
1314
2aa3770f02bf
Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents:
1313
diff
changeset
|
162 ## \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
|
163 # |
1313
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
164 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
|
165 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
|
166 pass |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
167 |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
168 def _current_component(self): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
169 treeview = self._components_treeview |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
170 path, col = treeview.get_cursor() |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
171 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
172 model = self._components_model |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
173 itr = model.get_iter(path) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
174 name = model.get_value(itr, 0) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
175 return name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
176 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
177 def _current_timeline(self): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
178 treeview = self._timelines_treeview |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
179 path, col = treeview.get_cursor() |
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 model = self._timelines_model |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
182 itr = model.get_iter(path) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
183 name = model.get_value(itr, 0) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
184 return name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
185 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
186 def _add_component(self): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
187 def _make_component_name(): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
188 comp_name = 'New Component' |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
189 idx = 0 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
190 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
|
191 comp_name = 'New Component %d' % (idx) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
192 idx = idx + 1 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
193 pass |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
194 return comp_name |
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 comp_name = _make_component_name() |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
197 print comp_name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
198 self._domview_ui.add_component(comp_name) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
199 pass |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
200 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
201 def _rm_component(self): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
202 if self._current_component() == 'main': |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
203 return |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
204 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
205 treeview = self._components_treeview |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
206 path, col = treeview.get_cursor() |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
207 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
208 model = self._components_model |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
209 itr = model.get_iter(path) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
210 comp_name = model.get_value(itr, 0) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
211 print comp_name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
212 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
213 self._domview_ui.rm_component(comp_name) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
214 pass |
1332
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
215 |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
216 def _switch_component(self): |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
217 domview_ui = self._domview_ui |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
218 |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
219 comp_name = self._current_component() |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
220 domview_ui.switch_component(comp_name) |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
221 |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
222 group = domview_ui.get_layer_group(0) |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
223 desktop = self._desktop # from comp_dock_base |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
224 desktop.setCurrentLayer(group.spitem) |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
225 pass |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
226 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
227 def _add_timeline(self): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
228 def _make_timeline_name(): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
229 tl_name = 'New Timeline' |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
230 idx = 0 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
231 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
|
232 tl_name = 'New Timeline %d' % (idx) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
233 idx = idx + 1 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
234 pass |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
235 return tl_name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
236 |
1333
3cbc1ab15541
Implement the function to create a link to a component.
Thinker K.F. Li <thinker@codemud.net>
parents:
1332
diff
changeset
|
237 if self._domview_ui.get_current_component() == 'main': |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
238 return |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
239 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
240 tl_name = _make_timeline_name() |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
241 print tl_name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
242 self._domview_ui.add_timeline(tl_name) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
243 pass |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
244 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
245 def _rm_timeline(self): |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
246 if self._current_component() == 'main': |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
247 return |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
248 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
249 treeview = self._timelines_treeview |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
250 path, col = treeview.get_cursor() |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
251 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
252 model = self._timelines_model |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
253 itr = model.get_iter(path) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
254 tl_name = model.get_value(itr, col) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
255 print tl_name |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
256 |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
257 self._domview_ui.rm_timeline(tl_name) |
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
258 pass |
1332
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
259 |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
260 def _switch_timeline(self): |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
261 domview_ui = self._domview_ui |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
262 |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
263 timeline_name = self._current_timeline() |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
264 domview_ui.switch_timeline(timeline_name) |
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
265 pass |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
266 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
267 def on_add_comp_clicked(self, *args): |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
268 self._add_component() |
1335
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
269 self._desktop.doc().done("None", |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
270 "Add a new component") |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
271 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
272 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
273 def on_remove_comp_clicked(self, *args): |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
274 self._rm_component() |
1335
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
275 self._desktop.doc().done("None", |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
276 "Remove a component") |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
277 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
278 |
1331
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
279 def on_treeview_components_button_press_event(self, widget, event, *args): |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
280 if event.type != gtk.gdk.BUTTON_PRESS: |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
281 return |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
282 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
283 if event.button != 3: # not right button |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
284 return |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
285 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
286 self._components_menu.popup(None, None, None, event.button, event.time) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
287 pass |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
288 |
1330
c2a693a27eb9
Double click to switch component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
289 def on_treeview_components_row_activated(self, *args): |
1332
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
290 self._switch_component() |
1335
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
291 self._desktop.doc().done("None", |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
292 "Switch to another component") |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
293 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
294 |
1331
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
295 ## \brief Handle of changing component name. |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
296 # |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
297 def on_cellrenderer_comp_edited(self, renderer, path, |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
298 new_text, *args): |
1331
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
299 model = self._components_model |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
300 itr = model.get_iter(path) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
301 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
302 old_name = model.get_value(itr, 0) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
303 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
304 model.set_value(itr, 0, new_text) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
305 model.set_value(itr, 1, False) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
306 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
307 self._domview_ui.rename_component(old_name, new_text) |
1335
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
308 |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
309 self._desktop.doc().done("None", |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
310 "Change name of a component") |
1331
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
311 pass |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
312 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
313 def on_rename_component_activate(self, *args): |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
314 treeview = self._components_treeview |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
315 path, col = treeview.get_cursor() |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
316 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
317 model = self._components_model |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
318 itr = model.get_iter(path) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
319 model.set_value(itr, 1, True) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
320 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
321 treeview.set_cursor(path, col, True) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
322 pass |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
323 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
324 def on_link_component_activate(self, *args): |
1333
3cbc1ab15541
Implement the function to create a link to a component.
Thinker K.F. Li <thinker@codemud.net>
parents:
1332
diff
changeset
|
325 desktop = self._desktop |
3cbc1ab15541
Implement the function to create a link to a component.
Thinker K.F. Li <thinker@codemud.net>
parents:
1332
diff
changeset
|
326 |
3cbc1ab15541
Implement the function to create a link to a component.
Thinker K.F. Li <thinker@codemud.net>
parents:
1332
diff
changeset
|
327 comp_name = self._current_component() |
3cbc1ab15541
Implement the function to create a link to a component.
Thinker K.F. Li <thinker@codemud.net>
parents:
1332
diff
changeset
|
328 cur_layer_group_sp = desktop.currentLayer() |
3cbc1ab15541
Implement the function to create a link to a component.
Thinker K.F. Li <thinker@codemud.net>
parents:
1332
diff
changeset
|
329 cur_layer_group = cur_layer_group_sp.repr |
3cbc1ab15541
Implement the function to create a link to a component.
Thinker K.F. Li <thinker@codemud.net>
parents:
1332
diff
changeset
|
330 |
3cbc1ab15541
Implement the function to create a link to a component.
Thinker K.F. Li <thinker@codemud.net>
parents:
1332
diff
changeset
|
331 self._domview_ui.link_to_component(comp_name, cur_layer_group) |
1335
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
332 |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
333 self._desktop.doc().done("None", |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
334 "Make a xlink of a component") |
1331
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
335 pass |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
336 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
337 def on_switch_component_activate(self, *args): |
1332
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
338 self._switch_component() |
1335
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
339 self._desktop.doc().done("None", |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
340 "Switch to another component") |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
341 pass |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
342 |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
343 def on_add_timeline_clicked(self, *args): |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
344 self._add_timeline() |
1335
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
345 self._desktop.doc().done("None", |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
346 "Add a timeline") |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
347 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
348 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
349 def on_remove_timeline_clicked(self, *args): |
1310
85d04ba11146
Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents:
1309
diff
changeset
|
350 self._rm_timeline() |
1335
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
351 self._desktop.doc().done("None", |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
352 "Remove a timeline") |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
353 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
354 |
1331
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
355 def on_treeview_timelines_button_press_event(self, widget, event, *args): |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
356 if event.type != gtk.gdk.BUTTON_PRESS: |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
357 return |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
358 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
359 if event.button != 3: # not right button |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
360 return |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
361 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
362 self._timelines_menu.popup(None, None, None, event.button, event.time) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
363 pass |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
364 |
1330
c2a693a27eb9
Double click to switch component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents:
1323
diff
changeset
|
365 def on_treeview_timelines_row_activated(self, *args): |
1332
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
366 self._switch_timeline() |
1335
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
367 self._desktop.doc().done("None", |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
368 "Switch to another timeline") |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
369 pass |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
370 |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
371 def on_cellrenderer_timelines_edited(self, renderer, path, |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
372 new_text, *args): |
1331
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
373 model = self._timelines_model |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
374 itr = model.get_iter(path) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
375 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
376 old_name = model.get_value(itr, 0) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
377 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
378 model.set_value(itr, 0, new_text) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
379 model.set_value(itr, 1, False) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
380 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
381 self._domview_ui.rename_timeline(old_name, new_text) |
1335
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
382 |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
383 self._desktop.doc().done("None", |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
384 "Change name of a timeline") |
1331
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
385 pass |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
386 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
387 def on_rename_timeline_activate(self, *args): |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
388 treeview = self._timelines_treeview |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
389 path, col = treeview.get_cursor() |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
390 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
391 model = self._timelines_model |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
392 itr = model.get_iter(path) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
393 model.set_value(itr, 1, True) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
394 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
395 treeview.set_cursor(path, col, True) |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
396 pass |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
397 |
5da64f67d00d
Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1330
diff
changeset
|
398 def on_switch_timeline_activate(self, *args): |
1332
a0d3a4f8e99d
Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents:
1331
diff
changeset
|
399 self._switch_timeline() |
1335
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
400 self._desktop.doc().done("None", |
194c7a831083
Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents:
1333
diff
changeset
|
401 "Switch to another timeline") |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
402 pass |
1303 | 403 pass |
1312
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
404 |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
405 ## \brief Component dock |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
406 # |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
407 # 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
|
408 # |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
409 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
|
410 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
|
411 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
|
412 |
1313
cc557ce8e9fa
Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1312
diff
changeset
|
413 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
|
414 pass |
89e640789750
Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents:
1311
diff
changeset
|
415 pass |