|
From: Alex T. <ale...@us...> - 2004-10-05 12:08:34
|
Update of /cvsroot/pythoncard/PythonCard/tools/oneEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10497/oneEditor Modified Files: codePage.py tabcodeEditor.py Log Message: Put codePage.saveAsFile back in, completed "close tab". Added switch "NEVER_BLANK" to determine how to handle closing last tab Fixed logic in openfile for when a new tab is needed. Index: tabcodeEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/oneEditor/tabcodeEditor.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tabcodeEditor.py 5 Oct 2004 00:42:27 -0000 1.3 --- tabcodeEditor.py 5 Oct 2004 12:08:22 -0000 1.4 *************** *** 27,30 **** --- 27,32 ---- import webbrowser + NEVER_BLANK = True # if True, closing last tab causes newFile + # KEA 2004-07-22 # force imports for components used in .rsrc.py file *************** *** 476,480 **** else: if page.documentPath is None: ! if not page.on_menuFileSaveAs_select(None): return False else: page.saveFile(page.documentPath) --- 478,482 ---- else: if page.documentPath is None: ! if not page.saveAsFile(): return False else: page.saveFile(page.documentPath) *************** *** 503,507 **** if self.currentPage.documentPath is None: # this a "new" document and needs to go through Save As... ! self.currentPage.on_menuFileSaveAs_select(None) else: self.currentPage.saveFile(self.currentPage.documentPath) --- 505,509 ---- if self.currentPage.documentPath is None: # this a "new" document and needs to go through Save As... ! self.currentPage.saveAsFile() else: self.currentPage.saveFile(self.currentPage.documentPath) *************** *** 509,521 **** def on_menuFileSaveAs_select(self, event): if self.currentPage: ! return self.currentPage.on_menuFileSaveAs_select(event) def on_menuFileCloseTab_select(self, event): # what do we do if there is only one tab? - # looks like CodePage on_menuFileSaveAs_select - # so this handler and the ones above will throw an exception - # if that line is called - # just do a Close Tab after opening the app - # and typing a character if self.currentPage: page = self.currentPage --- 511,518 ---- def on_menuFileSaveAs_select(self, event): if self.currentPage: ! return self.currentPage.saveAsFile() def on_menuFileCloseTab_select(self, event): # what do we do if there is only one tab? if self.currentPage: page = self.currentPage *************** *** 525,542 **** save = self.saveChanges(page.documentPath) if save == "Cancel": ! print "Cancelled Save" elif save == "No": ! print "Didn't Save" ! # close the document ! # and remove the tab here ! # unless there is only one tab left ! # in which case I don't know what the UI ! # should do?! ! # so probably check the number of tabs here ! # if len() > 1 then just remove the tab ! # stick this functionality in another method? else: if page.documentPath is None: ! if not page.on_menuFileSaveAs_select(None): print "no path, Didn't Save" # this logic was borrowed from doExit # user chose Yes to save on previous dialog but then --- 522,533 ---- save = self.saveChanges(page.documentPath) if save == "Cancel": ! #rint "Cancelled Save" ! return elif save == "No": ! #rint "Didn't Save" ! pass else: if page.documentPath is None: ! if not page.saveAsFile(): print "no path, Didn't Save" # this logic was borrowed from doExit # user chose Yes to save on previous dialog but then *************** *** 545,552 **** else: page.saveFile(page.documentPath) ! print "Saved" ! # close the tab ! # if there is only one tab, what ! # should we do? def newFile(self): --- 536,552 ---- else: page.saveFile(page.documentPath) ! #rint "Saved" ! self.closeTab() ! ! def closeTab(self): ! del self.pages[self.currentPageNumber] ! self.components.notebook.DeletePage(self.currentPageNumber) ! if len(self.pages) == 0: ! if NEVER_BLANK: ! self.newFile() ! else: ! self.currentPageNumber = -1 ! self.currentPage = None ! self.currentDocument = None def newFile(self): *************** *** 561,565 **** def openFile(self, path): ! if self.currentPage and self.currentPage.documentPath: win = model.childWindow(self.components.notebook, codePage.CodePage) self.components.notebook.AddPage(win, "opening ...", True) --- 561,572 ---- def openFile(self, path): ! # need a new tab page in notebook if ! # no current page - i.e. blank notebook ! # current page is a open on a file ! # untitled document has been modified ! if (not self.currentPage or ! self.currentPage.documentPath or ! self.currentDocument.GetModify() ): ! win = model.childWindow(self.components.notebook, codePage.CodePage) self.components.notebook.AddPage(win, "opening ...", True) Index: codePage.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/oneEditor/codePage.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** codePage.py 3 Oct 2004 23:58:01 -0000 1.1 --- codePage.py 5 Oct 2004 12:08:22 -0000 1.2 *************** *** 60,63 **** --- 60,82 ---- except: self.components.document.setEditorStyle('python') + + def saveAsFile(self): + resourceStrings = self.topLevelParent.resource.strings + #wildcard = "Python scripts (*.py;*.pyw)|*.py;*.pyw|Text files (*.txt)|*.txt|All files (*.*)|*.*" + wildcard = resourceStrings.saveAsWildcard + if self.documentPath is None: + dir = '' + filename = '*.py' + else: + dir = os.path.dirname(self.documentPath) + filename = os.path.basename(self.documentPath) + result = dialog.saveFileDialog(None, resourceStrings.saveAs, dir, filename, wildcard) + if result.accepted: + path = result.paths[0] + self.saveFile(path) + self.topLevelParent.fileHistory.AddFileToHistory(path) + return True + else: + return False |