Mercurial > MadButterfly
comparison pyink/domview.py @ 1331:5da64f67d00d
Rename components and timelines with context menu
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 31 Jan 2011 16:26:21 +0800 |
parents | 407f321f0d7c |
children | 0b5ee9c90af7 |
comparison
equal
deleted
inserted
replaced
1330:c2a693a27eb9 | 1331:5da64f67d00d |
---|---|
34 pass | 34 pass |
35 | 35 |
36 def name(self): | 36 def name(self): |
37 name = self.scenes_node.getAttribute('name') | 37 name = self.scenes_node.getAttribute('name') |
38 return name | 38 return name |
39 | |
40 def rename(self, new_name): | |
41 scenes_node = self.scenes_node | |
42 scenes_node.setAttribute('name', new_name) | |
43 pass | |
39 pass | 44 pass |
40 | 45 |
41 | 46 |
42 class Component(object): | 47 class Component(object): |
43 # | 48 # |
151 | 156 |
152 del self.timelines[i] | 157 del self.timelines[i] |
153 return | 158 return |
154 pass | 159 pass |
155 raise ValueError, 'try to remove a non-existed timeline - %s' % (name) | 160 raise ValueError, 'try to remove a non-existed timeline - %s' % (name) |
161 | |
162 def rename_timeline(self, timeline_name, new_name): | |
163 for i, tl in enumerate(self.timelines): | |
164 if tl.name() == timeline_name: | |
165 tl.rename(new_name) | |
166 return | |
167 pass | |
168 raise ValueError, 'try to remove a non-existed timeline - %s' % (name) | |
169 | |
170 def rename(self, new_name): | |
171 self.node.setAttribute('name', new_name) | |
172 pass | |
156 pass | 173 pass |
157 | 174 |
158 | 175 |
159 ## \brief A mix-in for class domview for management of components. | 176 ## \brief A mix-in for class domview for management of components. |
160 # | 177 # |
442 self._components.remove(comp) | 459 self._components.remove(comp) |
443 self._comp_names.remove(comp_name) | 460 self._comp_names.remove(comp_name) |
444 self._components_node.removeChild(comp_node) | 461 self._components_node.removeChild(comp_node) |
445 self._components_group.removeChild(comp_group) | 462 self._components_group.removeChild(comp_group) |
446 pass | 463 pass |
464 | |
465 def rename_component(self, comp_name, new_name): | |
466 comp = self._get_component(comp_name) | |
467 comp.rename(new_name) | |
468 pass | |
447 | 469 |
448 def get_component_group(self, comp_name): | 470 def get_component_group(self, comp_name): |
449 comp = self._get_component(comp_name) | 471 comp = self._get_component(comp_name) |
450 | 472 |
451 comp_name = comp.name() | 473 comp_name = comp.name() |
473 self._cur_comp.add_timeline(timeline_name) | 495 self._cur_comp.add_timeline(timeline_name) |
474 pass | 496 pass |
475 | 497 |
476 def rm_timeline(self, timeline_name): | 498 def rm_timeline(self, timeline_name): |
477 self._cur_comp.rm_timeline(timeline_name) | 499 self._cur_comp.rm_timeline(timeline_name) |
500 pass | |
501 | |
502 def rename_timeline_of_component(self, timeline_name, new_name, comp_name): | |
503 comp = self._get_component(comp_name) | |
504 comp.rename_timeline(timeline_name, new_name) | |
505 pass | |
506 | |
507 def rename_timeline(self, timeline_name, new_name): | |
508 comp_name = self._cur_comp.name() | |
509 self.rename_timeline_of_component(timeline_name, new_name, comp_name) | |
478 pass | 510 pass |
479 | 511 |
480 def all_timeline_names(self): | 512 def all_timeline_names(self): |
481 r = self._cur_comp.all_timeline_names() | 513 r = self._cur_comp.all_timeline_names() |
482 return r | 514 return r |