view pyink/pyink.py @ 1324:740b3239030e

Clear dup group before running animation. User may change content of groups. TweenObject would not aware the changes if we don't clear the dup group before running animation.
author Thinker K.F. Li <thinker@codemud.net>
date Sun, 30 Jan 2011 20:03:21 +0800
parents ffbbd3aa218d
children 0a2034f490e5
line wrap: on
line source

import os

try:
    if os.environ['PYINK_DBG_ENABLE'] == 'yes':
        import pdb
        pdb.set_trace()
        pass
    pass
except:
    pass

import pybInkscape
import pygtk
import gtk
from MBScene import *

all_desktop_mbscenes = {}

def _init_mbscene(inkscape, ptr):
    global all_desktop_mbscenes
    
    desktop = pybInkscape.GPointer_2_PYSPDesktop(ptr)

    top = desktop.getToplevel()
    mbscene = MBScene(desktop,top)
    mbscene.show()

    all_desktop_mbscenes[desktop] = mbscene

    print hash(desktop)
    pass


## \brief Handler for events of activating a desktop.
#
def act_desktop(inkscape, ptr):
    # Get Python wrapper of SPDesktop passed by ptr.
    desktop = pybInkscape.GPointer_2_PYSPDesktop(ptr)
    
    top = desktop.getToplevel()
    if not top:                 # has not top window.
        return

    if desktop in all_desktop_mbscenes:
        return                  # already initialized
    
    _init_mbscene(inkscape, ptr)
    pass


def pyink_start():
    pybInkscape.inkscape.connect('activate_desktop', act_desktop)
    pass


def pyink_context_menu(view, item, menu_factory):
    print hash(view)
    if view in all_desktop_mbscenes:
        mbscene = all_desktop_mbscenes[view]
        mbscene.context_menu(item, menu_factory)
        pass
    pass