diff --git a/po/POTFILES.in b/po/POTFILES.in index 5f9501306..3ab75f1eb 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -483,6 +483,7 @@ src/plugins/quickview/OnThisDay.py #src/plugins/quickview/Query.py src/plugins/quickview/quickview.gpr.py src/plugins/quickview/References.py +src/plugins/quickview/LinkReferences.py src/plugins/quickview/Reporef.py src/plugins/quickview/SameSurnames.py src/plugins/quickview/siblings.py diff --git a/src/Simple/_SimpleAccess.py b/src/Simple/_SimpleAccess.py index 2bb291802..5b0770c22 100644 --- a/src/Simple/_SimpleAccess.py +++ b/src/Simple/_SimpleAccess.py @@ -919,6 +919,17 @@ class SimpleAccess(object): else: return "Error: invalid object class: '%s'" % object_class + def get_link(self, object_class, prop, value): + """ + Given a object_class, prop, and value return the object. + object_class is "Person", "Source", etc. + prop is "gramps_id", or "handle" + value is a gramps_id or handle. + """ + if object_class in self.dbase.get_table_names(): + return self.dbase.get_table_metadata(object_class) \ + [prop + "_func"](value) + def by_date(event1, event2): """ Sort function that will compare two events by their dates. diff --git a/src/plugins/quickview/LinkReferences.py b/src/plugins/quickview/LinkReferences.py new file mode 100644 index 000000000..94bf65760 --- /dev/null +++ b/src/plugins/quickview/LinkReferences.py @@ -0,0 +1,73 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2010 Doug Blank +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# $Id: $ +# + +""" +Display link references for a note +""" + +from Simple import SimpleAccess, SimpleDoc, SimpleTable +from gen.lib import StyledTextTagType +from gen.ggettext import gettext as _ + +def run(database, document, obj): + """ + Display link references for this note. + """ + + # setup the simple access functions + sdb = SimpleAccess(database) + sdoc = SimpleDoc(document) + stab = SimpleTable(sdb) + + # display the title + sdoc.title(_("Link References for this note")) + sdoc.paragraph("\n") + stab.columns(_("Type"), _("Reference"), _("Link check")) + + tags = obj.text.get_tags() + + for styledtext_tag in tags: + if int(styledtext_tag.name) == StyledTextTagType.LINK: + if styledtext_tag.value.startswith("gramps://"): + object_class, prop, value = styledtext_tag.value[9:].split("/", 2) + tagtype = _("Gramps") + ref_obj = sdb.get_link(object_class, prop, value) + if ref_obj: + tagvalue = ref_obj + tagcheck = _("Ok") + else: + tagvalue = styledtext_tag.value + tagcheck = _("Failed: missing object") + else: + tagtype = _("Internet") + tagvalue = styledtext_tag.value + tagcheck = "" + stab.row(tagtype, tagvalue, tagcheck) + + if stab.get_row_count() > 0: + stab.write(sdoc) + else: + sdoc.paragraph(_("No link references for this note")) + sdoc.paragraph("") + sdoc.paragraph("") + diff --git a/src/plugins/quickview/Makefile.am b/src/plugins/quickview/Makefile.am index 990aefe55..16cd58e99 100644 --- a/src/plugins/quickview/Makefile.am +++ b/src/plugins/quickview/Makefile.am @@ -15,6 +15,7 @@ pkgdata_PYTHON = \ OnThisDay.py \ quickview.gpr.py \ References.py \ + LinkReferences.py \ Reporef.py \ SameSurnames.py\ siblings.py diff --git a/src/plugins/quickview/quickview.gpr.py b/src/plugins/quickview/quickview.gpr.py index 224fe77f9..7704041d2 100644 --- a/src/plugins/quickview/quickview.gpr.py +++ b/src/plugins/quickview/quickview.gpr.py @@ -219,6 +219,20 @@ for (category, item, trans) in refitems: runfunc = 'run_%s' % item ) +register(QUICKREPORT, + id = 'link_references', + name = _("Link References"), + description = _("Display link references for a note"), + version = '1.0', + gramps_target_version = '3.3', + status = STABLE, + fname = 'LinkReferences.py', + authors = ["Douglas Blank"], + authors_email = ["doug.blank@gmail.com"], + category = CATEGORY_QR_NOTE, + runfunc = 'run' +) + #------------------------------------------------------------------------ # # Show Repository Reference