diff --git a/ChangeLog b/ChangeLog index 579886e67..e35369b44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,16 @@ +2005-12-24 Don Allingham + * src/DisplayState.py: recent file support + * src/ViewManager.py: recent file support + 2005-12-23 Don Allingham - * DisplayState.py: recent file support - * EditPerson.py: Window management - * EditSource.py: Window management - * EventEdit.py: Window management - * ListBox.py: Window management - * Sources.py: Window management - * UrlEdit.py: Window management - * ViewManager.py: Window management + * src/DisplayState.py: recent file support + * src/EditPerson.py: Window management + * src/EditSource.py: Window management + * src/EventEdit.py: Window management + * src/ListBox.py: Window management + * src/Sources.py: Window management + * src/UrlEdit.py: Window management + * src/ViewManager.py: Window management 2005-12-23 Alex Roitman * src/EditPerson.py: Swap menu/submenu labels. diff --git a/src/DisplayState.py b/src/DisplayState.py index 061e30f45..7787f0297 100644 --- a/src/DisplayState.py +++ b/src/DisplayState.py @@ -358,10 +358,24 @@ except: from gnome.vfs import get_mime_type class RecentDocsMenu: - def __init__(self,uimanager): + def __init__(self,uimanager, state, fileopen): self.action_group = gtk.ActionGroup('RecentFiles') self.active = DISABLED self.uimanager = uimanager + self.fileopen = fileopen + self.state = state + + def load(self,item): + print item + name = item.get_path() + dbtype = item.get_mime() + + db = GrampsDb.gramps_db_factory(dbtype)() + self.state.change_database(db) + self.fileopen(name) + self.state.db.request_rebuild() + RecentFiles.recent_files(name,dbtype) + self.build() def build(self): f = StringIO() @@ -382,7 +396,8 @@ class RecentDocsMenu: filetype = get_mime_type(item.get_path()) action_id = "RecentMenu%d" % count f.write('' % action_id) - actions.append((action_id,None,filename,None,None,None)) + actions.append((action_id,None,filename,None,None, + make_callback(item,self.load))) except RuntimeError: pass # ignore no longer existing files @@ -390,9 +405,12 @@ class RecentDocsMenu: f.write(_rct_btm) self.action_group.add_actions(actions) self.uimanager.insert_action_group(self.action_group,1) - self.action = self.uimanager.add_ui_from_string(f.getvalue()) + self.active = self.uimanager.add_ui_from_string(f.getvalue()) f.close() +def make_callback(n,f): + return lambda x: f(n) + #------------------------------------------------------------------------- # # Gramps Managed Window class diff --git a/src/ViewManager.py b/src/ViewManager.py index 562af72eb..964bf40eb 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -61,6 +61,7 @@ import PageView import Navigation import TipOfDay import Bookmarks +import RecentFiles #------------------------------------------------------------------------- # @@ -204,7 +205,7 @@ class ViewManager: person_nav = Navigation.PersonNavigation(self.uistate) self.navigation_type[PageView.NAVIGATION_PERSON] = (person_nav,None) - self.recent_manager = DisplayState.RecentDocsMenu(self.uimanager) + self.recent_manager = DisplayState.RecentDocsMenu(self.uimanager,self.state,self.read_file) self.recent_manager.build() self.window.show() @@ -568,8 +569,8 @@ class ViewManager: self.state.db.request_rebuild() self.change_page(None,None) # Add the file to the recent items - #RecentFiles.recent_files(filename,const.app_gramps) - #self.parent.build_recent_menu() + RecentFiles.recent_files(filename,const.app_gramps) + self.recent_manager.build() return True else: choose.destroy() @@ -613,10 +614,10 @@ class ViewManager: self.state.db.request_rebuild() self.change_page(None,None) - #if success: - # Add the file to the recent items - #RecentFiles.recent_files(filename,filetype) - #parent.build_recent_menu() + if success: + # Add the file to the recent items + RecentFiles.recent_files(filename,filetype) + self.recent_manager.build() return success @@ -642,6 +643,7 @@ class ViewManager: 'to the selected file.')) try: + print self.load_database, filename, callback, mode if self.load_database(filename,callback,mode=mode): if filename[-1] == '/': filename = filename[:-1]