* src/DisplayState.py: recent file support

* src/ViewManager.py: recent file support

* 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


svn: r5631
This commit is contained in:
Don Allingham 2005-12-24 19:18:18 +00:00
parent b7040cb2e3
commit 8cb5f9673e
3 changed files with 42 additions and 18 deletions

View File

@ -1,12 +1,16 @@
2005-12-24 Don Allingham <don@gramps-project.org>
* src/DisplayState.py: recent file support
* src/ViewManager.py: recent file support
2005-12-23 Don Allingham <don@gramps-project.org>
* 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 <shura@gramps-project.org>
* src/EditPerson.py: Swap menu/submenu labels.

View File

@ -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('<menuitem action="%s"/>' % 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

View File

@ -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]