示例#1
0
    def __init__(self, title, hasarguments=1):
        # Create the Main dialog.

        # Create the dialog window (non-modal, so does not grab
        # the cursor) and pop it up (i.e. display it on the
        # screen).

        # Arguments (no defaults):
        # title -- string to be displayed as window title
        if __debug__:
            self.commandlist.append(
                CONSOLE(callback=(self.console_callback, ())))
            self.commandlist.append(
                SCHEDDEBUG(callback=(self.scheddebug_callback, ())))
        import Help
        import cmif, MMurl, os
        if hasattr(Help, 'hashelp') and Help.hashelp():
            self.commandlist.append(
                HELP_CONTENTS(callback=(self.help_contents_callback, ())))
        self.commandlist.append(
            GRINS_WEB(callback=(self.grins_web_callback,
                                ('http://www.oratrix.com/GRiNS/', ))))
        for base, cmd in _documentation:
            for ext in ['.pdf', '.html']:
                file = cmif.findfile(base + ext)
                if os.path.exists(file):
                    url = MMurl.pathname2url(file)
                    self.commandlist.append(
                        cmd(callback=(self.grins_web_callback, (url, ))))
                    break
        import windowinterface
        # register events for all frame wnds
        windowinterface.register_event(WMEVENTS.PasteFile, self.pastefile,
                                       None)
        windowinterface.register_event(WMEVENTS.DragFile, self.dropeffect,
                                       None)
        windowinterface.register_event(WMEVENTS.DropFile, self.dropfile, None)
        windowinterface.createmainwnd(title,
                                      adornments=self.adornments,
                                      commandlist=self.commandlist)
        import settings
        if not hasarguments and settings.get('initial_dialog'):
            f = windowinterface.getmainwnd()
            doclist = self.get_recent_files()
            # if we can't edit the GRiNS preferences, we shouldn't allow this check mark
            if features.PREFERENCES in features.feature_set:
                never_again = self.never_again
            else:
                never_again = None
            windowinterface.OpenAppDialog(version.title,
                                          self.new_callback,
                                          self.openfile_callback,
                                          never_again,
                                          doclist,
                                          self.openURL_callback,
                                          parent=f)
示例#2
0
文件: Help.py 项目: ystallonne/grins
def fixhelpdir():
    global helpbase
    global helpbase_web
    if helpbase_web is None:
        helpbase_web = 'http://www.oratrix.com/indir/%s/help/index.html'%version.shortversion
    if helpbase is None:
        import cmif
        helpdir = cmif.findfile('Help')
        basefile = os.path.join(helpdir, 'index.html')
        if os.path.exists(basefile):
            helpbase = MMurl.pathname2url(basefile)
        else:
            helpbase = helpbase_web
示例#3
0
def InitEditors():
    # XXX Should add the directory where the .cmif file resides...
    # XXX (toplevel.dirname)
    import cmif, os
    dirs = [os.curdir, os.environ['HOME'], cmif.findfile('')]
    for dirname in dirs:
        filename = os.path.join(dirname, '.cmif_editors')
        try:
            f = open(filename, 'r')
        except IOError:
            continue
        _merge(f, filename)
        f.close()
示例#4
0
def __WriteFileQT(root, filename, smilurl, oldfilename='', evallicense=0):
    # XXXX If oldfilename set we should use that as a template
    templatedir = findfile('Templates')
    templatedir = MMurl.pathname2url(templatedir)
    #
    # This is a bit of a hack. G2 appears to want its URLs without
    # %-style quoting.
    #
    fp = open(filename, 'w')

    try:
        writer = HTMLWriter(root, fp, filename, smilurl, oldfilename,
                            evallicense, templatedir, 'QuickTime')
        writer.write()
        fp.close()
    except Error, msg:
        windowinterface.showmessage(msg, mtype='error')
        return
示例#5
0
def __WriteFileG2(root, filename, smilurl, oldfilename='', evallicense=0):
    if not smilurl:
        return
    # XXXX If oldfilename set we should use that as a template
    templatedir = findfile('Templates')
    templatedir = MMurl.pathname2url(templatedir)
    #
    # This is a bit of a hack. G2 appears to want its URLs without
    # %-style quoting.
    #
    smilurl = MMurl.unquote(smilurl)
    fp = open(filename, 'w')
    ramfile = ramfilename(filename)

    # specific to g2
    try:
        open(ramfile, 'w').write(smilurl + '\n')
    except IOError, arg:
        windowinterface.showmessage('I/O Error writing %s: %s' %
                                    (ramfile, arg),
                                    mtype='error')
        return
示例#6
0
]

# Where is the preferences file:
if os.name == 'posix':
    PREFSFILENAME = os.environ['HOME'] + '/.grins'
