From df8a2a7bf3f2f961ba90b75a4a55cdeea4750531 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Wed, 26 Jan 2011 18:52:18 +0000 Subject: [PATCH] Clear bottombar gramplets when no active person is set svn: r16478 --- src/plugins/gramplet/PersonAttributes.py | 9 ++++--- src/plugins/gramplet/PersonDetails.py | 30 +++++++++++++++++++++--- src/plugins/gramplet/PersonGallery.py | 7 +++--- src/plugins/gramplet/PersonResidence.py | 9 +++++-- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/plugins/gramplet/PersonAttributes.py b/src/plugins/gramplet/PersonAttributes.py index 1a8ee5b39..d22b00eba 100644 --- a/src/plugins/gramplet/PersonAttributes.py +++ b/src/plugins/gramplet/PersonAttributes.py @@ -58,12 +58,11 @@ class PersonAttributes(Gramplet): def main(self): # return false finishes active_handle = self.get_active('Person') active_person = self.dbstate.db.get_person_from_handle(active_handle) - if not active_person: - return - + self.model.clear() - for attr in active_person.get_attribute_list(): - self.model.add((attr.get_type(), attr.get_value())) + if active_person: + for attr in active_person.get_attribute_list(): + self.model.add((attr.get_type(), attr.get_value())) def display_report(self, treeview): """ diff --git a/src/plugins/gramplet/PersonDetails.py b/src/plugins/gramplet/PersonDetails.py index b5dece1ce..42f019f7f 100644 --- a/src/plugins/gramplet/PersonDetails.py +++ b/src/plugins/gramplet/PersonDetails.py @@ -37,6 +37,7 @@ class PersonDetails(Gramplet): self.gui.get_container_widget().remove(self.gui.textview) self.gui.get_container_widget().add_with_viewport(self.gui.WIDGET) self.gui.WIDGET.show() + self.uistate.connect('nameformat-changed', self.update) def build_gui(self): """ @@ -84,7 +85,6 @@ class PersonDetails(Gramplet): def db_changed(self): self.dbstate.db.connect('person-update', self.update) - self.uistate.connect('nameformat-changed', self.update) self.update() def active_changed(self, handle): @@ -93,9 +93,15 @@ class PersonDetails(Gramplet): def main(self): # return false finishes active_handle = self.get_active('Person') active_person = self.dbstate.db.get_person_from_handle(active_handle) - if not active_person: - return + if active_person: + self.display_person(active_person) + else: + self.display_empty() + def display_person(self, active_person): + """ + Display details of the active person. + """ self.load_person_image(active_person) self.name.set_text(name_displayer.display(active_person)) self.display_parents(active_person) @@ -106,6 +112,24 @@ class PersonDetails(Gramplet): occupation_text = self.get_attribute(active_person, 'Occupation') self.occupation[1].set_text(occupation_text) + def display_empty(self): + """ + Display empty details when no person is selected. + """ + self.load_photo(None) + self.name.set_text(_('No active person')) + self.father[1].set_text(_('Unknown')) + self.mother[1].set_text(_('Unknown')) + self.birth[0].hide() + self.birth[1].hide() + self.baptism[0].hide() + self.baptism[1].hide() + self.death[0].hide() + self.death[1].hide() + self.burial[0].hide() + self.burial[1].hide() + self.occupation[1].set_text(_('Unknown')) + def display_parents(self, active_person): """ Display the parents of the active person. diff --git a/src/plugins/gramplet/PersonGallery.py b/src/plugins/gramplet/PersonGallery.py index 84676b42a..5b1caeffa 100644 --- a/src/plugins/gramplet/PersonGallery.py +++ b/src/plugins/gramplet/PersonGallery.py @@ -55,11 +55,10 @@ class PersonGallery(Gramplet): def main(self): # return false finishes active_handle = self.get_active('Person') active_person = self.dbstate.db.get_person_from_handle(active_handle) - if not active_person: - return - + self.clear_images() - self.load_person_images(active_person) + if active_person: + self.load_person_images(active_person) def clear_images(self): """ diff --git a/src/plugins/gramplet/PersonResidence.py b/src/plugins/gramplet/PersonResidence.py index 9992860d5..aa2e1bd9a 100644 --- a/src/plugins/gramplet/PersonResidence.py +++ b/src/plugins/gramplet/PersonResidence.py @@ -60,10 +60,15 @@ class PersonResidence(Gramplet): def main(self): # return false finishes active_handle = self.get_active('Person') active_person = self.dbstate.db.get_person_from_handle(active_handle) - if not active_person: - return self.model.clear() + if active_person: + self.display_person(active_person) + + def display_person(self, active_person): + """ + Display the residence events of the active person. + """ for event_ref in active_person.get_event_ref_list(): if int(event_ref.get_role()) == EventRoleType.PRIMARY: event = self.dbstate.db.get_event_from_handle(event_ref.ref)