Mercurial > MadButterfly
comparison pyink/pyink.py @ 1323:ffbbd3aa218d
Make a component from a group.
User can translate a group into a component from context menu.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sun, 30 Jan 2011 19:15:17 +0800 |
parents | 6586cd10c92f |
children | 0a2034f490e5 |
comparison
equal
deleted
inserted
replaced
1322:7f25abbc1b61 | 1323:ffbbd3aa218d |
---|---|
11 | 11 |
12 import pybInkscape | 12 import pybInkscape |
13 import pygtk | 13 import pygtk |
14 import gtk | 14 import gtk |
15 from MBScene import * | 15 from MBScene import * |
16 global ink_inited | 16 |
17 ink_inited=0 | 17 all_desktop_mbscenes = {} |
18 def start_desktop(inkscape,ptr): | 18 |
19 global ink_inited | 19 def _init_mbscene(inkscape, ptr): |
20 if ink_inited == 1: | 20 global all_desktop_mbscenes |
21 desktop = pybInkscape.GPointer_2_PYSPDesktop(ptr) | 21 |
22 top = desktop.getToplevel() | 22 desktop = pybInkscape.GPointer_2_PYSPDesktop(ptr) |
23 #dock = desktop.getDock() | 23 |
24 #item = dock.new_item("scene", "scene", "feBlend-icon", dock.ITEM_ST_DOCKED_STATE) | 24 top = desktop.getToplevel() |
25 scene = MBScene(desktop,top) | 25 mbscene = MBScene(desktop,top) |
26 scene.show() | 26 mbscene.show() |
27 | |
28 all_desktop_mbscenes[desktop] = mbscene | |
29 | |
30 print hash(desktop) | |
31 pass | |
32 | |
33 | |
34 ## \brief Handler for events of activating a desktop. | |
35 # | |
36 def act_desktop(inkscape, ptr): | |
37 # Get Python wrapper of SPDesktop passed by ptr. | |
38 desktop = pybInkscape.GPointer_2_PYSPDesktop(ptr) | |
39 | |
40 top = desktop.getToplevel() | |
41 if not top: # has not top window. | |
27 return | 42 return |
28 | |
29 | 43 |
30 ink_inited = 1 | 44 if desktop in all_desktop_mbscenes: |
45 return # already initialized | |
46 | |
47 _init_mbscene(inkscape, ptr) | |
48 pass | |
31 | 49 |
32 | 50 |
33 def pyink_start(): | 51 def pyink_start(): |
34 print 'pyink_start()' | 52 pybInkscape.inkscape.connect('activate_desktop', act_desktop) |
35 pybInkscape.inkscape.connect('activate_desktop', start_desktop) | |
36 pass | 53 pass |
54 | |
55 | |
56 def pyink_context_menu(view, item, menu_factory): | |
57 print hash(view) | |
58 if view in all_desktop_mbscenes: | |
59 mbscene = all_desktop_mbscenes[view] | |
60 mbscene.context_menu(item, menu_factory) | |
61 pass | |
62 pass |