示例#1
0
 def __openfile_callback(self):
     # Callback used by "browse" button in open url
     import windowinterface
     text = self.__text.gettext()
     dir, file = ',', ''
     if text:
         import urlparse
         utype, host, path, params, query, fragment = urlparse.urlparse(
             text)
         if (not utype or utype == 'file') and \
            (not host or host == 'localhost') and \
            path:
             import MMurl, os
             file = MMurl.url2pathname(path)
             dir, file = os.path.split(file)
     f = windowinterface.getmainwnd()
     filetypes = [
         '/All presentations', 'application/x-grins-project',
         'application/smil'
     ]
     windowinterface.FileDialog('Open file',
                                dir,
                                filetypes,
                                file,
                                self.__filecvt,
                                None,
                                1,
                                parent=f)
示例#2
0
 def __openfile_callback(self):
     import windowinterface
     windowinterface.setwaiting()
     # provide a default directory and file name for the
     # browser based on the current selection (if any)
     dir = '.'
     file = ''
     url = self.__text.gettext() or self.__lasturl
     if url:
         import MMurl
         type, rest = MMurl.splittype(url)
         if not type or type == 'file':
             import os
             dir, file = os.path.split(
                 MMurl.url2pathname(MMurl.splithost(rest)[1]))
     filetypes = [
         '/SMIL presentation', 'application/x-grins-project',
         'application/smil'
     ]
     windowinterface.FileDialog('Open file',
                                dir,
                                filetypes,
                                file,
                                self.__filecvt,
                                None,
                                1,
                                parent=self.__owindow)
示例#3
0
 def openfile_callback(self):
     """Callback for OPENFILE menu command"""
     import windowinterface
     if not self.canopennewtop():
         return
     filetypes = ['/SMIL presentation', 'application/x-grins-project', 'application/smil']
     windowinterface.FileDialog('', '', filetypes, '',
                                self.__openfile_done, None, 1)
示例#4
0
文件: grins.py 项目: scooter23/grins
 def skin_callback(self):
     import windowinterface
     windowinterface.FileDialog('Open Components File',
                                '.', ['text/x-grins-skin'],
                                '',
                                self.__skin_done,
                                None,
                                1,
                                parent=windowinterface.getmainwnd())
示例#5
0
 def openfile_callback(self):
     """Callback for OPENFILE menu command"""
     import windowinterface
     if features.compatibility == Boston:
         filetypes = ['/SMIL presentation', 'application/smil', 'application/x-grins-project']
     else:
         filetypes = ['/SMIL presentation', 'application/x-grins-project', 'application/smil']
     if not features.lightweight:
         filetypes.append('application/x-grins-cmif')
     windowinterface.FileDialog('', '', filetypes, '',
                                self.__openfile_done, None, 1)
示例#6
0
 def __init__(self, node):
     import ChannelMime, string
     self.node = node
     chtype = node.GetChannelType()
     types = ChannelMime.ChannelMime.get(chtype)
     if types:
         types = ['/%s files' % string.capitalize(chtype)] + types
     else:
         types = '*'
     windowinterface.FileDialog(
         'This is an internal node. Convert to external?', os.curdir, types,
         _inventname(node.GetChannelName()), self.ok, None)
示例#7
0
 def read_it_with_skin(self):
     if settings.get('askskin'):
         # default profile is SMIL 2.0 Language Profile
         settings.switch_profile(settings.SMIL_20_MODULES)
         windowinterface.FileDialog('Open Components File',
                                    '.', ['text/x-grins-skin'],
                                    '',
                                    self.__skin_done,
                                    self.__skin_done,
                                    1,
                                    parent=windowinterface.getmainwnd())
     else:
         self.read_it()
示例#8
0
    def openfile_callback(self):
        # Callback for OPENFILE menu command
        import windowinterface
        f=windowinterface.getmainwnd()
        if features.compatibility == Boston:
            filetypes = ['/All presentations', 'application/smil', 'application/x-grins-project', 'application/x-grins-binary-project']
        else:
            filetypes = ['/All presentations', 'application/x-grins-project', 'application/smil', 'application/x-grins-binary-project']
