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)
def skin_callback(self): import windowinterface windowinterface.FileDialog('Open Components File', '.', ['text/x-grins-skin'], '', self.__skin_done, None, 1, parent=windowinterface.getmainwnd())
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)
def open_callback(self): callbacks={ 'Browse':(self.__openfile_callback, ()), 'Open': (self.__tcallback, ()), 'Cancel':(self.__ccallback, ()), } import windowinterface f=windowinterface.getmainwnd() self.__owindow=windowinterface.OpenLocationDlg(callbacks,f, self.last_location, recent_files=self.get_recent_files()) self.__text=self.__owindow self.__owindow.show()
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()
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)
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)
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)
def __init__(self, filename, player, profile=15): self.filename = filename self.player = player self.writer = None self.profile = profile self.topwindow = None self.completed = 0 # set avgTimePerFrame to something good enough for non-video presentations self.avgTimePerFrame = 500 # msec self.parent = windowinterface.getmainwnd() self.progress = windowinterface.ProgressDialog("Exporting", self.cancel_callback, self.parent, 0, 1) self.progress.set('Exporting document to WMP...') self.timefunc = self.player.scheduler.timefunc self.player.exportplay(self)
def __init__(self, srcurl): self._waveout = None self._wavhdrs = [] self._wfx = None self._rdr = None self._u = None self._rest = '' self.decoder = None try: u = MMurl.urlopen(srcurl) except IOError: raise error, 'Cannot open file.' if u.headers.maintype != 'audio': u.close() raise error, 'Not an audio file.' if u.headers.subtype == 'basic': atype = 'au' elif u.headers.subtype == 'x-aiff': atype = 'aiff' elif u.headers.subtype == 'x-wav': atype = 'wav' elif u.headers.subtype in ('mp3', 'mpeg', 'x-mp3'): atype = 'mp3' else: atype = 'au' if atype == 'mp3': self.read_more = self.read_more_mp3_audio self.read_mp3_audio(u, atype) else: self.read_more = self.read_more_basic_audio self.read_basic_audio(u, atype) cbwnd = windowinterface.getmainwnd() self.hook_callbacks(cbwnd) self._waveout = winmm.WaveOutOpen(self._wfx, cbwnd.GetSafeHwnd()) self._waveout.Pause() for hdr in self._wavhdrs: hdr.PrepareHeader(self._waveout) self._waveout.Write(hdr)
def close_callback(self, exitcallback=None): for top in self.tops[:]: top.destroy() import windowinterface windowinterface.getmainwnd().destroy()
def getparentwindow(self): # Used by machine-independent code to pass as parent # parameter to dialogs import windowinterface return windowinterface.getmainwnd()
def __init__(self, title, attriblist, toplevel=None, initattr=None): # Create the AttrEditor 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 the window title # attriblist -- list of instances of subclasses of # AttrEditorDialogField if hasattr(self, 'willreopen') and self.willreopen: # This is a reopen call. w = self.__window w._title = title w._attriblist = attriblist w._initattr = initattr for a in attriblist: a.attach_ui(w) w.RecreateWindow() self.fixbuttonstate() return formid = 'attr_edit' if toplevel: toplevel_window = self.wrapper.toplevel.window else: toplevel_window = windowinterface.getmainwnd() w = toplevel_window.newviewobj(formid) w._title = title w._attriblist = attriblist w._cbdict = { 'Cancel': (self.cancel_callback, ()), 'Restore': (self.restore_callback, ()), 'Apply': (self.apply_callback, ()), 'OK': (self.ok_callback, ()), 'Showall': (self.showall_callback, ()), 'Followselection': (self.followselection_callback, ()), 'SetCustomColors': self.setcustomcolors_callback, } if hasattr(self.wrapper, 'context') and hasattr( self.wrapper.context, 'color_list'): w._color_list = self.wrapper.context.color_list w._initattr = initattr # Not sure that this is the right way to pass this info # to AttrEditForm... w._has_showAll = 0 w._has_followSelection = 0 for a in attriblist: a.attach_ui(w) self.__window = w if self.wrapper.canhideproperties(): # Not sure that this is the right way to pass this info # to AttrEditForm... w._has_showAll = 1 w._showAll_initial = self.show_all_attributes commandlist = [ usercmd.SHOWALLPROPERTIES(callback=(self.showall_callback, ())) ] w.set_commandlist(commandlist) w.set_toggle(usercmd.SHOWALLPROPERTIES, self.show_all_attributes) w._has_followSelection = self.wrapper.canfollowselection() w._followSelection_initial = self.follow_selection toplevel_window.showview(w, formid)