From a36a2a36e6d1cb2b260f8456659a341a95965145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Sat, 13 Dec 2014 15:39:06 +0100 Subject: [PATCH] Enable Attributes gramplet support on Source/Citation bars; not backported yet because of #8144 --- gramps/plugins/gramplet/attributes.py | 56 +++++++++++++++++++++++++ gramps/plugins/gramplet/gramplet.gpr.py | 28 +++++++++++++ 2 files changed, 84 insertions(+) diff --git a/gramps/plugins/gramplet/attributes.py b/gramps/plugins/gramplet/attributes.py index 56658c141..5e6c2505d 100644 --- a/gramps/plugins/gramplet/attributes.py +++ b/gramps/plugins/gramplet/attributes.py @@ -190,3 +190,59 @@ class MediaAttributes(Attributes): self.set_has_data(False) else: self.set_has_data(False) + +class SourceAttributes(Attributes): + """ + Displays the attributes of a source object. + """ + def db_changed(self): + self.dbstate.db.connect('source-update', self.update) + self.connect_signal('Source', self.update) + + def update_has_data(self): + active_handle = self.get_active('Source') + 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.model.clear() + active_handle = self.get_active('Source') + if active_handle: + active = self.dbstate.db.get_source_from_handle(active_handle) + if active: + self.display_attributes(active) + else: + self.set_has_data(False) + else: + self.set_has_data(False) + +class CitationAttributes(Attributes): + """ + Displays the attributes of a citation object. + """ + def db_changed(self): + self.dbstate.db.connect('citation-update', self.update) + self.connect_signal('Citation', self.update) + + def update_has_data(self): + active_handle = self.get_active('Citation') + 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.model.clear() + active_handle = self.get_active('Citation') + if active_handle: + active = self.dbstate.db.get_citation_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/gramplet.gpr.py b/gramps/plugins/gramplet/gramplet.gpr.py index 46f6b54e5..5b2138e4f 100644 --- a/gramps/plugins/gramplet/gramplet.gpr.py +++ b/gramps/plugins/gramplet/gramplet.gpr.py @@ -604,6 +604,34 @@ register(GRAMPLET, navtypes=["Media"], ) +register(GRAMPLET, + id="Source Attributes", + name=_("Source Attributes"), + description = _("Gramplet showing the attributes of a source object"), + version="1.0.0", + gramps_target_version=MODULE_VERSION, + status = STABLE, + fname="attributes.py", + height=200, + gramplet = 'SourceAttributes', + gramplet_title=_("Attributes"), + navtypes=["Source"], + ) + +register(GRAMPLET, + id="Citation Attributes", + name=_("Citation Attributes"), + description = _("Gramplet showing the attributes of a citation object"), + version="1.0.0", + gramps_target_version=MODULE_VERSION, + status = STABLE, + fname="attributes.py", + height=200, + gramplet = 'CitationAttributes', + gramplet_title=_("Attributes"), + navtypes=["Citation"], + ) + register(GRAMPLET, id="Person Notes", name=_("Person Notes"),