diff --git a/gramps/plugins/gramplet/ancestor.py b/gramps/plugins/gramplet/ancestor.py index c38c5544d..dfd9627bb 100644 --- a/gramps/plugins/gramplet/ancestor.py +++ b/gramps/plugins/gramplet/ancestor.py @@ -104,7 +104,10 @@ class Ancestor(Gramplet): def update_has_data(self): active_handle = self.get_active('Person') - self.set_has_data(self.get_has_data(active_handle)) + if active_handle: + self.set_has_data(self.get_has_data(active_handle)) + else: + self.set_has_data(False) def main(self): active_handle = self.get_active('Person') diff --git a/gramps/plugins/gramplet/attributes.py b/gramps/plugins/gramplet/attributes.py index e7d8bd623..56658c141 100644 --- a/gramps/plugins/gramplet/attributes.py +++ b/gramps/plugins/gramplet/attributes.py @@ -89,16 +89,21 @@ class PersonAttributes(Attributes): def update_has_data(self): active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def main(self): - active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - self.model.clear() - if active: - self.display_attributes(active) + active_handle = self.get_active('Person') + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + if active: + self.display_attributes(active) + else: + self.set_has_data(False) else: self.set_has_data(False) @@ -112,16 +117,21 @@ class EventAttributes(Attributes): def update_has_data(self): active_handle = self.get_active('Event') - active = self.dbstate.db.get_event_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_event_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def main(self): - active_handle = self.get_active('Event') - active = self.dbstate.db.get_event_from_handle(active_handle) - self.model.clear() - if active: - self.display_attributes(active) + active_handle = self.get_active('Event') + if active_handle: + active = self.dbstate.db.get_event_from_handle(active_handle) + if active: + self.display_attributes(active) + else: + self.set_has_data(False) else: self.set_has_data(False) @@ -135,16 +145,21 @@ class FamilyAttributes(Attributes): def update_has_data(self): active_handle = self.get_active('Family') - active = self.dbstate.db.get_family_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_family_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def main(self): - active_handle = self.get_active('Family') - active = self.dbstate.db.get_family_from_handle(active_handle) - self.model.clear() - if active: - self.display_attributes(active) + active_handle = self.get_active('Family') + if active_handle: + active = self.dbstate.db.get_family_from_handle(active_handle) + if active: + self.display_attributes(active) + else: + self.set_has_data(False) else: self.set_has_data(False) @@ -158,16 +173,20 @@ class MediaAttributes(Attributes): def update_has_data(self): active_handle = self.get_active('Media') - active = self.dbstate.db.get_object_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Media') - active = self.dbstate.db.get_object_from_handle(active_handle) - - self.model.clear() - if active: - self.display_attributes(active) + if active_handle: + active = self.dbstate.db.get_object_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.model.clear() + active_handle = self.get_active('Media') + if active_handle: + active = self.dbstate.db.get_object_from_handle(active_handle) + if active: + self.display_attributes(active) + else: + self.set_has_data(False) else: self.set_has_data(False) - diff --git a/gramps/plugins/gramplet/children.py b/gramps/plugins/gramplet/children.py index 58106d99b..dc943d543 100644 --- a/gramps/plugins/gramplet/children.py +++ b/gramps/plugins/gramplet/children.py @@ -105,8 +105,11 @@ class PersonChildren(Children): def update_has_data(self): active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def get_has_data(self, active_person): """ @@ -200,8 +203,11 @@ class FamilyChildren(Children): def update_has_data(self): active_handle = self.get_active('Family') - active = self.dbstate.db.get_family_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_family_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def get_has_data(self, active_family): """ diff --git a/gramps/plugins/gramplet/citations.py b/gramps/plugins/gramplet/citations.py index d260016e2..b40087d85 100644 --- a/gramps/plugins/gramplet/citations.py +++ b/gramps/plugins/gramplet/citations.py @@ -279,18 +279,23 @@ class PersonCitations(Citations): def update_has_data(self): active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + def main(self): - active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - self.model.clear() self.callman.unregister_all() - if active: - self.callman.register_obj(active) - self.display_citations(active) + active_handle = self.get_active('Person') + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + if active: + self.callman.register_obj(active) + self.display_citations(active) + else: + self.set_has_data(False) else: self.set_has_data(False) @@ -351,18 +356,23 @@ class EventCitations(Citations): def update_has_data(self): active_handle = self.get_active('Event') - active = self.dbstate.db.get_event_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - + if active_handle: + active = self.dbstate.db.get_event_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + def main(self): - active_handle = self.get_active('Event') - active = self.dbstate.db.get_event_from_handle(active_handle) - self.model.clear() self.callman.unregister_all() - if active: - self.callman.register_obj(active) - self.display_citations(active) + active_handle = self.get_active('Event') + if active_handle: + active = self.dbstate.db.get_event_from_handle(active_handle) + if active: + self.callman.register_obj(active) + self.display_citations(active) + else: + self.set_has_data(False) else: self.set_has_data(False) @@ -394,18 +404,23 @@ class FamilyCitations(Citations): def update_has_data(self): active_handle = self.get_active('Family') - active = self.dbstate.db.get_family_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - + if active_handle: + active = self.dbstate.db.get_family_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + def main(self): - active_handle = self.get_active('Family') - active = self.dbstate.db.get_family_from_handle(active_handle) - self.model.clear() self.callman.unregister_all() - if active: - self.callman.register_obj(active) - self.display_citations(active) + active_handle = self.get_active('Family') + if active_handle: + active = self.dbstate.db.get_family_from_handle(active_handle) + if active: + self.callman.register_obj(active) + self.display_citations(active) + else: + self.set_has_data(False) else: self.set_has_data(False) @@ -450,18 +465,23 @@ class PlaceCitations(Citations): def update_has_data(self): active_handle = self.get_active('Place') - active = self.dbstate.db.get_place_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - + if active_handle: + active = self.dbstate.db.get_place_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + def main(self): - active_handle = self.get_active('Place') - active = self.dbstate.db.get_place_from_handle(active_handle) - self.model.clear() self.callman.unregister_all() - if active: - self.callman.register_obj(active) - self.display_citations(active) + active_handle = self.get_active('Place') + if active_handle: + active = self.dbstate.db.get_place_from_handle(active_handle) + if active: + self.callman.register_obj(active) + self.display_citations(active) + else: + self.set_has_data(False) else: self.set_has_data(False) @@ -493,18 +513,23 @@ class MediaCitations(Citations): def update_has_data(self): active_handle = self.get_active('Media') - active = self.dbstate.db.get_object_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - + if active_handle: + active = self.dbstate.db.get_object_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + def main(self): - active_handle = self.get_active('Media') - active = self.dbstate.db.get_object_from_handle(active_handle) - self.model.clear() self.callman.unregister_all() - if active: - self.callman.register_obj(active) - self.display_citations(active) + active_handle = self.get_active('Media') + if active_handle: + active = self.dbstate.db.get_object_from_handle(active_handle) + if active: + self.callman.register_obj(active) + self.display_citations(active) + else: + self.set_has_data(False) else: self.set_has_data(False) diff --git a/gramps/plugins/gramplet/descendant.py b/gramps/plugins/gramplet/descendant.py index 866b3c0e9..99a715725 100644 --- a/gramps/plugins/gramplet/descendant.py +++ b/gramps/plugins/gramplet/descendant.py @@ -108,7 +108,10 @@ class Descendant(Gramplet): def update_has_data(self): active_handle = self.get_active('Person') - self.set_has_data(self.get_has_data(active_handle)) + if active_handle: + self.set_has_data(self.get_has_data(active_handle)) + else: + self.set_has_data(False) def main(self): active_handle = self.get_active('Person') diff --git a/gramps/plugins/gramplet/events.py b/gramps/plugins/gramplet/events.py index 85bfb6123..72df86aaf 100644 --- a/gramps/plugins/gramplet/events.py +++ b/gramps/plugins/gramplet/events.py @@ -168,8 +168,11 @@ class PersonEvents(Events): def update_has_data(self): active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def get_has_data(self, active_person): """ @@ -234,8 +237,11 @@ class FamilyEvents(Events): def update_has_data(self): active_handle = self.get_active('Family') - active = self.dbstate.db.get_family_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_family_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def get_has_data(self, active_family): """ diff --git a/gramps/plugins/gramplet/gallery.py b/gramps/plugins/gramplet/gallery.py index 7263be005..cec431b0a 100644 --- a/gramps/plugins/gramplet/gallery.py +++ b/gramps/plugins/gramplet/gallery.py @@ -96,16 +96,21 @@ class PersonGallery(Gallery): def update_has_data(self): active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def main(self): - active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - self.clear_images() - if active: - self.load_images(active) + active_handle = self.get_active('Person') + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + if active: + self.load_images(active) + else: + self.set_has_data(False) else: self.set_has_data(False) @@ -119,16 +124,21 @@ class FamilyGallery(Gallery): def update_has_data(self): active_handle = self.get_active('Family') - active = self.dbstate.db.get_family_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_family_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def main(self): - active_handle = self.get_active('Family') - active = self.dbstate.db.get_family_from_handle(active_handle) - self.clear_images() - if active: - self.load_images(active) + active_handle = self.get_active('Family') + if active_handle: + active = self.dbstate.db.get_family_from_handle(active_handle) + if active: + self.load_images(active) + else: + self.set_has_data(False) else: self.set_has_data(False) @@ -142,16 +152,21 @@ class EventGallery(Gallery): def update_has_data(self): active_handle = self.get_active('Event') - active = self.dbstate.db.get_event_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_event_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def main(self): - active_handle = self.get_active('Event') - active = self.dbstate.db.get_event_from_handle(active_handle) - self.clear_images() - if active: - self.load_images(active) + active_handle = self.get_active('Event') + if active_handle: + active = self.dbstate.db.get_event_from_handle(active_handle) + if active: + self.load_images(active) + else: + self.set_has_data(False) else: self.set_has_data(False) @@ -165,16 +180,21 @@ class PlaceGallery(Gallery): def update_has_data(self): active_handle = self.get_active('Place') - active = self.dbstate.db.get_place_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_place_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def main(self): - active_handle = self.get_active('Place') - active = self.dbstate.db.get_place_from_handle(active_handle) - self.clear_images() - if active: - self.load_images(active) + active_handle = self.get_active('Place') + if active_handle: + active = self.dbstate.db.get_place_from_handle(active_handle) + if active: + self.load_images(active) + else: + self.set_has_data(False) else: self.set_has_data(False) @@ -188,16 +208,21 @@ class SourceGallery(Gallery): def update_has_data(self): active_handle = self.get_active('Source') - active = self.dbstate.db.get_source_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_source_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def main(self): - active_handle = self.get_active('Source') - active = self.dbstate.db.get_source_from_handle(active_handle) - self.clear_images() - if active: - self.load_images(active) + active_handle = self.get_active('Source') + if active_handle: + active = self.dbstate.db.get_source_from_handle(active_handle) + if active: + self.load_images(active) + else: + self.set_has_data(False) else: self.set_has_data(False) @@ -211,16 +236,20 @@ class CitationGallery(Gallery): def update_has_data(self): active_handle = self.get_active('Citation') - active = self.dbstate.db.get_citation_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Citation') - active = self.dbstate.db.get_citation_from_handle(active_handle) - - self.clear_images() - if active: - self.load_images(active) + if active_handle: + active = self.dbstate.db.get_citation_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) else: self.set_has_data(False) + def main(self): + self.clear_images() + active_handle = self.get_active('Citation') + if active_handle: + active = self.dbstate.db.get_citation_from_handle(active_handle) + if active: + self.load_images(active) + else: + self.set_has_data(False) + else: + self.set_has_data(False) diff --git a/gramps/plugins/gramplet/mediapreview.py b/gramps/plugins/gramplet/mediapreview.py index 3849531b0..4dd4b6cbd 100644 --- a/gramps/plugins/gramplet/mediapreview.py +++ b/gramps/plugins/gramplet/mediapreview.py @@ -47,20 +47,26 @@ class MediaPreview(Gramplet): def update_has_data(self): active_handle = self.get_active('Media') - active_media = self.dbstate.db.get_object_from_handle(active_handle) - self.set_has_data(active_media is not None) + if active_handle: + active_media = self.dbstate.db.get_object_from_handle(active_handle) + self.set_has_data(active_media is not None) + else: + self.set_has_data(False) def main(self): active_handle = self.get_active('Media') - media = self.dbstate.db.get_object_from_handle(active_handle) - self.top.hide() - if media: - self.load_image(media) - self.set_has_data(True) + if active_handle: + media = self.dbstate.db.get_object_from_handle(active_handle) + self.top.hide() + if media: + self.load_image(media) + self.set_has_data(True) + else: + self.photo.set_image(None) + self.set_has_data(False) + self.top.show() else: - self.photo.set_image(None) self.set_has_data(False) - self.top.show() def load_image(self, media): """ diff --git a/gramps/plugins/gramplet/metadataviewer.py b/gramps/plugins/gramplet/metadataviewer.py index 6f2e147c2..ed7f1d8e2 100644 --- a/gramps/plugins/gramplet/metadataviewer.py +++ b/gramps/plugins/gramplet/metadataviewer.py @@ -44,19 +44,24 @@ class MetadataViewer(Gramplet): def main(self): active_handle = self.get_active('Media') - media = self.dbstate.db.get_object_from_handle(active_handle) - - if media: - full_path = media_path_full(self.dbstate.db, media.get_path()) - has_data = self.view.display_exif_tags(full_path) - self.set_has_data(has_data) + if active_handle: + media = self.dbstate.db.get_object_from_handle(active_handle) + if media: + full_path = media_path_full(self.dbstate.db, media.get_path()) + has_data = self.view.display_exif_tags(full_path) + self.set_has_data(has_data) + else: + self.set_has_data(False) else: self.set_has_data(False) def update_has_data(self): active_handle = self.get_active('Media') - active = self.dbstate.db.get_object_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_object_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def get_has_data(self, media): """ diff --git a/gramps/plugins/gramplet/notes.py b/gramps/plugins/gramplet/notes.py index e71d88274..6d6ba4d3e 100644 --- a/gramps/plugins/gramplet/notes.py +++ b/gramps/plugins/gramplet/notes.py @@ -143,16 +143,22 @@ class PersonNotes(Notes): def update_has_data(self): active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Person') + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) class EventNotes(Notes): @@ -165,16 +171,22 @@ class EventNotes(Notes): def update_has_data(self): active_handle = self.get_active('Event') - active = self.dbstate.db.get_event_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Event') - active = self.dbstate.db.get_event_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_event_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Event') + if active_handle: + active = self.dbstate.db.get_event_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) class FamilyNotes(Notes): @@ -187,16 +199,22 @@ class FamilyNotes(Notes): def update_has_data(self): active_handle = self.get_active('Family') - active = self.dbstate.db.get_family_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Family') - active = self.dbstate.db.get_family_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_family_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Family') + if active_handle: + active = self.dbstate.db.get_family_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) class PlaceNotes(Notes): @@ -209,16 +227,22 @@ class PlaceNotes(Notes): def update_has_data(self): active_handle = self.get_active('Place') - active = self.dbstate.db.get_place_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Place') - active = self.dbstate.db.get_place_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_place_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Place') + if active_handle: + active = self.dbstate.db.get_place_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) class SourceNotes(Notes): @@ -231,16 +255,22 @@ class SourceNotes(Notes): def update_has_data(self): active_handle = self.get_active('Source') - active = self.dbstate.db.get_source_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Source') - active = self.dbstate.db.get_source_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_source_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Source') + if active_handle: + active = self.dbstate.db.get_source_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) class CitationNotes(Notes): @@ -253,16 +283,22 @@ class CitationNotes(Notes): def update_has_data(self): active_handle = self.get_active('Citation') - active = self.dbstate.db.get_citation_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Citation') - active = self.dbstate.db.get_citation_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_citation_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Citation') + if active_handle: + active = self.dbstate.db.get_citation_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) class RepositoryNotes(Notes): @@ -275,16 +311,22 @@ class RepositoryNotes(Notes): def update_has_data(self): active_handle = self.get_active('Repository') - active = self.dbstate.db.get_repository_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Repository') - active = self.dbstate.db.get_repository_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_repository_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Repository') + if active_handle: + active = self.dbstate.db.get_repository_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) class MediaNotes(Notes): @@ -297,15 +339,20 @@ class MediaNotes(Notes): def update_has_data(self): active_handle = self.get_active('Media') - active = self.dbstate.db.get_object_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Media') - active = self.dbstate.db.get_object_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_object_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) else: - self.clear_text() self.set_has_data(False) + def main(self): + self.clear_text() + active_handle = self.get_active('Media') + if active_handle: + active = self.dbstate.db.get_object_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) + else: + self.set_has_data(False) diff --git a/gramps/plugins/gramplet/pedigreegramplet.py b/gramps/plugins/gramplet/pedigreegramplet.py index ce5d53d37..5b7d7c052 100644 --- a/gramps/plugins/gramplet/pedigreegramplet.py +++ b/gramps/plugins/gramplet/pedigreegramplet.py @@ -239,6 +239,8 @@ class PedigreeGramplet(Gramplet): self._generations = {} self.gui.buffer.set_text("") active_handle = self.get_active('Person') + if active_handle is None: + return active_person = self.dbstate.db.get_person_from_handle(active_handle) #no wrap in Gramplet self.no_wrap() diff --git a/gramps/plugins/gramplet/persondetails.py b/gramps/plugins/gramplet/persondetails.py index a44f60bc7..81d212546 100644 --- a/gramps/plugins/gramplet/persondetails.py +++ b/gramps/plugins/gramplet/persondetails.py @@ -90,20 +90,26 @@ class PersonDetails(Gramplet): def update_has_data(self): active_handle = self.get_active('Person') - active_person = self.dbstate.db.get_person_from_handle(active_handle) - self.set_has_data(active_person is not None) + if active_handle: + active_person = self.dbstate.db.get_person_from_handle(active_handle) + self.set_has_data(active_person is not None) + else: + self.set_has_data(False) def main(self): # return false finishes + self.display_empty() active_handle = self.get_active('Person') - active_person = self.dbstate.db.get_person_from_handle(active_handle) - self.top.hide() - if active_person: - self.display_person(active_person) - self.set_has_data(True) + if active_handle: + active_person = self.dbstate.db.get_person_from_handle(active_handle) + self.top.hide() + if active_person: + self.display_person(active_person) + self.set_has_data(True) + else: + self.set_has_data(False) + self.top.show() else: - self.display_empty() self.set_has_data(False) - self.top.show() def display_person(self, active_person): """ diff --git a/gramps/plugins/gramplet/personresidence.py b/gramps/plugins/gramplet/personresidence.py index 54eef58d4..28954a53b 100644 --- a/gramps/plugins/gramplet/personresidence.py +++ b/gramps/plugins/gramplet/personresidence.py @@ -58,8 +58,11 @@ class PersonResidence(Gramplet): def update_has_data(self): active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) def get_has_data(self, active_person): """ @@ -74,12 +77,14 @@ class PersonResidence(Gramplet): return False def main(self): # return false finishes - active_handle = self.get_active('Person') - active_person = self.dbstate.db.get_person_from_handle(active_handle) - self.model.clear() - if active_person: - self.display_person(active_person) + active_handle = self.get_active('Person') + if active_handle: + active_person = self.dbstate.db.get_person_from_handle(active_handle) + if active_person: + self.display_person(active_person) + else: + self.set_has_data(False) else: self.set_has_data(False) diff --git a/gramps/plugins/gramplet/placedetails.py b/gramps/plugins/gramplet/placedetails.py index 52652c7a0..00756d5eb 100644 --- a/gramps/plugins/gramplet/placedetails.py +++ b/gramps/plugins/gramplet/placedetails.py @@ -84,20 +84,26 @@ class PlaceDetails(Gramplet): def update_has_data(self): active_handle = self.get_active('Person') - active_person = self.dbstate.db.get_person_from_handle(active_handle) - self.set_has_data(active_person is not None) + if active_handle: + active_person = self.dbstate.db.get_person_from_handle(active_handle) + self.set_has_data(active_person is not None) + else: + self.set_has_data(False) def main(self): + self.display_empty() active_handle = self.get_active('Place') - place = self.dbstate.db.get_place_from_handle(active_handle) - self.top.hide() - if place: - self.display_place(place) - self.set_has_data(True) + if active_handle: + place = self.dbstate.db.get_place_from_handle(active_handle) + self.top.hide() + if place: + self.display_place(place) + self.set_has_data(True) + else: + self.set_has_data(False) + self.top.show() else: - self.display_empty() self.set_has_data(False) - self.top.show() def display_place(self, place): """ diff --git a/gramps/plugins/gramplet/relativegramplet.py b/gramps/plugins/gramplet/relativegramplet.py index 99abcd802..065087758 100644 --- a/gramps/plugins/gramplet/relativegramplet.py +++ b/gramps/plugins/gramplet/relativegramplet.py @@ -63,6 +63,8 @@ class RelativesGramplet(Gramplet): self.set_text("") database = self.dbstate.db active_handle = self.get_active('Person') + if not active_handle: + return active_person = self.dbstate.db.get_person_from_handle(active_handle) if not active_person: return diff --git a/gramps/plugins/gramplet/repositorydetails.py b/gramps/plugins/gramplet/repositorydetails.py index c13c8f280..15a27f942 100644 --- a/gramps/plugins/gramplet/repositorydetails.py +++ b/gramps/plugins/gramplet/repositorydetails.py @@ -78,21 +78,27 @@ class RepositoryDetails(Gramplet): self.connect_signal('Repository', self.update) def update_has_data(self): - active_handle = self.get_active('Person') - active_person = self.dbstate.db.get_person_from_handle(active_handle) - self.set_has_data(active_person is not None) + active_handle = self.get_active('Repository') + if active_handle: + repo = self.dbstate.db.get_repository_from_handle(active_handle) + self.set_has_data(repo is not None) + else: + self.set_has_data(False) def main(self): + self.display_empty() active_handle = self.get_active('Repository') - repo = self.dbstate.db.get_repository_from_handle(active_handle) - self.top.hide() - if repo: - self.display_repo(repo) - self.set_has_data(True) + if active_handle: + repo = self.dbstate.db.get_repository_from_handle(active_handle) + self.top.hide() + if repo: + self.display_repo(repo) + self.set_has_data(True) + else: + self.set_has_data(False) + self.top.show() else: - self.display_empty() self.set_has_data(False) - self.top.show() def display_repo(self, repo): """ diff --git a/gramps/plugins/gramplet/todo.py b/gramps/plugins/gramplet/todo.py index ecc37c89f..410e6a638 100644 --- a/gramps/plugins/gramplet/todo.py +++ b/gramps/plugins/gramplet/todo.py @@ -193,16 +193,22 @@ class PersonToDo(ToDo): def update_has_data(self): active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Person') - active = self.dbstate.db.get_person_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Person') + if active_handle: + active = self.dbstate.db.get_person_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) def created(self, handle): @@ -220,16 +226,22 @@ class EventToDo(ToDo): def update_has_data(self): active_handle = self.get_active('Event') - active = self.dbstate.db.get_event_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Event') - active = self.dbstate.db.get_event_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_event_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Event') + if active_handle: + active = self.dbstate.db.get_event_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) def created(self, handle): @@ -247,16 +259,22 @@ class FamilyToDo(ToDo): def update_has_data(self): active_handle = self.get_active('Family') - active = self.dbstate.db.get_family_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Family') - active = self.dbstate.db.get_family_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_family_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Family') + if active_handle: + active = self.dbstate.db.get_family_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) def created(self, handle): @@ -274,16 +292,22 @@ class PlaceToDo(ToDo): def update_has_data(self): active_handle = self.get_active('Place') - active = self.dbstate.db.get_place_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Place') - active = self.dbstate.db.get_place_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_place_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Place') + if active_handle: + active = self.dbstate.db.get_place_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) def created(self, handle): @@ -301,16 +325,22 @@ class SourceToDo(ToDo): def update_has_data(self): active_handle = self.get_active('Source') - active = self.dbstate.db.get_source_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Source') - active = self.dbstate.db.get_source_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_source_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Source') + if active_handle: + active = self.dbstate.db.get_source_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) def created(self, handle): @@ -328,16 +358,22 @@ class CitationToDo(ToDo): def update_has_data(self): active_handle = self.get_active('Citation') - active = self.dbstate.db.get_citation_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Citation') - active = self.dbstate.db.get_citation_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_citation_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Citation') + if active_handle: + active = self.dbstate.db.get_citation_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) def created(self, handle): @@ -355,16 +391,22 @@ class RepositoryToDo(ToDo): def update_has_data(self): active_handle = self.get_active('Repository') - active = self.dbstate.db.get_repository_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Repository') - active = self.dbstate.db.get_repository_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_repository_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Repository') + if active_handle: + active = self.dbstate.db.get_repository_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) def created(self, handle): @@ -382,16 +424,22 @@ class MediaToDo(ToDo): def update_has_data(self): active_handle = self.get_active('Media') - active = self.dbstate.db.get_object_from_handle(active_handle) - self.set_has_data(self.get_has_data(active)) - - def main(self): - active_handle = self.get_active('Media') - active = self.dbstate.db.get_object_from_handle(active_handle) - if active: - self.get_notes(active) + if active_handle: + active = self.dbstate.db.get_object_from_handle(active_handle) + self.set_has_data(self.get_has_data(active)) + else: + self.set_has_data(False) + + def main(self): + self.clear_text() + active_handle = self.get_active('Media') + if active_handle: + active = self.dbstate.db.get_object_from_handle(active_handle) + if active: + self.get_notes(active) + else: + self.set_has_data(False) else: - self.clear_text() self.set_has_data(False) def created(self, handle):