From ded50afd834334965c8c0934ec6448cf46d7d937 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sat, 6 May 2006 22:49:51 +0000 Subject: [PATCH] 2006-05-06 Don Allingham * src/DisplayTabs/_SourceEmbedList.py: fix icon * src/DisplayState.py: add relationship calculator option to statusbar svn: r6566 --- ChangeLog | 4 ++++ src/DisplayState.py | 28 ++++++++++++++++++++++++++-- src/DisplayTabs/_SourceEmbedList.py | 29 ++++++++++++++++++++++------- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 629647c19..11f5cc3df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-05-06 Don Allingham + * src/DisplayTabs/_SourceEmbedList.py: fix icon + * src/DisplayState.py: add relationship calculator option to statusbar + 2006-05-05 Don Allingham * src/DisplayTabs/_WebEmbedList.py: new icon diff --git a/src/DisplayState.py b/src/DisplayState.py index c952050e6..b8647c3c1 100644 --- a/src/DisplayState.py +++ b/src/DisplayState.py @@ -255,7 +255,8 @@ class DisplayState(GrampsDb.GrampsDBCallback): __signals__ = { } - def __init__(self,window,status,progress,warnbtn,uimanager,dbstate): + def __init__(self, window, status, progress, warnbtn, uimanager, dbstate): + self.dbstate = dbstate self.uimanager = uimanager self.window = window @@ -274,6 +275,29 @@ class DisplayState(GrampsDb.GrampsDBCallback): self.log = logging.getLogger() self.log.setLevel(logging.WARN) self.log.addHandler(self.rh) + self.dbstate.connect('database-changed', self.db_changed) + + def db_changed(self, db): + from PluginUtils import _PluginMgr + self.relationship = _PluginMgr.relationship_class(db) + + def display_relationship(self): + default_person = self.dbstate.db.get_default_person() + active = self.dbstate.get_active_person() + if default_person == None or active == None: + return u'' + + pname = NameDisplay.displayer.display(default_person) + (name,plist) = self.relationship.get_relationship( + default_person,active) + + if name: + if plist == None: + return name + return _("%(relationship)s of %(person)s") % { + 'relationship' : name, 'person' : pname } + else: + return u"" def clear_history(self): self.phistory.clear() @@ -306,7 +330,7 @@ class DisplayState(GrampsDb.GrampsDBCallback): pname = NameDisplay.displayer.display(person) name = "[%s] %s" % (person.get_gramps_id(),pname) else: - name = "" #self.display_relationship() + name = self.display_relationship() self.status.push(self.status_id,name) while gtk.events_pending(): diff --git a/src/DisplayTabs/_SourceEmbedList.py b/src/DisplayTabs/_SourceEmbedList.py index a3abf7859..53e14108a 100644 --- a/src/DisplayTabs/_SourceEmbedList.py +++ b/src/DisplayTabs/_SourceEmbedList.py @@ -69,7 +69,7 @@ class SourceEmbedList(EmbeddedList): _('Sources'), SourceRefModel, True) def get_icon_name(self): - return 'gramps-event' + return 'gramps-source' def get_data(self): return self.obj @@ -83,24 +83,39 @@ class SourceEmbedList(EmbeddedList): try: from Editors import EditSourceRef - EditSourceRef(self.dbstate, self.uistate, self.track, - src, sref, self.add_callback) + EditSourceRef( + self.dbstate, + self.uistate, + self.track, + src, + sref, + self.add_callback) + except Errors.WindowActiveError: pass def share_button_clicked(self, obj): import SelectSource - sel = SelectSource.SelectSource(self.dbstate,self.uistate,self.track, - _("Select source")) + sel = SelectSource.SelectSource( + self.dbstate, + self.uistate, + self.track, + _("Select source")) + src = sel.run() if src: try: from Editors import EditSourceRef ref = RelLib.SourceRef() - EditSourceRef(self.dbstate, self.uistate, self.track, - src, ref, self.add_callback) + EditSourceRef(self.dbstate, + self.uistate, + self.track, + src, + ref, + self.add_callback) + except Errors.WindowActiveError: pass