Mercurial > MadButterfly
annotate pyink/comp_dock.py @ 1309:f2b1b22f7cbc
Make comp_dock editable
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Thu, 20 Jan 2011 10:54:27 +0800 |
parents | 49775feefbcf |
children | 85d04ba11146 |
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 # | |
1304
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
8 class comp_dock(object): |
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
9 __metaclass__ = data_monitor.data_monitor |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
10 __data_monitor_prefix__ = 'on_' |
1304
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
11 |
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
12 def __init__(self, domview_ui, fname=None): |
1303 | 13 super(comp_dock, self).__init__() |
14 | |
15 if not fname: | |
16 dirname = os.path.dirname(__file__) | |
17 fname = os.path.join(dirname, 'component_dock.glade') | |
18 pass | |
19 | |
20 builder = gtk.Builder() | |
21 builder.add_from_file(fname) | |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
22 builder.connect_signals(self) |
1303 | 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') |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
27 timelines_treeview = builder.get_object('treeview_timelines') |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
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 |
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
33 self._locker = domview_ui |
1303 | 34 self._builder = builder |
35 self._dock_top = dock_top | |
36 self._desktop = None | |
37 self._dock_item = None | |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
38 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
39 self._components_model = components_model |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
40 self._timelines_model = timelines_model |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
41 self._components_treeview = components_treeview |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
42 self._timelines_treeview = timelines_treeview |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
43 |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
44 self._cur_component = -1 |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
45 self._cur_timeline = -1 |
1303 | 46 pass |
47 | |
48 def install_dock(self, desktop): | |
49 self._desktop = desktop | |
50 | |
51 dock = desktop.getDock() | |
52 item = dock.new_item('component_dock', | |
53 'Component and timeline manager', | |
54 'feBlend-icon', dock.ITEM_ST_DOCKED_STATE) | |
55 item_vbox = item.get_vbox() | |
56 self._dock_item = item | |
57 | |
1304
94e6594dea59
Make comp_dock being instantiated by domview_ui
Thinker K.F. Li <thinker@codemud.net>
parents:
1303
diff
changeset
|
58 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
|
59 self._dock_top.show() |
1303 | 60 pass |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
61 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
62 ## \brief Refresh content of component list and timeline list. |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
63 # |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
64 def refresh(self): |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
65 components_model = self._components_model |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
66 components_model.clear() |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
67 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
68 for comp_name in self._domview_ui.all_comp_names(): |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
69 components_model.append((comp_name, True)) |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
70 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
71 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
72 timelines_model = self._timelines_model |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
73 timelines_model.clear() |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
74 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
75 for timeline_name in self._domview_ui.all_timeline_names(): |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
76 timelines_model.append((timeline_name, True)) |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
77 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
78 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
79 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
80 def on_add_comp_clicked(self, *args): |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
81 print args |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
82 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
83 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
84 def on_remove_comp_clicked(self, *args): |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
85 print args |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
86 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
87 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
88 def on_treeview_components_cursor_changed(self, *args): |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
89 print args |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
90 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
91 |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
92 def on_cellrenderer_comp_edited(self, renderer, path, |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
93 new_text, *args): |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
94 print '%s - %s' % (path, new_text) |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
95 pass |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
96 |
1308
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
97 def on_add_timeline_clicked(self, *args): |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
98 print args |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
99 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
100 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
101 def on_remove_timeline_clicked(self, *args): |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
102 print args |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
103 pass |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
104 |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
105 def on_treeview_timelines_cursor_changed(self, *args): |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
106 print args |
49775feefbcf
Show components and timelines in comp_dock
Thinker K.F. Li <thinker@codemud.net>
parents:
1305
diff
changeset
|
107 pass |
1309
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
108 |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
109 def on_cellrenderer_timelines_edited(self, renderer, path, |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
110 new_text, *args): |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
111 print '%s - %s' % (path, new_text) |
f2b1b22f7cbc
Make comp_dock editable
Thinker K.F. Li <thinker@codemud.net>
parents:
1308
diff
changeset
|
112 pass |
1303 | 113 pass |