From 507d8de5ad7e3577c6ca1d18f4a20cbdcf112585 Mon Sep 17 00:00:00 2001 From: Peter Landgren Date: Wed, 19 Dec 2007 16:40:08 +0000 Subject: [PATCH] Update of RecentFiles for unique renam/name svn: r9536 --- src/RecentFiles.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/RecentFiles.py b/src/RecentFiles.py index d761279dd..079302203 100644 --- a/src/RecentFiles.py +++ b/src/RecentFiles.py @@ -110,18 +110,44 @@ class RecentFiles: # so simply inserting a new item in the beginning self.gramps_recent_files.insert(0,item2add) + + + def rename_filename(self,filename,new_filename): + # First we need to walk the existing items to see + # if our item is already there + found = False + for index in range(len(self.gramps_recent_files)): + if self.gramps_recent_files[index].get_name() == filename: + # Found it -- break here and change that item + found = True + break + if found: + self.gramps_recent_files[index].set_path(new_filename) + def remove_filename(self,filename): # First we need to walk the existing items to see # if our item is already there found = False for index in range(len(self.gramps_recent_files)): - if self.gramps_recent_files[index].get_path() == filename: + if self.gramps_recent_files[index].get_name() == filename: # Found it -- break here and pop that item found = True break if found: self.gramps_recent_files.pop(index) + + def check_if_recent(self,filename): + # First we need to walk the existing items to see + # if our item is already there + found = False + for index in range(len(self.gramps_recent_files)): + if self.gramps_recent_files[index].get_name() == filename: + # Found it -- break here and pop that item + found = True + break + return found + def save(self): """ Attempt saving into XML. @@ -234,3 +260,13 @@ def remove_filename(filename): gramps_rf = RecentFiles() gramps_rf.remove_filename(filename) gramps_rf.save() + +def rename_filename(filename,new_filename): + gramps_rf = RecentFiles() + gramps_rf.rename_filename(filename,new_filename) + gramps_rf.save() + +def check_if_recent(filename): + gramps_rf = RecentFiles() + return gramps_rf.check_if_recent(filename) +