Mercurial > MadButterfly
comparison pyink/comp_dock.py @ 1310:85d04ba11146
Support adding new components
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Thu, 20 Jan 2011 12:44:37 +0800 |
parents | f2b1b22f7cbc |
children | e6bb9d00341f |
comparison
equal
deleted
inserted
replaced
1309:f2b1b22f7cbc | 1310:85d04ba11146 |
---|---|
74 | 74 |
75 for timeline_name in self._domview_ui.all_timeline_names(): | 75 for timeline_name in self._domview_ui.all_timeline_names(): |
76 timelines_model.append((timeline_name, True)) | 76 timelines_model.append((timeline_name, True)) |
77 pass | 77 pass |
78 pass | 78 pass |
79 | |
80 def _current_component(self): | |
81 treeview = self._components_treeview | |
82 path, col = treeview.get_cursor() | |
83 | |
84 model = self._components_model | |
85 itr = model.get_iter(path) | |
86 name = model.get_value(itr, 0) | |
87 return name | |
88 | |
89 def _current_timeline(self): | |
90 treeview = self._timelines_treeview | |
91 path, col = treeview.get_cursor() | |
92 | |
93 model = self._timelines_model | |
94 itr = model.get_iter(path) | |
95 name = model.get_value(itr, 0) | |
96 return name | |
97 | |
98 def _add_component(self): | |
99 def _make_component_name(): | |
100 comp_name = 'New Component' | |
101 idx = 0 | |
102 while comp_name in self._domview_ui.all_comp_names(): | |
103 comp_name = 'New Component %d' % (idx) | |
104 idx = idx + 1 | |
105 pass | |
106 return comp_name | |
107 | |
108 comp_name = _make_component_name() | |
109 print comp_name | |
110 self._domview_ui.add_component(comp_name) | |
111 pass | |
112 | |
113 def _rm_component(self): | |
114 if self._current_component() == 'main': | |
115 return | |
116 | |
117 treeview = self._components_treeview | |
118 path, col = treeview.get_cursor() | |
119 | |
120 model = self._components_model | |
121 itr = model.get_iter(path) | |
122 comp_name = model.get_value(itr, 0) | |
123 print comp_name | |
124 | |
125 self._domview_ui.rm_component(comp_name) | |
126 pass | |
127 | |
128 def _add_timeline(self): | |
129 def _make_timeline_name(): | |
130 tl_name = 'New Timeline' | |
131 idx = 0 | |
132 while tl_name in self._domview_ui.all_timeline_names(): | |
133 tl_name = 'New Timeline %d' % (idx) | |
134 idx = idx + 1 | |
135 pass | |
136 return tl_name | |
137 | |
138 if self._current_component() == 'main': | |
139 return | |
140 | |
141 tl_name = _make_timeline_name() | |
142 print tl_name | |
143 self._domview_ui.add_timeline(tl_name) | |
144 pass | |
145 | |
146 def _rm_timeline(self): | |
147 if self._current_component() == 'main': | |
148 return | |
149 | |
150 treeview = self._timelines_treeview | |
151 path, col = treeview.get_cursor() | |
152 | |
153 model = self._timelines_model | |
154 itr = model.get_iter(path) | |
155 tl_name = model.get_value(itr, col) | |
156 print tl_name | |
157 | |
158 self._domview_ui.rm_timeline(tl_name) | |
159 pass | |
79 | 160 |
80 def on_add_comp_clicked(self, *args): | 161 def on_add_comp_clicked(self, *args): |
81 print args | 162 self._add_component() |
82 pass | 163 pass |
83 | 164 |
84 def on_remove_comp_clicked(self, *args): | 165 def on_remove_comp_clicked(self, *args): |
85 print args | 166 self._rm_component() |
86 pass | 167 pass |
87 | 168 |
88 def on_treeview_components_cursor_changed(self, *args): | 169 def on_treeview_components_cursor_changed(self, *args): |
89 print args | 170 print args |
90 pass | 171 pass |
93 new_text, *args): | 174 new_text, *args): |
94 print '%s - %s' % (path, new_text) | 175 print '%s - %s' % (path, new_text) |
95 pass | 176 pass |
96 | 177 |
97 def on_add_timeline_clicked(self, *args): | 178 def on_add_timeline_clicked(self, *args): |
98 print args | 179 self._add_timeline() |
99 pass | 180 pass |
100 | 181 |
101 def on_remove_timeline_clicked(self, *args): | 182 def on_remove_timeline_clicked(self, *args): |
102 print args | 183 self._rm_timeline() |
103 pass | 184 pass |
104 | 185 |
105 def on_treeview_timelines_cursor_changed(self, *args): | 186 def on_treeview_timelines_cursor_changed(self, *args): |
106 print args | 187 print args |
107 pass | 188 pass |