summaryrefslogtreecommitdiffstats
path: root/Mac/Tools
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2003-02-25 15:08:02 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2003-02-25 15:08:02 (GMT)
commitc00b6d7a0a72a481de3064e0bd11e7b30f5b2610 (patch)
treeccd778cd1144df1cc98831bf7783e521e0f56e4d /Mac/Tools
parentf4a9ac25e9cf27914ad4235d0745980d56212c1d (diff)
downloadcpython-c00b6d7a0a72a481de3064e0bd11e7b30f5b2610.zip
cpython-c00b6d7a0a72a481de3064e0bd11e7b30f5b2610.tar.gz
cpython-c00b6d7a0a72a481de3064e0bd11e7b30f5b2610.tar.bz2
Added an "Open Recent" command. Fixes 607810.
Diffstat (limited to 'Mac/Tools')
-rw-r--r--Mac/Tools/IDE/PyEdit.py6
-rw-r--r--Mac/Tools/IDE/PythonIDEMain.py40
2 files changed, 46 insertions, 0 deletions
diff --git a/Mac/Tools/IDE/PyEdit.py b/Mac/Tools/IDE/PyEdit.py
index ef31486..6cac553 100644
--- a/Mac/Tools/IDE/PyEdit.py
+++ b/Mac/Tools/IDE/PyEdit.py
@@ -63,6 +63,7 @@ class Editor(W.Window):
text = f.read()
f.close()
self._creator, filetype = MacOS.GetCreatorAndType(path)
+ self.addrecentfile(path)
else:
raise IOError, "file '%s' does not exist" % path
self.path = path
@@ -399,6 +400,7 @@ class Editor(W.Window):
del linecache.cache[self.path]
import macostools
macostools.touched(self.path)
+ self.addrecentfile(self.path)
def can_save(self, menuitem):
return self.editgroup.editor.changed or self.editgroup.editor.selchanged
@@ -780,6 +782,10 @@ class Editor(W.Window):
def selectline(self, lineno, charoffset = 0):
self.editgroup.editor.selectline(lineno - 1, charoffset)
+
+ def addrecentfile(self, filename):
+ app = W.getapplication()
+ app.addrecentfile(filename)
class _saveoptions:
diff --git a/Mac/Tools/IDE/PythonIDEMain.py b/Mac/Tools/IDE/PythonIDEMain.py
index c79d9fc..9efaa22 100644
--- a/Mac/Tools/IDE/PythonIDEMain.py
+++ b/Mac/Tools/IDE/PythonIDEMain.py
@@ -76,6 +76,8 @@ class PythonIDE(Wapplication.Application):
newitem = FrameWork.MenuItem(m, "New", "N", 'new')
openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open')
openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname')
+ self.openrecentmenu = FrameWork.SubMenu(m, "Open Recent")
+ self.makeopenrecentmenu()
FrameWork.Separator(m)
closeitem = FrameWork.MenuItem(m, "Close", "W", 'close')
saveitem = FrameWork.MenuItem(m, "Save", "S", 'save')
@@ -278,11 +280,49 @@ class PythonIDE(Wapplication.Application):
self._openwindowscheckmark = 0
self.checkopenwindowsmenu()
+ def makeopenrecentmenu(self):
+ for i in range(len(self.openrecentmenu.items)):
+ self.openrecentmenu.menu.DeleteMenuItem(1)
+ self.openrecentmenu.items = []
+ prefs = self.getprefs()
+ filelist = prefs.recentfiles
+ if not filelist:
+ self.openrecentmenu.enable(0)
+ return
+ self.openrecentmenu.enable(1)
+ for filename in filelist:
+ item = FrameWork.MenuItem(self.openrecentmenu, filename, None, callback = self.domenu_openrecent)
+
+ def addrecentfile(self, file):
+ prefs = self.getprefs()
+ filelist = prefs.recentfiles
+ if not filelist:
+ filelist = []
+
+ if file in filelist:
+ if file == filelist[0]:
+ return
+ filelist.remove(file)
+ filelist.insert(0, file)
+ filelist = filelist[:10]
+ prefs.recentfiles = filelist
+ prefs.save()
+ self.makeopenrecentmenu()
+
def domenu_openwindows(self, id, item, window, event):
w = self._openwindows[item]
w.ShowWindow()
w.SelectWindow()
+ def domenu_openrecent(self, id, item, window, event):
+ prefs = self.getprefs()
+ filelist = prefs.recentfiles
+ if not filelist:
+ filelist = []
+ item = item - 1
+ filename = filelist[item]
+ self.openscript(filename)
+
def domenu_quit(self):
self._quit()