comparison pyink/comp_dock.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 c2a693a27eb9
children a0d3a4f8e99d
comparison
equal deleted inserted replaced
1330:c2a693a27eb9 1331:5da64f67d00d
20 builder.add_from_file(fname) 20 builder.add_from_file(fname)
21 dock_top = builder.get_object('component_dock_top') 21 dock_top = builder.get_object('component_dock_top')
22 components_model = builder.get_object('components_model') 22 components_model = builder.get_object('components_model')
23 timelines_model = builder.get_object('timelines_model') 23 timelines_model = builder.get_object('timelines_model')
24 components_treeview = builder.get_object('treeview_components') 24 components_treeview = builder.get_object('treeview_components')
25 components_menu = builder.get_object('components_menu')
25 timelines_treeview = builder.get_object('treeview_timelines') 26 timelines_treeview = builder.get_object('treeview_timelines')
27 timelines_menu = builder.get_object('timelines_menu')
26 28
27 dock_top_parent = dock_top.get_parent() 29 dock_top_parent = dock_top.get_parent()
28 dock_top_parent.remove(dock_top) 30 dock_top_parent.remove(dock_top)
29 31
30 self._domview_ui = domview_ui 32 self._domview_ui = domview_ui
34 self._dock_item = None 36 self._dock_item = None
35 37
36 self._components_model = components_model 38 self._components_model = components_model
37 self._timelines_model = timelines_model 39 self._timelines_model = timelines_model
38 self._components_treeview = components_treeview 40 self._components_treeview = components_treeview
41 self._components_menu = components_menu
39 self._timelines_treeview = timelines_treeview 42 self._timelines_treeview = timelines_treeview
43 self._timelines_menu = timelines_menu
40 44
41 self._cur_component = -1 45 self._cur_component = -1
42 self._cur_timeline = -1 46 self._cur_timeline = -1
43 pass 47 pass
44 48
248 252
249 def on_remove_comp_clicked(self, *args): 253 def on_remove_comp_clicked(self, *args):
250 self._rm_component() 254 self._rm_component()
251 pass 255 pass
252 256
257 def on_treeview_components_button_press_event(self, widget, event, *args):
258 if event.type != gtk.gdk.BUTTON_PRESS:
259 return
260
261 if event.button != 3: # not right button
262 return
263
264 self._components_menu.popup(None, None, None, event.button, event.time)
265 pass
266
253 def on_treeview_components_row_activated(self, *args): 267 def on_treeview_components_row_activated(self, *args):
254 domview_ui = self._domview_ui 268 domview_ui = self._domview_ui
255 269
256 comp_name = self._current_component() 270 comp_name = self._current_component()
257 domview_ui.switch_component(comp_name) 271 domview_ui.switch_component(comp_name)
259 group = domview_ui.get_layer_group(0) 273 group = domview_ui.get_layer_group(0)
260 desktop = self._desktop # from comp_dock_base 274 desktop = self._desktop # from comp_dock_base
261 desktop.setCurrentLayer(group.spitem) 275 desktop.setCurrentLayer(group.spitem)
262 pass 276 pass
263 277
278 ## \brief Handle of changing component name.
279 #
264 def on_cellrenderer_comp_edited(self, renderer, path, 280 def on_cellrenderer_comp_edited(self, renderer, path,
265 new_text, *args): 281 new_text, *args):
266 print '%s - %s' % (path, new_text) 282 model = self._components_model
283 itr = model.get_iter(path)
284
285 old_name = model.get_value(itr, 0)
286
287 model.set_value(itr, 0, new_text)
288 model.set_value(itr, 1, False)
289
290 self._domview_ui.rename_component(old_name, new_text)
291 pass
292
293 def on_rename_component_activate(self, *args):
294 treeview = self._components_treeview
295 path, col = treeview.get_cursor()
296
297 model = self._components_model
298 itr = model.get_iter(path)
299 model.set_value(itr, 1, True)
300
301 treeview.set_cursor(path, col, True)
302 pass
303
304 def on_link_component_activate(self, *args):
305 pass
306
307 def on_switch_component_activate(self, *args):
267 pass 308 pass
268 309
269 def on_add_timeline_clicked(self, *args): 310 def on_add_timeline_clicked(self, *args):
270 self._add_timeline() 311 self._add_timeline()
271 pass 312 pass
272 313
273 def on_remove_timeline_clicked(self, *args): 314 def on_remove_timeline_clicked(self, *args):
274 self._rm_timeline() 315 self._rm_timeline()
275 pass 316 pass
276 317
318 def on_treeview_timelines_button_press_event(self, widget, event, *args):
319 if event.type != gtk.gdk.BUTTON_PRESS:
320 return
321
322 if event.button != 3: # not right button
323 return
324
325 self._timelines_menu.popup(None, None, None, event.button, event.time)
326 pass
327
277 def on_treeview_timelines_row_activated(self, *args): 328 def on_treeview_timelines_row_activated(self, *args):
278 domview_ui = self._domview_ui 329 domview_ui = self._domview_ui
279 330
280 timeline_name = self._current_timeline() 331 timeline_name = self._current_timeline()
281 domview_ui.switch_timeline(timeline_name) 332 domview_ui.switch_timeline(timeline_name)
282 pass 333 pass
283 334
284 def on_cellrenderer_timelines_edited(self, renderer, path, 335 def on_cellrenderer_timelines_edited(self, renderer, path,
285 new_text, *args): 336 new_text, *args):
286 print '%s - %s' % (path, new_text) 337 model = self._timelines_model
338 itr = model.get_iter(path)
339
340 old_name = model.get_value(itr, 0)
341
342 model.set_value(itr, 0, new_text)
343 model.set_value(itr, 1, False)
344
345 self._domview_ui.rename_timeline(old_name, new_text)
346 pass
347
348 def on_rename_timeline_activate(self, *args):
349 treeview = self._timelines_treeview
350 path, col = treeview.get_cursor()
351
352 model = self._timelines_model
353 itr = model.get_iter(path)
354 model.set_value(itr, 1, True)
355
356 treeview.set_cursor(path, col, True)
357 pass
358
359 def on_link_timeline_activate(self, *args):
360 pass
361
362 def on_switch_timeline_activate(self, *args):
287 pass 363 pass
288 pass 364 pass
289 365
290 ## \brief Component dock 366 ## \brief Component dock
291 # 367 #