def _do_mac_edit(filename): import findertools, macfs, aetools try: rv = findertools.launch(filename) except (macfs.error, aetools.Error), arg: windowinterface.showmessage("Failed to open file: %s" % str(arg), mtype='warning')
def checkversion_callback(self): import MMurl import windowinterface url = self._get_versiondep_url('updatecheck.txt') try: fp = MMurl.urlopen(url) data = fp.read() fp.close() except: windowinterface.showmessage( 'Unable to check for upgrade. You can try again later, or visit www.oratrix.com with your webbrowser.' ) return data = data.strip() if not data: windowinterface.showmessage( 'You are running the latest version of the software.') return cancel = windowinterface.GetOKCancel( 'There appears to be a newer version!\nDo you want to know more?') if cancel: return url = self._add_license_id(self, data) windowinterface.htmlwindow(url)
def finish_link(self, node, notransaction=0): self.fixinteresting() if not self.interesting: windowinterface.showmessage('No reasonable sources for link.') return if len(self.interesting) == 1: srcanchor = self.interesting[0] else: anchors = ['Cancel'] for a in self.interesting: anchors.append(self.makename(a)) i = windowinterface.multchoice('Choose source anchor', anchors, 0) if i == 0: return srcanchor = self.interesting[i - 1] em = self.editmgr if not notransaction and not em.transaction(): return self.interesting.remove(srcanchor) if node in self.interesting: # unlikely... self.interesting.remove(node) link = srcanchor, node, DIR_1TO2 em.addlink(link) if not notransaction: em.commit()
def set(setting, value, dontsave=0): global _warned_already import windowinterface if get(setting) == value: # no change return if not transaction(auto=1): return if setting in NEEDS_RESTART and value != get( setting) and not _warned_already: _warned_already = 1 windowinterface.showmessage( 'You have to restart GRiNS for some of these changes to take effect.' ) if dontsave: nonsaved_user_settings[setting] = value else: user_settings[setting] = value if nonsaved_user_settings.has_key(setting): del nonsaved_user_settings[setting] if setting == 'skin': global _screensize _screensize = None read_components_from_skin() commit(auto=1)
def _new_ok_callback(self, info): if not info: return if len(info) == 3: d1, d2, filename = info htmltemplate = None else: d1, d2, filename, htmltemplate = info import windowinterface windowinterface.setwaiting() import TopLevel import MMurl from MMExc import MSyntaxError, UserCancel template_url = MMurl.pathname2url(filename) try: top = TopLevel.TopLevel(self, self.getnewdocumentname(filename), template_url) except IOError: import windowinterface windowinterface.showmessage('Cannot open: %s' % filename) except MSyntaxError, msg: message = 'Parse error in document: %s' % filename if msg is not None: message = message + ': %s' % msg import windowinterface windowinterface.showmessage(message, mtype='error')
def writenode(node, evallicense = 0, tostring = 0, silent = 0): if not hasattr(node, 'tmpfile') and not tostring: return import realsupport data = realsupport.writeRP(None, node.slideshow.rp, node, savecaptions=1, tostring = 1, silent = silent) if tostring: return data url = MMAttrdefs.getattr(node, 'file') url = node.GetContext().findurl(url) utype, host, path, params, query, tag = urlparse.urlparse(url) if (not utype or utype == 'file') and \ (not host or host == 'localhost'): try: localpathname = MMurl.url2pathname(path) f = open(localpathname, 'w') f.write(data) f.close() except: windowinterface.showmessage("cannot write `%s' for node `%s'" % (url, MMAttrdefs.getattr(node, 'name') or '<unnamed>')) else: if os.name == 'mac': import macfs import macostools fss = macfs.FSSpec(localpathname) fss.SetCreatorType('PNst', 'PNRA') macostools.touched(fss) del node.tmpfile else: windowinterface.showmessage("cannot write remote file for node `%s'" % (MMAttrdefs.getattr(node, 'name') or '<unnamed>'))
def read_components_from_skin(skindict=None): global components import MMurl import parseskin del components[:] if skindict is None: url = get('skin') if not url: components = ['http://www.oratrix.com/GRiNS/smil2.0'] return try: u = MMurl.urlopen(url) except: import windowinterface windowinterface.showmessage( "Failed opening skin config file `%s'" % url) return try: skindict = parseskin.parsegskin(u) except parseskin.error, msg: import windowinterface windowinterface.showmessage( "Error parsing skin/components file %s: %s" % (url, msg)) nonsaved_user_settings['skin'] = '' skindict = {}
def doFindNext(self, text, options): if not self.__textwindow: return # save the text and options for the next time self._findText = text self._findOptions = options found = 0 # first search from the current position begin = self.getCurrentCharIndex() if self.__textwindow.findNext(begin, text, options) == None: # not found, search from the begining ret = self.__textwindow.findNext(0, text, options) if ret == None: windowinterface.showmessage("No more occurrences.", mtype='error') else: found = 1 else: found = 1 if self._findReplaceDlg != None: self._findReplaceDlg.enableReplace(found) # raz the flag whitch allows to know if a replace if directly possible. self.__selChanged = 0
def checkversion_callback(self): import MMurl import version import windowinterface import settings url = 'http://www.oratrix.com/indir/%s/updatecheck.txt' % version.shortversion try: fp = MMurl.urlopen(url) data = fp.read() fp.close() except: windowinterface.showmessage( 'Unable to check for upgrade. You can try again later, or visit www.oratrix.com with your webbrowser.' ) print "Could not load URL", url return data = data.strip() if not data: windowinterface.showmessage( 'You are running the latest version of the software') return cancel = windowinterface.GetOKCancel( 'There appears to be a newer version!\nDo you want to know more?') if cancel: return # Pass the version and the second item of the license along. id = settings.get('license').split('-')[1] url = '%s?version=%s&id=%s' % (data, version.shortversion, id) windowinterface.htmlwindow(url)
def WriteFTP(root, filename, smilurl, ftpparams, oldfilename='', evallicense=0, exporttype=None): if not smilurl: return host, user, passwd, dir = ftpparams import settings templatedir = settings.get('templatedir_url') # # First create and upload the RAM file # smilurl = MMurl.unquote(smilurl) ramfile = ramfilename(filename) try: ftp = FtpWriter.FtpWriter(host, ramfile, user=user, passwd=passwd, dir=dir, ascii=1) ftp.write(smilurl + '\n') ftp.close() except FtpWriter.all_errors, msg: windowinterface.showmessage('Webserver upload failed:\n%s' % (msg, ), mtype='error') return
def reload(self): # create a new instance # important: we have to create the new instance before to delete the old one # Thus, if the operation fails we can easily back to the original settings.unregister(self) try: top = TopLevel(self.main, self.url) except IOError: windowinterface.showmessage('Cannot open: %s' % self.url) return except MSyntaxError: windowinterface.showmessage('Parse error in document: %s' % self.url) return # show the main frame top.show() # update the recent list. self.main._update_recent(None) # at list top.player.show() # at least, we can close the old instance, before at there was no error self.close()
def ok(self, file): if os.path.exists(file): windowinterface.showmessage('File already exists. Overwrite?', mtype='question', title='Overwrite?', callback=(self.convert, (file, ))) return 1 # don't remove dialog self.convert(file)
def defanchor(self, node, anchor, cb): ch = self.anchorinit(node) if ch is None: windowinterface.showmessage('Cannot set internal anchor\n' + \ '(node not on a channel)') apply(cb, (anchor, )) return ch.defanchor(node, anchor, cb)
def cc_enable_ch(self, name, onoff): try: ch = self.channels[name] except KeyError: windowinterface.showmessage('No such channel: '+name) return ch.set_visible(onoff) self.setchannel(name, onoff)
def dropfile(self, arg, window, event, value): x,y,filename=value url=MMurl.pathname2url(filename) import urlcache, windowinterface mimetype = urlcache.mimetype(url) if mimetype in ('application/x-grins-project', 'application/smil', 'application/smil+xml', 'application/x-grins-cmif'): self.openURL_callback(url) else: windowinterface.showmessage('Only GRiNS or SMIL files can be dropped.')
def _do_edit_win32(cmd, filename): import string app = string.split(cmd, '$file')[0] cmd = '%s %s' % (app, filename) import win32api try: win32api.WinExec(cmd) except: windowinterface.showmessage('Application not found: %s' % app, mtype='warning')
def save_settings(self): values = {} for name in self.bool_names: try: value = self.getboolitem(name) except PreferencesDialogError, arg: windowinterface.showmessage(arg) return None if SPECIAL_NAMES.has_key(name) and value in (0,1): allowed_values = SPECIAL_NAMES[name] value = allowed_values[value] values[name] = value
def WriteFile(root, filename, smilurl, oldfilename='', evallicense=0, exporttype='REAL'): if exporttype == 'REAL': __WriteFileG2(root, filename, smilurl, oldfilename, evallicense) elif exporttype == 'QuickTime': __WriteFileQT(root, filename, smilurl, oldfilename, evallicense) else: windowinterface.showmessage( 'Unsupported export type in this product: %s' % exporttype)
def dropfile(self, arg, window, event, value): if not self.canopennewtop(): return x, y, filename = value url = self.__path2url(filename) import urlcache mimetype = urlcache.mimetype(url) if mimetype in ('application/x-grins-project', 'application/smil', 'application/smil+xml'): self.openURL_callback(url) else: import windowinterface windowinterface.showmessage( 'Only GRiNS or SMIL files can be dropped.')
def loadSplash(self): filename = r'\Program Files\GRiNS\cesplash.bmp' import settings skin = settings.get('skin') if skin: import parseskin, MMurl try: dict = parseskin.parsegskin(MMurl.urlopen(skin)) if dict.has_key('image'): filename = MMurl.urlretrieve( MMurl.basejoin(skin, dict['image']))[0] except parseskin.error, msg: settings.nonsaved_user_settings['skin'] = '' from windowinterface import showmessage showmessage(msg) except:
def newlayout_callback(self, name=None): editmgr = self.editmgr if not name or (not self.__newlayout and name == self.curlayout): editmgr.rollback() return if self.context.layouts.has_key(name): import windowinterface editmgr.rollback() windowinterface.showmessage('screen name already exists') return self.toplevel.setwaiting() if self.__newlayout: editmgr.addlayout(name) else: editmgr.setlayoutname(self.curlayout, name) self.curlayout = name editmgr.commit()
def showeditor(node, url=None): if len(channeleditors) == 0: InitEditors() if not url: if node.GetType() == 'imm': dummy = _Convert(node) return if node.GetType() <> 'ext': windowinterface.showmessage('Only extern nodes can be edited.', mtype='error') return import MMAttrdefs url = MMAttrdefs.getattr(node, 'file') url = node.context.findurl(url) xx = windowinterface.shell_execute(url, 'edit', showmsg=0) if xx != 0: windowinterface.shell_execute(url, 'open')
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
def wholenodeanchor(self, node, extended=0, notransaction=0, create=1, interesting=1): c = self.findwholenodeanchor(node) if c is not None: if not create: return c windowinterface.showmessage( "Such an anchor already exists on this node.") return None if not create: return None return self.createanchor(node, notransaction, interesting)
def do_itemhit(self, item, event): if item == ITEM_LEFT_NODESELECT: self._showmenu(event, ITEM_LEFT_NODESELECT, self._leftmenu) elif item == ITEM_LEFT_ALIST: ## self._listclick(event, self._leftlist, self.anchor_browser_callback, ## (self._left_client_data,)) self.anchor_browser_callback(self._left_client_data) elif item == ITEM_LEFT_PUSH: self.show_callback(self._left_client_data) elif item == ITEM_LEFT_AEDIT: self.anchoredit_callback(self._left_client_data) elif item == ITEM_RIGHT_NODESELECT: self._showmenu(event, ITEM_RIGHT_NODESELECT, self._rightmenu) elif item == ITEM_RIGHT_ALIST: ## self._listclick(event, self._rightlist, self.anchor_browser_callback, ## (self._right_client_data,)) double = self._rightlist.lastclickwasdouble() print 'Double:', ` double ` if double: data = self._rightlist.getselectvalue() if data: windowinterface.showmessage(data) self.anchor_browser_callback(self._right_client_data) elif item == ITEM_RIGHT_PUSH: self.show_callback(self._right_client_data) elif item == ITEM_RIGHT_AEDIT: self.anchoredit_callback(self._right_client_data) elif item == ITEM_RIGHT_ADDEXT: self.add_external_callback() elif item == ITEM_LINKS_LLIST: ## self._listclick(event, self._linklist, self.link_browser_callback, ()) self.link_browser_callback() elif item == ITEM_LINKS_ADD: self.link_new_callback() elif item == ITEM_LINKS_EDIT: self.link_edit_callback() elif item == ITEM_LINKS_DELETE: self.link_delete_callback() else: print 'Unexpected dialog browser event, item', item, 'event', event return 1
def createWriter(self, window): if self.topwindow: print "Cannot export multiple topwindows" return self.topwindow = window if self._hasvideo(): self.avgTimePerFrame = 100 self.fulldur = self.player.userplayroot.calcfullduration() if self.fulldur is None or self.fulldur < 0: windowinterface.showmessage(msgUnresolvedDur, mtype='warning', parent=self.parent) self.writer = wmwriter.WMWriter(self, window.getDrawBuffer(), self.profile, self.avgTimePerFrame) self._setAudioFormat() self.writer.setOutputFilename(self.filename) self.writer.beginWriting()
def openURL_callback(self, url): import windowinterface windowinterface.setwaiting() from MMExc import MSyntaxError import TopLevel self.last_location = url try: top = TopLevel.TopLevel(self, url) except IOError: import windowinterface windowinterface.showmessage('Cannot open: %s' % url) except MSyntaxError: import windowinterface windowinterface.showmessage('Parse error in document: %s' % url) else: self.tops.append(top) top.show() top.player.show() self._update_recent(url)
def transaction(self, type=None): if self.busy: raise MMExc.AssertError, 'recursive transaction' if self.context == None: # the document is probably not open return 0 # allow transaction only the document is valid, or if the transaction come from the source view # note: this test can't be done from the source view which may be closed if type != 'source' and not self.context.isValidDocument(): import windowinterface windowinterface.showmessage( 'You should first fix the parsing errors in the source view.', mtype='error') return 0 self.__delete(self.future) self.future = [] return self.__start_transaction(type)
def anchorfired(self, old_sctx, node, arg): #self.showpauseanchor(0) # also see Scheduler.py # Firing an anchor continues the player if it was paused. if self.scheduler.getpaused(): self.toplevel.waspaused = 1 self.pause(0) else: self.toplevel.waspaused = 0 destlist = self.context.hyperlinks.findsrclinks(node) if not destlist: windowinterface.showmessage( 'No hyperlink source at this anchor') return 0 root = node.GetRoot() for dest in destlist: if not self.context.isgoodlink(dest, root): continue if not self.gotoanchor(dest, arg): return 0 return 1
def openURL_callback(self, url, askskin=1): import windowinterface windowinterface.setwaiting() from MMExc import MSyntaxError import TopLevel self.last_location = url try: top = TopLevel.TopLevel(self, url, askskin=askskin) except IOError: import windowinterface windowinterface.showmessage('Cannot open: %s' % url) except MSyntaxError: import windowinterface windowinterface.showmessage('Parse error in document: %s' % url) else: while self.tops: self.tops[0].close_callback() self.tops.append(top) top.show() top.player.show() top.player.play_callback()