elif os.name == 'mac':
    import macfs, MACFS
    vrefnum, dirid = macfs.FindFolder(MACFS.kOnSystemDisk, 'pref', 1)
    import version
    prefname = version.macpreffilename
    fss = macfs.FSSpec((vrefnum, dirid, prefname))
    PREFSFILENAME = fss.as_pathname()
else:
    default_settings['html_control'] = 0  # which HTML control to use
    import cmif
    PREFSFILENAME = cmif.findfile('grprefs.txt')


def restore():
    global user_settings, nonsaved_user_settings
    user_settings = {}
    nonsaved_user_settings = {}
    if os.path.exists(PREFSFILENAME):
        execfile(PREFSFILENAME, user_settings)
    # Remove __globals__ and such from the user_settings dict
    for k in user_settings.keys():
        if k[:2] == '__':
            del user_settings[k]
    read_components_from_skin()

示例#7
0
                return 1
    return 0


try:
    import producer
except ImportError:
    producer = None
    if sys.platform == 'win32' or sys.platform == 'mac':
        # fatal error on Mac and Windows
        raise ImportError('no RealProducer SDK')
else:
    import cmif
    if sys.platform == 'mac':
        # Newer SDK version with different paths
        dllpath = cmif.findfile('enceng60.dll')
        dir = os.path.split(dllpath)[0]
        if not dir:
            dir = os.getcwd()
        producer.SetDllAccessPath('DT_Plugins=%s\000' % dir +
                                  'DT_Codecs=%s\000' % dir +
                                  'DT_EncSDK=%s\000' % dir +
                                  'DT_Common=%s\000' % dir)
    else:
        dir = cmif.findfile('Producer-SDK')
        if os.path.exists(dir):
            producer.SetDllAccessPath(
                'DT_Plugins=%s\000' % os.path.join(dir, 'Plugins') +
                'DT_Codecs=%s\000' % os.path.join(dir, 'Codecs') +
                'DT_EncSDK=%s\000' % os.path.join(dir, 'Tools') +
                'DT_Common=%s\000' % os.path.join(dir, 'Common'))
示例#8
0
    def write(self):
        import version
        ctxa = self.root.GetContext().attributes
        #
        # Step one - Read the template data. This is an html file
        # with %(name)s constructs that will be filled in later
        #
        if not ctxa.has_key('project_html_page'):
            raise Error, 'Webpage generation skipped: No HTML template selected.'
        template_name = ctxa['project_html_page']
        templatedir = findfile('Templates')
        templatefile = os.path.join(templatedir, template_name)
        if not os.path.exists(templatefile):
            raise Error, 'HTML template file does not exist'
        try:
            template_data = open(templatefile).read()
        except IOError:
            raise Error, 'HTML template %s: I/O error' % template_name

        #
        # Step two - Construct the dictionary for the %(name)s values
        #
        outdict = {}

        outdict['title'] = nameencode(self.__title)[1:-1]
        outdict[
            'generator'] = '<meta name="generator" content="GRiNS %s">' % version.version
        outdict['generatorname'] = 'GRiNS %s' % version.version
        if self.evallicense:
            outdict['generator'] = outdict['generator'] + '\n' + EVALcomment
            outdict['generatorname'] = outdict[
                'generatorname'] + ' (evaluation copy)'
        outdict['ramurl'] = self.ramurl
        outdict['unquotedramurl'] = MMurl.unquote(self.ramurl)
        outdict['templatedir'] = self.templatedir_url
        outdict['author'] = nameencode(ctxa.get('author', ''))[1:-1]
        outdict['copyright'] = nameencode(ctxa.get('copyright', ''))[1:-1]

        playername = 'clip_1'

        out = '<!-- START-GRINS-GENERATED-CODE singleregion -->\n'

        if self.top_levels:
            import features
            if len(self.top_levels) > 1 and (features.MULTIPLE_TOPLAYOUT not in features.feature_set or \
                       (template_data is not None and template_data.find('singleregion') >=0)):
                raise Error, "Multiple toplevel windows"
            w, h = self.top_channel_size(self.top_levels[0])
            if not w or not h:
                raise Error, "Zero-sized presentation window"

            out = out + '<div>\n'

            # we have to take account of slider's width and height in dimension calculation
            out = out + self.objectgenerator(
                w + 20, h + 20, [('controls', 'ImageWindow'),
                                 ('console', playername),
                                 ('autostart', 'false'),
                                 ('src', MMurl.unquote(self.ramurl))])

            out = out + '</div>\n'

        out = out + '<!-- END-GRINS-GENERATED-CODE singleregion -->\n'
        outdict['singleregion'] = out

        #
        # Step three - generate the output
        #
        try:
            output = template_data % outdict
        except:
            raise Error, "Error in HTML template %s" % templatefile
        #
        # Step four - Write it
        #
        self.fp.write(output)