annotate pyink/comp_dock.py @ 1529:af8dd27bf450

Remove layer from button
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 31 Aug 2011 22:30:02 +0800
parents 04b67119df8c
children 199ba528fd4a
rev   line source
1303
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
1 import gtk
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
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
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
4 import pybInkscape
1456
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
5 import FSM_window
1303
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
6
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
7
1303
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
8 ## \brief User interface for management components and their timelines.
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
9 #
1312
89e640789750 Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
10 # 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
11 #
89e640789750 Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
12 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
13 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
14 super(comp_dock_base, self).__init__(domview_ui, fname)
1303
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
15
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
16 if not fname:
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
17 dirname = os.path.dirname(__file__)
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
18 fname = os.path.join(dirname, 'component_dock.glade')
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
19 pass
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
20
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
21 builder = gtk.Builder()
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
22 builder.add_from_file(fname)
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
23 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
24 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
25 timelines_model = builder.get_object('timelines_model')
1309
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
26 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
27 components_menu = builder.get_object('components_menu')
1309
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
28 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
29 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
30
1303
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
31 dock_top_parent = dock_top.get_parent()
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
32 dock_top_parent.remove(dock_top)
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
33
1304
94e6594dea59 Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1303
diff changeset
34 self._domview_ui = domview_ui
1303
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
35 self._builder = builder
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
36 self._dock_top = dock_top
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
37 self._desktop = None
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
38 self._dock_item = None
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
39
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
40 self._components_model = components_model
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
41 self._timelines_model = timelines_model
1309
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
42 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
43 self._components_menu = components_menu
1309
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
44 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
45 self._timelines_menu = timelines_menu
1309
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
46
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
47 self._cur_component = -1
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
48 self._cur_timeline = -1
1303
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
49 pass
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
50
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
51 def install_dock(self, desktop):
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
52 self._desktop = desktop
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
53
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
54 dock = desktop.getDock()
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
55 item = dock.new_item('component_dock',
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
56 'Component and timeline manager',
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
57 'feBlend-icon', dock.ITEM_ST_DOCKED_STATE)
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
58 item_vbox = item.get_vbox()
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
59 self._dock_item = item
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
60
1304
94e6594dea59 Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1303
diff changeset
61 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
62 self._dock_top.show()
1303
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
63 pass
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 ## \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
66 #
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
67 # 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
68 #
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
69 def refresh_components(self):
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
70 components_model = self._components_model
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
71 components_model.clear()
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
72
1460
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
73 cur_comp_name = self._domview_ui.get_current_component()
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
74
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
75 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
76 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
77 editable = False
1460
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
78 selected = comp_name == cur_comp_name
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
79 icon = 'gtk-apply'
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
80 components_model.append((comp_name, editable, selected, icon))
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
81 pass
1313
cc557ce8e9fa Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1312
diff changeset
82
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
83 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
84 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
85 pass
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
86
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
87 ## \brief Update the list of timelines.
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
88 #
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
89 # 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
90 #
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
91 def refresh_timelines(self):
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
92 timelines_model = self._timelines_model
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
93 timelines_model.clear()
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
94
1460
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
95 cur_tl_name = self._domview_ui.get_current_timeline()
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
96
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
97 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
98 for timeline_name in all_timeline_names:
1460
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
99 if timeline_name == cur_tl_name:
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
100 timelines_model.append((timeline_name, False,
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
101 True, 'gtk-apply'))
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
102 else:
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
103 timelines_model.append((timeline_name, False,
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
104 False, 'gtk-apply'))
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
105 pass
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
106 pass
1313
cc557ce8e9fa Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1312
diff changeset
107
1316
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
108 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
109 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
110 pass
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
111
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
112 ## \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
113 #
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
114 def refresh(self):
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
115 self.refresh_components()
9ab8d50dcf7e Refactory code of refreshing UI
Thinker K.F. Li <thinker@codemud.net>
parents: 1315
diff changeset
116 self.refresh_timelines()
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
117 pass
1310
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
118
1311
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
119 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
120 model = self._components_model
1460
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
121 model.append((name, False, False, 'gtk-apply'))
1311
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
122 pass
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
123
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
124 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
125 model = self._components_model
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 itr = model.get_iter_first()
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
128 while itr:
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
129 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
130 if itr_name == name:
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
131 model.remove(itr)
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
132 return
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
133
1417
7c89a4f648bd Fix issue of removing components.
Thinker K.F. Li <thinker@codemud.net>
parents: 1338
diff changeset
134 itr = model.iter_next(itr)
1311
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
135 pass
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
136
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
137 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
138
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
139 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
140 model = self._timelines_model
1460
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
141 model.append((name, False, False, 'gtk-apply'))
1311
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
142 pass
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
143
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
144 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
145 model = self._timelines_model
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
146
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
147 itr = model.get_iter_first()
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
148 while itr:
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
149 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
150 if itr_name == name:
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
151 model.remove(itr)
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
152 return
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
153
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
154 itr = itr.iter_next()
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
155 pass
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
156
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
157 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
158 pass
1311
e6bb9d00341f Make content dom and comp_dock synchronized
Thinker K.F. Li <thinker@codemud.net>
parents: 1310
diff changeset
159
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
160
1312
89e640789750 Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
161 ## \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
162 #
89e640789750 Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
163 # 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
164 #
89e640789750 Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
165 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
166 __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
167 __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
168
1313
cc557ce8e9fa Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1312
diff changeset
169 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
170 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
171
cc557ce8e9fa Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1312
diff changeset
172 self._locker = domview_ui
1456
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
173 self._fsm_editor_win = None
1313
cc557ce8e9fa Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1312
diff changeset
174 pass
cc557ce8e9fa Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1312
diff changeset
175
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
176 def _drop_undo(self):
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
177 self._doc.commit()
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
178 self._doc.beginTransaction()
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
179 pass
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
180
1314
2aa3770f02bf Fix issue of events for setting cursor of treeview.
Thinker K.F. Li <thinker@codemud.net>
parents: 1313
diff changeset
181 ## \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
182 #
1313
cc557ce8e9fa Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1312
diff changeset
183 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
184 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
185 pass
1336
0b5ee9c90af7 Update components and timelines list for async changes on DOM
Thinker K.F. Li <thinker@codemud.net>
parents: 1335
diff changeset
186
0b5ee9c90af7 Update components and timelines list for async changes on DOM
Thinker K.F. Li <thinker@codemud.net>
parents: 1335
diff changeset
187 def install_dock(self, desktop):
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
188 self._doc = desktop.doc().rdoc
1336
0b5ee9c90af7 Update components and timelines list for async changes on DOM
Thinker K.F. Li <thinker@codemud.net>
parents: 1335
diff changeset
189 pass
1312
89e640789750 Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
190
1310
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
191 def _current_component(self):
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
192 treeview = self._components_treeview
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
193 path, col = treeview.get_cursor()
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
194
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
195 model = self._components_model
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
196 itr = model.get_iter(path)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
197 name = model.get_value(itr, 0)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
198 return name
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
199
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
200 def _current_timeline(self):
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
201 treeview = self._timelines_treeview
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
202 path, col = treeview.get_cursor()
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
203
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
204 model = self._timelines_model
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
205 itr = model.get_iter(path)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
206 name = model.get_value(itr, 0)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
207 return name
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 def _add_component(self):
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
210 def _make_component_name():
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
211 comp_name = 'New Component'
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
212 idx = 0
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
213 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
214 comp_name = 'New Component %d' % (idx)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
215 idx = idx + 1
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
216 pass
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
217 return comp_name
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
218
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
219 comp_name = _make_component_name()
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
220 print comp_name
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
221 self._domview_ui.add_component(comp_name)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
222 pass
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
223
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
224 def _rm_component(self):
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
225 if self._current_component() == 'main':
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
226 return
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
227
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
228 treeview = self._components_treeview
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
229 path, col = treeview.get_cursor()
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
230
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
231 model = self._components_model
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
232 itr = model.get_iter(path)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
233 comp_name = model.get_value(itr, 0)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
234
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
235 self._domview_ui.rm_component(comp_name)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
236 pass
1332
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
237
1461
31189b5d832a Add document
Thinker K.F. Li <thinker@codemud.net>
parents: 1460
diff changeset
238 ## \brief Hint user that given component is selected.
31189b5d832a Add document
Thinker K.F. Li <thinker@codemud.net>
parents: 1460
diff changeset
239 #
31189b5d832a Add document
Thinker K.F. Li <thinker@codemud.net>
parents: 1460
diff changeset
240 # Show an icon before the component name.
31189b5d832a Add document
Thinker K.F. Li <thinker@codemud.net>
parents: 1460
diff changeset
241 #
1462
c3e0af5d2487 Rename functions
Thinker K.F. Li <thinker@codemud.net>
parents: 1461
diff changeset
242 def _hint_sel_component(self, comp_name):
1460
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
243 all_comp_names = self._domview_ui.all_comp_names()
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
244 sel_idx = all_comp_names.index(comp_name)
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
245 assert sel_idx >= 0
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
246
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
247 for idx in range(len(all_comp_names)):
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
248 model = self._components_model
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
249 itr = model.get_iter((idx,))
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
250 if idx == sel_idx:
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
251 model.set_value(itr, 2, True)
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
252 else:
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
253 model.set_value(itr, 2, False)
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
254 pass
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
255 pass
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
256 pass
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
257
1332
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
258 def _switch_component(self):
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
259 domview_ui = self._domview_ui
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
260
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
261 comp_name = self._current_component()
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
262 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
263
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
264 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
265 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
266 desktop.setCurrentLayer(group.spitem)
1460
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
267
1462
c3e0af5d2487 Rename functions
Thinker K.F. Li <thinker@codemud.net>
parents: 1461
diff changeset
268 self._hint_sel_component(comp_name)
1460
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
269 tl_name = self._current_timeline()
1462
c3e0af5d2487 Rename functions
Thinker K.F. Li <thinker@codemud.net>
parents: 1461
diff changeset
270 self._hint_sel_timeline(tl_name)
1332
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
271 pass
1310
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
272
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
273 def _add_timeline(self):
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
274 def _make_timeline_name():
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
275 tl_name = 'New Timeline'
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
276 idx = 0
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
277 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
278 tl_name = 'New Timeline %d' % (idx)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
279 idx = idx + 1
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
280 pass
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
281 return tl_name
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
282
1333
3cbc1ab15541 Implement the function to create a link to a component.
Thinker K.F. Li <thinker@codemud.net>
parents: 1332
diff changeset
283 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
284 return
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
285
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
286 tl_name = _make_timeline_name()
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
287 print tl_name
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
288 self._domview_ui.add_timeline(tl_name)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
289 pass
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
290
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
291 def _rm_timeline(self):
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
292 if self._current_component() == 'main':
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
293 return
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
294
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
295 treeview = self._timelines_treeview
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
296 path, col = treeview.get_cursor()
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
297
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
298 model = self._timelines_model
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
299 itr = model.get_iter(path)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
300 tl_name = model.get_value(itr, col)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
301 print tl_name
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
302
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
303 self._domview_ui.rm_timeline(tl_name)
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
304 pass
1332
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
305
1461
31189b5d832a Add document
Thinker K.F. Li <thinker@codemud.net>
parents: 1460
diff changeset
306 ## \brief Hint user that given timeline is selected.
31189b5d832a Add document
Thinker K.F. Li <thinker@codemud.net>
parents: 1460
diff changeset
307 #
31189b5d832a Add document
Thinker K.F. Li <thinker@codemud.net>
parents: 1460
diff changeset
308 # Show an icon before the timeline name.
31189b5d832a Add document
Thinker K.F. Li <thinker@codemud.net>
parents: 1460
diff changeset
309 #
1462
c3e0af5d2487 Rename functions
Thinker K.F. Li <thinker@codemud.net>
parents: 1461
diff changeset
310 def _hint_sel_timeline(self, tl_name):
1460
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
311 all_tl_names = self._domview_ui.all_timeline_names()
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
312 sel_idx = all_tl_names.index(tl_name)
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
313 assert sel_idx >= 0
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
314
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
315 for idx in range(len(all_tl_names)):
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
316 model = self._timelines_model
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
317 itr = model.get_iter((idx,))
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
318 if idx == sel_idx:
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
319 model.set_value(itr, 2, True)
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
320 else:
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
321 model.set_value(itr, 2, False)
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
322 pass
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
323 pass
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
324 pass
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
325
1332
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
326 def _switch_timeline(self):
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
327 domview_ui = self._domview_ui
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
328
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
329 timeline_name = self._current_timeline()
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
330 domview_ui.switch_timeline(timeline_name)
1460
75ca2a66c08d Hint user current selected component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1458
diff changeset
331
1462
c3e0af5d2487 Rename functions
Thinker K.F. Li <thinker@codemud.net>
parents: 1461
diff changeset
332 self._hint_sel_timeline(timeline_name)
1332
a0d3a4f8e99d Siwtch components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1331
diff changeset
333 pass
1456
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
334
1457
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
335 def _prepare_FSM_editor(self):
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
336 def FSM_editor_close():
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
337 self._fsm_editor_win.hide()
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
338 pass
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
339
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
340 def FSM_editor_destroy():
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
341 self._fsm_editor_win = None
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
342 pass
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
343
1458
59b90d7fcf57 Lock UI event handlers for FSM_window
Thinker K.F. Li <thinker@codemud.net>
parents: 1457
diff changeset
344 fsm_win = FSM_window.FSM_window(self._domview_ui,
59b90d7fcf57 Lock UI event handlers for FSM_window
Thinker K.F. Li <thinker@codemud.net>
parents: 1457
diff changeset
345 FSM_editor_close,
1457
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
346 FSM_editor_destroy)
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
347 self._fsm_editor_win = fsm_win
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
348
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
349 doc = pybInkscape.createSPDocument()
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
350 view_widget = pybInkscape.create_svg_view_widget(doc)
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
351 view_widget.show()
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
352
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
353 self._FSM_doc = doc
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
354 self._FSM_view_widget = view_widget
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
355
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
356 fsm_win.set_svg_view(view_widget)
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
357 pass
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
358
1514
fa4d0480d6cb Switch the component that FSM editor is working on
Thinker K.F. Li <thinker@codemud.net>
parents: 1462
diff changeset
359 def _show_FSM_for_comp(self, comp_name):
1456
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
360 if not self._fsm_editor_win:
1457
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
361 self._prepare_FSM_editor()
416a18409603 Show an empty document in SVG viewer widget
Thinker K.F. Li <thinker@codemud.net>
parents: 1456
diff changeset
362 fsm_win = self._fsm_editor_win
1456
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
363 else:
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
364 fsm_win = self._fsm_editor_win
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
365 pass
1514
fa4d0480d6cb Switch the component that FSM editor is working on
Thinker K.F. Li <thinker@codemud.net>
parents: 1462
diff changeset
366 fsm_win.switch_component(comp_name)
1456
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
367 fsm_win.show()
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
368 pass
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
369
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
370 def on_add_comp_clicked(self, *args):
1310
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
371 self._add_component()
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
372 self._drop_undo()
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
373 pass
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
374
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
375 def on_remove_comp_clicked(self, *args):
1310
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
376 self._rm_component()
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
377 self._drop_undo()
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
378 pass
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
379
1331
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
380 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
381 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
382 return
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
383
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
384 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
385 return
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 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
388 pass
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
389
1330
c2a693a27eb9 Double click to switch component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1323
diff changeset
390 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
391 self._switch_component()
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
392 self._drop_undo()
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
393 pass
1456
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
394
1331
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
395 ## \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
396 #
1309
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
397 def on_cellrenderer_comp_edited(self, renderer, path,
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
398 new_text, *args):
1331
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
399 model = self._components_model
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
400 itr = model.get_iter(path)
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
401
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
402 old_name = model.get_value(itr, 0)
1526
04b67119df8c Prevent users from changing name of main component and its timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1514
diff changeset
403 if old_name == 'main':
04b67119df8c Prevent users from changing name of main component and its timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1514
diff changeset
404 raise ValueError, 'can not change name of main component'
1331
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
405
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
406 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
407 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
408
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
409 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
410
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
411 self._drop_undo()
1331
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
412 pass
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
413
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
414 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
415 treeview = self._components_treeview
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
416 path, col = treeview.get_cursor()
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
417
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
418 model = self._components_model
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
419 itr = model.get_iter(path)
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
420 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
421
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
422 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
423 pass
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
424
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
425 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
426 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
427
3cbc1ab15541 Implement the function to create a link to a component.
Thinker K.F. Li <thinker@codemud.net>
parents: 1332
diff changeset
428 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
429 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
430 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
431
3cbc1ab15541 Implement the function to create a link to a component.
Thinker K.F. Li <thinker@codemud.net>
parents: 1332
diff changeset
432 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
433
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
434 self._drop_undo()
1331
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
435 pass
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
436
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
437 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
438 self._switch_component()
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
439 self._drop_undo()
1309
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
440 pass
1456
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
441
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
442 ## \brief User clicks "State Machine" on context menu for a component.
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
443 #
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
444 def on_edit_FSM_activate(self, *args):
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
445 comp_name = self._current_component()
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
446 self._show_FSM_for_comp(comp_name)
894a4bf35fe6 Start implement FSM editor window
Thinker K.F. Li <thinker@codemud.net>
parents: 1417
diff changeset
447 pass
1309
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
448
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
449 def on_add_timeline_clicked(self, *args):
1310
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
450 self._add_timeline()
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
451 self._drop_undo()
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
452 pass
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
453
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
454 def on_remove_timeline_clicked(self, *args):
1310
85d04ba11146 Support adding new components
Thinker K.F. Li <thinker@codemud.net>
parents: 1309
diff changeset
455 self._rm_timeline()
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
456 self._drop_undo()
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
457 pass
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
458
1331
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
459 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
460 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
461 return
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
462
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
463 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
464 return
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
465
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
466 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
467 pass
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
468
1330
c2a693a27eb9 Double click to switch component and timeline
Thinker K.F. Li <thinker@codemud.net>
parents: 1323
diff changeset
469 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
470 self._switch_timeline()
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
471 self._drop_undo()
1308
49775feefbcf Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents: 1305
diff changeset
472 pass
1309
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
473
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
474 def on_cellrenderer_timelines_edited(self, renderer, path,
f2b1b22f7cbc Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents: 1308
diff changeset
475 new_text, *args):
1526
04b67119df8c Prevent users from changing name of main component and its timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1514
diff changeset
476 comp_name = self._domview_ui.get_current_component()
04b67119df8c Prevent users from changing name of main component and its timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1514
diff changeset
477 if comp_name == 'main':
04b67119df8c Prevent users from changing name of main component and its timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1514
diff changeset
478 raise ValueError, \
04b67119df8c Prevent users from changing name of main component and its timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1514
diff changeset
479 'can not change name of timeline of main component'
04b67119df8c Prevent users from changing name of main component and its timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1514
diff changeset
480
1331
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
481 model = self._timelines_model
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
482 itr = model.get_iter(path)
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
483
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
484 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
485
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
486 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
487 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
488
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
489 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
490
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
491 self._drop_undo()
1331
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
492 pass
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
493
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
494 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
495 treeview = self._timelines_treeview
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
496 path, col = treeview.get_cursor()
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
497
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
498 model = self._timelines_model
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
499 itr = model.get_iter(path)
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
500 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
501
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
502 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
503 pass
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
504
5da64f67d00d Rename components and timelines with context menu
Thinker K.F. Li <thinker@codemud.net>
parents: 1330
diff changeset
505 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
506 self._switch_timeline()
1338
d0e6f350b3fd Clear change log to prevent from undo/redo.
Thinker K.F. Li <thinker@codemud.net>
parents: 1336
diff changeset
507 self._drop_undo()
1336
0b5ee9c90af7 Update components and timelines list for async changes on DOM
Thinker K.F. Li <thinker@codemud.net>
parents: 1335
diff changeset
508 pass
1303
cf2691a18a7a Add component dock
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
509 pass
1312
89e640789750 Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
510
89e640789750 Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
511 ## \brief Component dock
89e640789750 Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
512 #
89e640789750 Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
513 # 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
514 #
89e640789750 Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
515 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
516 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
517 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
518
1313
cc557ce8e9fa Move signal connecting actions to comp_dock_ui
Thinker K.F. Li <thinker@codemud.net>
parents: 1312
diff changeset
519 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
520 pass
1336
0b5ee9c90af7 Update components and timelines list for async changes on DOM
Thinker K.F. Li <thinker@codemud.net>
parents: 1335
diff changeset
521
0b5ee9c90af7 Update components and timelines list for async changes on DOM
Thinker K.F. Li <thinker@codemud.net>
parents: 1335
diff changeset
522 def install_dock(self, desktop):
0b5ee9c90af7 Update components and timelines list for async changes on DOM
Thinker K.F. Li <thinker@codemud.net>
parents: 1335
diff changeset
523 comp_dock_base.install_dock(self, desktop)
0b5ee9c90af7 Update components and timelines list for async changes on DOM
Thinker K.F. Li <thinker@codemud.net>
parents: 1335
diff changeset
524 comp_dock_ui.install_dock(self, desktop)
0b5ee9c90af7 Update components and timelines list for async changes on DOM
Thinker K.F. Li <thinker@codemud.net>
parents: 1335
diff changeset
525 pass
1312
89e640789750 Separate envet handlers from base functions of comp_doc
Thinker K.F. Li <thinker@codemud.net>
parents: 1311
diff changeset
526 pass