* 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 svn: r5629
This commit is contained in:
parent
4f96128b79
commit
318def7c23
@ -1,3 +1,13 @@
|
|||||||
|
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
|
||||||
|
|
||||||
2005-12-23 Alex Roitman <shura@gramps-project.org>
|
2005-12-23 Alex Roitman <shura@gramps-project.org>
|
||||||
* src/EditPerson.py: Swap menu/submenu labels.
|
* src/EditPerson.py: Swap menu/submenu labels.
|
||||||
* src/EventEdit.py: Menu label fixes.
|
* src/EventEdit.py: Menu label fixes.
|
||||||
|
@ -340,6 +340,59 @@ class GrampsWindowManager:
|
|||||||
self.action_group.add_actions(action_data)
|
self.action_group.add_actions(action_data)
|
||||||
self.enable()
|
self.enable()
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Recent Docs Menu
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_rct_top = '<ui><menubar name="MenuBar"><menu action="FileMenu"><menu action="OpenRecent">'
|
||||||
|
_rct_btm = '</menu></menu></menubar></ui>'
|
||||||
|
|
||||||
|
import RecentFiles
|
||||||
|
import os
|
||||||
|
try:
|
||||||
|
from gnomevfs import get_mime_type
|
||||||
|
except:
|
||||||
|
from gnome.vfs import get_mime_type
|
||||||
|
|
||||||
|
class RecentDocsMenu:
|
||||||
|
def __init__(self,uimanager):
|
||||||
|
self.action_group = gtk.ActionGroup('RecentFiles')
|
||||||
|
self.active = DISABLED
|
||||||
|
self.uimanager = uimanager
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
f = StringIO()
|
||||||
|
f.write(_rct_top)
|
||||||
|
gramps_rf = RecentFiles.GrampsRecentFiles()
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
if self.active != DISABLED:
|
||||||
|
self.uimanager.remove_ui(self.active)
|
||||||
|
self.uimanager.remove_action_group(self.action_group)
|
||||||
|
self.active = DISABLED
|
||||||
|
|
||||||
|
actions = []
|
||||||
|
for item in gramps_rf.gramps_recent_files:
|
||||||
|
try:
|
||||||
|
filename = os.path.basename(item.get_path()).replace('_','__')
|
||||||
|
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))
|
||||||
|
except RuntimeError:
|
||||||
|
pass # ignore no longer existing files
|
||||||
|
|
||||||
|
count +=1
|
||||||
|
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())
|
||||||
|
f.close()
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Gramps Managed Window class
|
# Gramps Managed Window class
|
||||||
|
@ -108,7 +108,7 @@ class EditPerson(DisplayState.ManagedWindow):
|
|||||||
else:
|
else:
|
||||||
self.orig_handle = ""
|
self.orig_handle = ""
|
||||||
|
|
||||||
DisplayState.ManagedWindow.__init__(self, uistate, [], person)
|
DisplayState.ManagedWindow.__init__(self, uistate, track, person)
|
||||||
|
|
||||||
if self.already_exist:
|
if self.already_exist:
|
||||||
return
|
return
|
||||||
|
@ -181,7 +181,7 @@ class EditSource(DisplayState.ManagedWindow):
|
|||||||
self.idle = None
|
self.idle = None
|
||||||
self.name_display = NameDisplay.displayer.display
|
self.name_display = NameDisplay.displayer.display
|
||||||
|
|
||||||
DisplayState.ManagedWindow.__init__(self, uistate, self.track, self.source)
|
DisplayState.ManagedWindow.__init__(self, uistate, self.track, source)
|
||||||
|
|
||||||
if source:
|
if source:
|
||||||
self.source = source
|
self.source = source
|
||||||
@ -411,7 +411,7 @@ class EditSource(DisplayState.ManagedWindow):
|
|||||||
if data_type == 0:
|
if data_type == 0:
|
||||||
import EditPerson
|
import EditPerson
|
||||||
person = self.db.get_person_from_handle(handle)
|
person = self.db.get_person_from_handle(handle)
|
||||||
EditPerson.EditPerson(self.parent,person,self.db)
|
EditPerson.EditPerson(self.state, self.uistate, self.track, person)
|
||||||
elif data_type == 1:
|
elif data_type == 1:
|
||||||
import Marriage
|
import Marriage
|
||||||
family = self.db.get_family_from_handle(handle)
|
family = self.db.get_family_from_handle(handle)
|
||||||
|
@ -113,7 +113,7 @@ class EventEditor(DisplayState.ManagedWindow):
|
|||||||
self.dp = _dp
|
self.dp = _dp
|
||||||
self.dd = _dd
|
self.dd = _dd
|
||||||
|
|
||||||
DisplayState.ManagedWindow.__init__(self, uistate, [], event)
|
DisplayState.ManagedWindow.__init__(self, uistate, self.track, event)
|
||||||
if self.already_exist:
|
if self.already_exist:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -612,15 +612,16 @@ class UrlListBox(ReorderListBox):
|
|||||||
self.data[index].set_description(value)
|
self.data[index].set_description(value)
|
||||||
|
|
||||||
def add(self,obj):
|
def add(self,obj):
|
||||||
UrlEdit.UrlEditor(self.state, self.uistate, self.name, None,
|
UrlEdit.UrlEditor(self.state, self.uistate, self.track,
|
||||||
self.edit_callback)
|
self.name, None, self.edit_callback)
|
||||||
|
|
||||||
def update(self,obj):
|
def update(self,obj):
|
||||||
store,node = self.list_model.get_selected()
|
store,node = self.list_model.get_selected()
|
||||||
if node:
|
if node:
|
||||||
UrlEdit.UrlEditor(self.state, self.uistate, self.name,
|
UrlEdit.UrlEditor(self.state, self.uistate, self.track,
|
||||||
|
self.name,
|
||||||
self.list_model.get_object(node),
|
self.list_model.get_object(node),
|
||||||
self.edit_callback, self.window)
|
self.edit_callback)
|
||||||
|
|
||||||
def display_data(self,url):
|
def display_data(self,url):
|
||||||
return [url.get_path(), url.get_description()]
|
return [url.get_path(), url.get_description()]
|
||||||
|
@ -319,7 +319,8 @@ class SourceTab:
|
|||||||
if node:
|
if node:
|
||||||
col = store.get_path(node)
|
col = store.get_path(node)
|
||||||
src = self.list[col[0]]
|
src = self.list[col[0]]
|
||||||
SourceEditor(self.state, self.uistate, self.track, src, self.update_clist)
|
SourceEditor(self.state, self.uistate, self.track,
|
||||||
|
src, self.update_clist)
|
||||||
|
|
||||||
def add_src_clicked(self,obj):
|
def add_src_clicked(self,obj):
|
||||||
src = RelLib.SourceRef()
|
src = RelLib.SourceRef()
|
||||||
@ -351,9 +352,7 @@ class SourceEditor(DisplayState.ManagedWindow):
|
|||||||
else:
|
else:
|
||||||
submenu_label = _('New Source Reference')
|
submenu_label = _('New Source Reference')
|
||||||
|
|
||||||
DisplayState.ManagedWindow.__init__(
|
DisplayState.ManagedWindow.__init__(self, uistate, self.track, srcref)
|
||||||
self, uistate, self.track, srcref, submenu_label,
|
|
||||||
_('Source Reference Editor'))
|
|
||||||
|
|
||||||
self.update = update
|
self.update = update
|
||||||
self.source_ref = srcref
|
self.source_ref = srcref
|
||||||
@ -427,6 +426,13 @@ class SourceEditor(DisplayState.ManagedWindow):
|
|||||||
self.db.connect('source-add', self.rebuild_menu)
|
self.db.connect('source-add', self.rebuild_menu)
|
||||||
self.window.show()
|
self.window.show()
|
||||||
|
|
||||||
|
def build_menu_names(self,srcref):
|
||||||
|
if srcref:
|
||||||
|
submenu_label = _('Source Reference')
|
||||||
|
else:
|
||||||
|
submenu_label = _('New Source Reference')
|
||||||
|
return (_('Source Reference Editor'),submenu_label)
|
||||||
|
|
||||||
def rebuild_menu(self,handle_list):
|
def rebuild_menu(self,handle_list):
|
||||||
self.build_source_menu(handle_list[0])
|
self.build_source_menu(handle_list[0])
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ import const
|
|||||||
import Utils
|
import Utils
|
||||||
import RelLib
|
import RelLib
|
||||||
import GrampsDisplay
|
import GrampsDisplay
|
||||||
|
import DisplayState
|
||||||
|
|
||||||
from WindowUtils import GladeIf
|
from WindowUtils import GladeIf
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -52,18 +54,20 @@ from WindowUtils import GladeIf
|
|||||||
# UrlEditor class
|
# UrlEditor class
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class UrlEditor:
|
class UrlEditor(DisplayState.ManagedWindow):
|
||||||
|
|
||||||
|
def __init__(self, dbstate, uistate, track, name, url, callback):
|
||||||
|
|
||||||
|
self.db = dbstate.db
|
||||||
|
self.uistate = uistate
|
||||||
|
self.state = dbstate
|
||||||
|
self.callback = callback
|
||||||
|
self.name = name
|
||||||
|
|
||||||
|
DisplayState.ManagedWindow.__init__(self, uistate, track, url)
|
||||||
|
if self.already_exist:
|
||||||
|
return
|
||||||
|
|
||||||
def __init__(self,parent,name,url,callback,parent_window=None):
|
|
||||||
self.parent = parent
|
|
||||||
if url:
|
|
||||||
if self.parent.child_windows.has_key(url):
|
|
||||||
self.parent.child_windows[url].present(None)
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
self.win_key = url
|
|
||||||
else:
|
|
||||||
self.win_key = self
|
|
||||||
self.url = url
|
self.url = url
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.top = gtk.glade.XML(const.dialogFile, "url_edit","gramps")
|
self.top = gtk.glade.XML(const.dialogFile, "url_edit","gramps")
|
||||||
@ -78,7 +82,7 @@ class UrlEditor:
|
|||||||
if not name or name == ", ":
|
if not name or name == ", ":
|
||||||
etitle =_('Internet Address Editor')
|
etitle =_('Internet Address Editor')
|
||||||
else:
|
else:
|
||||||
etitle =_('Internet Address Editor for %s') % escape(name),
|
etitle =_('Internet Address Editor for %s') % escape(name)
|
||||||
|
|
||||||
|
|
||||||
Utils.set_titles(self.window,title_label, etitle,
|
Utils.set_titles(self.window,title_label, etitle,
|
||||||
@ -93,37 +97,25 @@ class UrlEditor:
|
|||||||
self.gladeif.connect('button124','clicked', self.on_url_edit_ok_clicked)
|
self.gladeif.connect('button124','clicked', self.on_url_edit_ok_clicked)
|
||||||
self.gladeif.connect('button130','clicked', self.on_help_clicked)
|
self.gladeif.connect('button130','clicked', self.on_help_clicked)
|
||||||
|
|
||||||
if parent_window:
|
self.window.set_transient_for(self.parent_window)
|
||||||
self.window.set_transient_for(parent_window)
|
|
||||||
self.add_itself_to_menu()
|
|
||||||
self.window.show()
|
self.window.show()
|
||||||
|
|
||||||
|
def build_menu_names(self,obj):
|
||||||
|
if not self.name or self.name == ", ":
|
||||||
|
etitle =_('Internet Address Editor')
|
||||||
|
else:
|
||||||
|
etitle =_('Internet Address Editor for %s') % escape(self.name)
|
||||||
|
return (etitle, _('Internet Address Editor'))
|
||||||
|
|
||||||
def on_delete_event(self,*obj):
|
def on_delete_event(self,*obj):
|
||||||
self.gladeif.close()
|
self.gladeif.close()
|
||||||
self.remove_itself_from_menu()
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
def close(self,*obj):
|
def close(self,*obj):
|
||||||
self.gladeif.close()
|
self.gladeif.close()
|
||||||
self.remove_itself_from_menu()
|
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
def add_itself_to_menu(self):
|
|
||||||
self.parent.child_windows[self.win_key] = self
|
|
||||||
label = _('Internet Address Editor')
|
|
||||||
self.parent_menu_item = gtk.MenuItem(label)
|
|
||||||
self.parent_menu_item.connect("activate",self.present)
|
|
||||||
self.parent_menu_item.show()
|
|
||||||
self.parent.winsmenu.append(self.parent_menu_item)
|
|
||||||
|
|
||||||
def remove_itself_from_menu(self):
|
|
||||||
del self.parent.child_windows[self.win_key]
|
|
||||||
self.parent_menu_item.destroy()
|
|
||||||
|
|
||||||
def present(self,*obj):
|
|
||||||
self.window.present()
|
|
||||||
|
|
||||||
def on_help_clicked(self,*obj):
|
def on_help_clicked(self,*obj):
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
"""Display the relevant portion of GRAMPS manual"""
|
||||||
GrampsDisplay.help('gramps-edit-complete')
|
GrampsDisplay.help('gramps-edit-complete')
|
||||||
@ -133,10 +125,6 @@ class UrlEditor:
|
|||||||
addr = unicode(self.addr.get_text())
|
addr = unicode(self.addr.get_text())
|
||||||
priv = self.priv.get_active()
|
priv = self.priv.get_active()
|
||||||
|
|
||||||
if self.url == None:
|
|
||||||
self.url = RelLib.Url()
|
|
||||||
self.parent.ulist.append(self.url)
|
|
||||||
|
|
||||||
self.update_url(des,addr,priv)
|
self.update_url(des,addr,priv)
|
||||||
self.callback(self.url)
|
self.callback(self.url)
|
||||||
self.close(obj)
|
self.close(obj)
|
||||||
@ -144,12 +132,10 @@ class UrlEditor:
|
|||||||
def update_url(self,des,addr,priv):
|
def update_url(self,des,addr,priv):
|
||||||
if self.url.get_path() != addr:
|
if self.url.get_path() != addr:
|
||||||
self.url.set_path(addr)
|
self.url.set_path(addr)
|
||||||
self.parent.lists_changed = 1
|
|
||||||
|
|
||||||
if self.url.get_description() != des:
|
if self.url.get_description() != des:
|
||||||
self.url.set_description(des)
|
self.url.set_description(des)
|
||||||
self.parent.lists_changed = 1
|
|
||||||
|
|
||||||
if self.url.get_privacy() != priv:
|
if self.url.get_privacy() != priv:
|
||||||
self.url.set_privacy(priv)
|
self.url.set_privacy(priv)
|
||||||
self.parent.lists_changed = 1
|
|
||||||
|
@ -78,7 +78,8 @@ uidefault = '''<ui>
|
|||||||
<menu action="FileMenu">
|
<menu action="FileMenu">
|
||||||
<menuitem action="New"/>
|
<menuitem action="New"/>
|
||||||
<menuitem action="Open"/>
|
<menuitem action="Open"/>
|
||||||
<menuitem action="OpenRecent"/>
|
<menu action="OpenRecent">
|
||||||
|
</menu>
|
||||||
<separator/>
|
<separator/>
|
||||||
<menuitem action="Import"/>
|
<menuitem action="Import"/>
|
||||||
<menuitem action="SaveAs"/>
|
<menuitem action="SaveAs"/>
|
||||||
@ -203,6 +204,8 @@ class ViewManager:
|
|||||||
|
|
||||||
person_nav = Navigation.PersonNavigation(self.uistate)
|
person_nav = Navigation.PersonNavigation(self.uistate)
|
||||||
self.navigation_type[PageView.NAVIGATION_PERSON] = (person_nav,None)
|
self.navigation_type[PageView.NAVIGATION_PERSON] = (person_nav,None)
|
||||||
|
self.recent_manager = DisplayState.RecentDocsMenu(self.uimanager)
|
||||||
|
self.recent_manager.build()
|
||||||
self.window.show()
|
self.window.show()
|
||||||
|
|
||||||
def init_interface(self):
|
def init_interface(self):
|
||||||
@ -237,7 +240,7 @@ class ViewManager:
|
|||||||
('FileMenu', None, '_File'),
|
('FileMenu', None, '_File'),
|
||||||
('New', gtk.STOCK_NEW, '_New', "<control>n", None, self.new_activate),
|
('New', gtk.STOCK_NEW, '_New', "<control>n", None, self.new_activate),
|
||||||
('Open', gtk.STOCK_OPEN, '_Open', "<control>o", None, self.open_activate),
|
('Open', gtk.STOCK_OPEN, '_Open', "<control>o", None, self.open_activate),
|
||||||
('OpenRecent', gtk.STOCK_OPEN, 'Open _Recent'),
|
('OpenRecent', None, 'Open _Recent'),
|
||||||
('Quit', gtk.STOCK_QUIT, '_Quit', "<control>q", None, self.quit),
|
('Quit', gtk.STOCK_QUIT, '_Quit', "<control>q", None, self.quit),
|
||||||
('ViewMenu', None, '_View'),
|
('ViewMenu', None, '_View'),
|
||||||
('Preferences', gtk.STOCK_PREFERENCES, '_Preferences'),
|
('Preferences', gtk.STOCK_PREFERENCES, '_Preferences'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user