##         import features
##         if not features.lightweight:
##             filetypes.append('application/x-grins-cmif')
        windowinterface.FileDialog('Open Document', '.', filetypes, '',
                                   self.__openfile_done, None, 1,
                                   parent = f)
示例#9
0
 def skin_callback(self):
     import settings
     import windowinterface
     oldskin = settings.get('skin')
     windowinterface.FileDialog('Open skin file',
                                '.', ['text/x-grins-skin'],
                                '',
                                self.__skin_done,
                                None,
                                1,
                                parent=windowinterface.getmainwnd())
     newskin = settings.get('skin')
     if newskin and oldskin != newskin:
         if self.tops:
             url = self.tops[0].url
         else:
             url = EMPTYDOC
         self.openURL_callback(url, askskin=0)
示例#10
0
 def openfile_callback(self):
     # Callback for OPENFILE menu command
     if not self.canopennewtop():
         return
     import windowinterface
     f = windowinterface.getmainwnd()
     filetypes = [
         '/All presentations', 'application/x-grins-project',
         'application/smil'
     ]
     windowinterface.FileDialog('Open Document',
                                'Desktop',
                                filetypes,
                                '',
                                self.__openfile_done,
                                None,
                                1,
                                parent=f)
示例#11
0
    def __openfile_callback(self):
        import windowinterface
        windowinterface.setwaiting()
        # provide a default directory and file name for the
        # browser based on the current selection (if any)
        dir = '.'
        file = ''
        url = self.__text.gettext() or self.__lasturl
        if url:
            import MMurl
            type, rest = MMurl.splittype(url)
            if not type or type == 'file':
                import os
                dir, file = os.path.split(
                    MMurl.url2pathname(MMurl.splithost(rest)[1]))
        import features
        from compatibility import Boston
        if features.compatibility == Boston:
            filetypes = [
                '/SMIL presentation', 'application/smil',
                'application/x-grins-project'
            ]
        else:
            filetypes = [
                '/SMIL presentation', 'application/x-grins-project',
                'application/smil'
            ]
##         import features
##         if not features.lightweight:
##             filetypes.append('application/x-grins-cmif')
        windowinterface.FileDialog('Open file',
                                   dir,
                                   filetypes,
                                   file,
                                   self.__filecvt,
                                   None,
                                   1,
                                   parent=self.__owindow)
示例#12
0
 def cb_open(self):
     import windowinterface
     windowinterface.FileDialog("Select file containing license key", "",
                                "", "", self.cb_open_ok, None, 1)
