Jeremy Sanders wrote:
On Tue, 14 Mar 2006, Jeremy Sanders wrote:
I corrected a bug where if there weren't any history items it would
see the first one. I also modified the code to only show the final
part of the filename in the menu (but not on the status bar).
It also occurs to me that every file that is opened (e.g. command line)
should appear on the recent files list. I quite often open files like that.
What do you think?
The attached patch (against current CVS, very lightly tested) should do
that, if you haven't already. It also renames a few functions to more
sensible names.
? recentFiles.diff
? dialogs/__init__.pyc
? dialogs/aboutdialog.pyc
? dialogs/dataeditdialog.pyc
? dialogs/exceptiondialog.pyc
? dialogs/importdialog.pyc
? dialogs/importfits.pyc
? dialogs/reloaddata.pyc
? document/__init__.pyc
? document/commandinterface.pyc
? document/commandinterpreter.pyc
? document/datasets.pyc
? document/doc.pyc
? document/operations.pyc
? document/readcsv.pyc
? document/simpleread.pyc
? helpers/__init__.pyc
? setting/__init__.pyc
? setting/collections.pyc
? setting/controls.pyc
? setting/setting.pyc
? setting/settingdb.pyc
? setting/settings.pyc
? setting/stylesheet.pyc
? utils/__init__.pyc
? utils/fitlm.pyc
? utils/points.pyc
? utils/pref.pyc
? utils/preftypes.pyc
? utils/textrender.pyc
? utils/utilfuncs.pyc
? utils/version.pyc
? widgets/__init__.pyc
? widgets/axis.pyc
? widgets/axisticks.pyc
? widgets/containers.pyc
? widgets/contour.pyc
? widgets/fit.pyc
? widgets/graph.pyc
? widgets/image.pyc
? widgets/key.pyc
? widgets/page.pyc
? widgets/plotters.pyc
? widgets/root.pyc
? widgets/widget.pyc
? widgets/widgetfactory.pyc
? windows/__init__.pyc
? windows/action.pyc
? windows/consolewindow.pyc
? windows/mainwindow.pyc
? windows/plotwindow.pyc
? windows/treeeditwindow.pyc
Index: windows/mainwindow.py
===================================================================
RCS file: /cvs/veusz/veusz/windows/mainwindow.py,v
retrieving revision 1.51
diff -u -r1.51 mainwindow.py
--- windows/mainwindow.py 14 Mar 2006 21:51:26 -0000 1.51
+++ windows/mainwindow.py 14 Mar 2006 23:54:35 -0000
@@ -52,7 +52,7 @@
win = cls()
win.show()
if filename:
- win.openFile(filename)
+ win.openFileInWindow(filename)
return win
CreateWindow = classmethod(CreateWindow)
@@ -160,7 +160,7 @@
files = self._getVeuszFiles(event)
if files:
if self.document.isBlank():
- self.openFile(files[0])
+ self.openFileInWindow(files[0])
else:
self.CreateWindow(files[0])
for filename in files[1:]:
@@ -501,18 +501,18 @@
self.slotFileSave()
- def doFileOpen(self,filename):
- """(Needs a better name) - select whether to load the file in the
+ def openFile(self,filename):
+ """Select whether to load the file in the
current window or in a blank window and calls the appropriate loader"""
if self.document.isBlank():
# If the file is new and there are no modifications,
# reuse the current window
- self.openFile(filename)
+ self.openFileInWindow(filename)
else:
# create a new window
self.CreateWindow(filename)
- def openFile(self, filename):
+ def openFileInWindow(self, filename):
'''Open the given filename in the current window.'''
# show busy cursor
@@ -526,6 +526,19 @@
self.filename = filename
self.updateTitlebar()
self.updateStatusbar("Opened %s" % filename)
+
+ #Update the list of recently opened files
+ if 'recent_files' in setting.settingdb:
+ filelist = setting.settingdb['recent_files']
+ if filename in filelist:
+ filelist.remove(filename)
+ filelist.insert(0, filename)
+ filelist = filelist[:5]
+ else:
+ filelist = [filename]
+ setting.settingdb['recent_files'] = filelist
+ self.populateRecentFiles()
+
except IOError:
# problem reading file
qt.QMessageBox("Veusz",
@@ -564,20 +577,8 @@
self.dirname = fd.dir()
filename = unicode( fd.selectedFile() )
-
- #Update the list of recently opened files
- if 'recent_files' in setting.settingdb:
- filelist = setting.settingdb['recent_files']
- if filename in filelist:
- filelist.remove(filename)
- filelist.insert(0, filename)
- filelist = filelist[:5]
- else:
- filelist = [filename]
- setting.settingdb['recent_files'] = filelist
- self.populateRecentFiles()
- self.doFileOpen(filename)
+ self.openFile(filename)
def populateRecentFiles(self):
"""Populate the recently opened files menu with a list of
@@ -595,7 +596,7 @@
def fileOpenerFunction(filename):
path=filename
def f():
- self.doFileOpen(path)
+ self.openFile(path)
return f
f = fileOpenerFunction(path)
self._openRecentFunctions.append(f)
_______________________________________________
Veusz-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/veusz-discuss