示例#13
0
def convertrp(node, errorfunc = None):
    # Convert a seq node into a RealPix node.  The seq's children
    # must all be images, playing to the same region, the images
    # must not have an effective fill value "transition" (other
    # values are ok), the images may only have zero or one begin
    # syncarc which specifies a simple offset, and only zero or
    # one end syncarc which specifies a simple offset.
    ctx = node.GetContext()
    hlinks = ctx.hyperlinks
    if node.GetType() != 'seq':
        if errorfunc is not None: errorfunc('not a seq node')
        return
    import realnode
    rp = realnode.DummyRP()
    rp.tags = []                    # must make new copy
    start = 0
    rp.duration = 0
    region = None
    bgcolor = None
    fill = None
    for c in node.GetChildren():
        # first some checks
        ctype = c.GetType()
        if ctype not in ('ext', 'brush'):
            if errorfunc is not None: errorfunc('child not an external node')
            return
        if region is None:
            region = c.GetChannel()
            rp.width, rp.height = region.getPxGeom()[2:]
            if region.get('transparent', 1):
                bgcolor = (0, 0, 0)
            else:
                bgcolor = region.get('bgcolor')
                if bgcolor is None:
                    bgcolor = (0, 0, 0)
        elif c.GetChannel() != region:
            if errorfunc is not None: errorfunc('different region')
            return
        tagdict = {}
        rp.tags.append(tagdict)
        # set the start time
        beginlist = c.GetAttrDef('beginlist', [])
        if beginlist:
            if len(beginlist) > 1:
                if errorfunc is not None: errorfunc('too many begin values')
                return
            if beginlist[0].srcnode != 'syncbase':
                if errorfunc is not None: errorfunc('begin not a syncbase value')
            start = start + beginlist[0].delay
        if fill == 'freeze':
            # need to update start of out transition
            rp.tags[-2]['start'] = start - rp.tags[-2]['tduration']
            start = rp.tags[-2]['tduration']
        tagdict['start'] = start
        rp.duration = rp.duration + start
        # figure out syncbase for next child
        start = 0
        endlist = c.GetAttrDef('endlist', [])
        if endlist:
            if len(endlist) > 1:
                if errorfunc is not None: errorfunc('too many end values')
                return
            if endlist[0].srcnode != 'syncbase':
                if errorfunc is not None: errorfunc('end not a syncbase value')
            start = endlist[0].delay
        dur = c.GetAttrDef('duration', None)
        if dur is not None:
            if not endlist or dur < start:
                start = dur

        if ctype == 'ext':
            # set file
            file = c.GetAttrDef('file', None)
            if not file:
                if errorfunc is not None: errorfunc('no file specified on image')
                return
            tagdict['file'] = file
        else:
            fgcolor = c.GetAttrDef('fgcolor', (0,0,0))

        # figure out the transition
        transIn = c.GetAttrDef('transIn', [])
        if transIn:
            for tr in transIn:
                trdict = ctx.transitions.get(tr)
                trtype = trdict.get('trtype', 'fade')
                if (ctype == 'brush' and trtype == 'fade') or \
                   (ctype != 'brush' and trtype in ('fade', 'barWipe', 'pushWipe')):
                    break
            else:
                trdict = None
        if not transIn or trdict is None:
            # no transition
            if ctype == 'ext':
                tagdict['tag'] = 'fadein'
                tagdict['tduration'] = 0
            else:
                tagdict['tag'] = 'fill'
                tagdict['color'] = fgcolor
        else:
            if trdict.get('startProgress', 0.0) != 0 or \
               trdict.get('endProgress', 1.0) != 1 or \
               trdict.get('horzRepeat', 1) != 1 or \
               trdict.get('vertRepeat', 1) != 1 or \
               trdict.get('borderWidth', 0) != 0:
                if errorfunc is not None: errorfunc('translation of transition looses information')
            tagdict['tduration'] = trdict.get('dur', 1)
            trtype = tagdict.get('trtype', 'fade')
            if ctype == 'brush':
                tagdict['tag'] = 'fadeout'
                tagdict['color'] = fgcolor
            elif trtype == 'barWipe':
                tagdict['tag'] = 'wipe'
                tagdict['wipetype'] = 'normal'
                if trdict.get('subtype', 'leftToRight') == 'leftToRight':
                    if trdict.get('direction', 'forward') == 'forward':
                        tagdict['direction'] = 'right'
                    else:
                        # direction="reverse"
                        tagdict['direction'] = 'left'
                else:
                    # subtype="topToBottom"
                    if trdict.get('direction', 'forward') == 'forward':
                        tagdict['direction'] = 'down'
                    else:
                        # direction="reverse"
                        tagdict['direction'] = 'up'
            elif trtype == 'pushWipe':
                tagdict['tag'] = 'wipe'
                tagdict['wipetype'] = 'push'
                subtype = trdict.get('subtype', 'fromLeft')
                if subtype == 'fromLeft':
                    tagdict['direction'] = 'right'
                elif subtype == 'fromRight':
                    tagdict['direction'] = 'left'
                elif subtype == 'fromBottom':
                    tagdict['direction'] = 'up'
                else:
                    # subtype="fromTop"
                    tagdict['direction'] = 'down'
            elif trtype == 'fade':
                tagdict['tag'] = 'fadein'
            else:
                if errorfunc is not None: errorfunc('untranslatable transition')
                tagdict['tag'] = 'fadein'
                tagdict['tduration'] = 0

        subRegGeom, mediaGeom = c.getPxGeomMedia()
        effSubRegGeom = _intersect((0, 0, rp.width, rp.height), subRegGeom)
        effMediaGeom = _intersect(effSubRegGeom, mediaGeom)
        tagdict['displayfull'] = 0
        tagdict['subregionxy'] = effMediaGeom[:2]
        tagdict['subregionwh'] = effMediaGeom[2:]
        if effMediaGeom == mediaGeom:
            tagdict['fullimage'] = 1
        else:
            width, height = apply(c.GetDefaultMediaSize, mediaGeom[2:])
            tagdict['fullimage'] = 0
            tagdict['imgcropxy'] = int(width * effMediaGeom[0] / float(mediaGeom[2]) + .5), int(height * effMediaGeom[1] / float(mediaGeom[3]) + .5)
            tagdict['imgcropwh'] = int(width * effMediaGeom[2] / float(mediaGeom[2]) + .5), int(height * effMediaGeom[3] / float(mediaGeom[3]) + .5)
        tagdict['aspect'] = 0
        fill = c.GetFill()
        if fill == 'transition':
            fill = 'remove'
            if errorfunc is not None: errorfunc('fill="transition" replaced by fill="remove"')
        if fill != 'hold':
            tagdict = {}
            rp.tags.append(tagdict)
            transOut = c.GetAttrDef('transIn', [])
            if transOut:
                for tr in transOut:
                    trdict = ctx.transitions.get(tr)
                    if trdict.get('trtype', 'fade') == 'fade':
                        break
                else:
                    trdict = None
            # start value may be updated in next iteration if fill="freeze"
            if transOut and trdict is not None and trdict.get('dur', 1) > 0:
                tagdict['tag'] = 'fadeout'
                tagdict['tduration'] = trdict.get('dur', 1)
                tagdict['start'] = start - tagdict['tduration']
                start = tagdict['tduration']
            else:
                # no transition
                tagdict['tag'] = 'fill'
                tagdict['tduration'] = 0
                tagdict['start'] = start
                start = 0
            tagdict['color'] = bgcolor
            tagdict['displayfull'] = 0
            tagdict['subregionxy'] = effMediaGeom[:2]
            tagdict['subregionwh'] = effMediaGeom[2:]

        # deal with hyperlinks from this node
        # we only do hyperlinks from whole-node anchors to external documents
        for a in c.GetChildren():
            if a.GetType() == 'anchor' and \
               MMAttrdefs.getattr(a, 'actuate') == 'onRequest' and \
               not MMAttrdefs.getattr(a, 'fragment') and \
               MMAttrdefs.getattr(a, 'ashape') == 'rect' and \
               not MMAttrdefs.getattr(a, 'acoords'):
                links = hlinks.finddstlinks(a)
                for l in links:
                    if type(l[ANCHOR2]) is type(''):
                        tagdict['href'] = l[ANCHOR2]
                        break

    rp.duration = rp.duration + start
    if rp.tags:
        rp.duration = rp.duration + rp.tags[-1]['tduration']
    dur = node.GetAttrDef('duration', None)
    if dur is not None:
        # seq duration overrides calculated duration
        rp.duration = dur
    if fill == 'freeze':
        # need to update start of out transition
        rp.tags[-1]['start'] = start - rp.tags[-1]['tduration']
        start = rp.tags[-1]['tduration']
    import windowinterface
    windowinterface.FileDialog('File name for RealPix:', '.', ['image/vnd.rn-realpix'], '', lambda file,rp=rp,node=node,regionname=region.name:_convertrpfinish(file,rp,node,regionname), None)