diff --git a/po/POTFILES.in b/po/POTFILES.in index 34f9cec80..b0e8129a2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -241,6 +241,8 @@ src/plugins/all_events.py src/plugins/all_relations.py src/plugins/AncestorReport.py src/plugins/AncestorTree.py +src/plugins/AttributeMatch.py +src/plugins/AttributesGramplet.py src/plugins/BookReport.py src/plugins/CalculateEstimatedDates.py src/plugins/Calendar.py diff --git a/src/DataViews/GrampletView.py b/src/DataViews/GrampletView.py index 18fd1f908..72237fa69 100644 --- a/src/DataViews/GrampletView.py +++ b/src/DataViews/GrampletView.py @@ -817,6 +817,14 @@ class GuiGramplet: 'list of people', handles=handle) return True + elif link_type == 'Attribute': + if event.button == 1: # left mouse + if event.type == gtk.gdk._2BUTTON_PRESS: # double + run_quick_report_by_name(self.dbstate, + self.uistate, + 'attribute_match', + handle) + return True return False # did not handle event class MyScrolledWindow(gtk.ScrolledWindow): diff --git a/src/plugins/AttributeMatch.py b/src/plugins/AttributeMatch.py new file mode 100644 index 000000000..7401d96df --- /dev/null +++ b/src/plugins/AttributeMatch.py @@ -0,0 +1,55 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2009 Douglas S. 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 +# + +from ReportBase import CATEGORY_QR_MISC +from Simple import SimpleAccess, SimpleDoc, SimpleTable +from gen.plug import PluginManager + +def run(database, document, attribute, value=None): + sdb = SimpleAccess(database) + sdoc = SimpleDoc(document) + stab = SimpleTable(sdb) + sdoc.title(_("People who have the '%s' Attribute") % attribute) + sdoc.paragraph("") + stab.columns(_("Person"), str(attribute)) + matches = 0 + for person_handle in database.get_person_handles(sort_handles=False): + person = database.get_person_from_handle(person_handle) + matched = False + for attr in person.attribute_list: + if str(attr.type) == attribute: + stab.row(person, str(attr.get_value())) + matched = True + if matched: + matches += 1 + sdoc.paragraph(_("There are %d people with a matching attribute name.\n") % matches) + stab.write(sdoc) + +pmgr = PluginManager.get_instance() +pmgr.register_quick_report( + name = 'attribute_match', + category = CATEGORY_QR_MISC, # to run with attribute/value + run_func = run, + translated_name = _("Attribute Match"), + status = _("Stable"), + description= _("Display people with same attribute."), + author_name="Douglas S. Blank", + author_email="dblank@cs.brynmawr.edu" + ) diff --git a/src/plugins/AttributesGramplet.py b/src/plugins/AttributesGramplet.py new file mode 100644 index 000000000..95c189466 --- /dev/null +++ b/src/plugins/AttributesGramplet.py @@ -0,0 +1,62 @@ +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2009 Douglas S. 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 + +from DataViews import Gramplet, register +from BasicUtils import name_displayer + +class AttributesGramplet(Gramplet): + """ + Displays attributes of a person. + """ + def init(self): + self.set_text(_("No Family Tree loaded.")) + self.set_use_markup(True) + self.no_wrap() + + def db_changed(self): + self.dbstate.db.connect('person-edit', self.update) + self.update() + + def active_changed(self, handle): + self.update() + + def main(self): # return false finishes + self.set_text("") + active_person = self.dbstate.get_active_person() + if not active_person: + return + name = name_displayer.display(active_person) + self.render_text(_("Active person: %s") % name) + self.append_text("\n\n") + for attr in active_person.attribute_list: + # # text, type, data + self.link(str(attr.type), 'Attribute', str(attr.type)) + self.append_text(": %s\n" % attr.get_value()) + self.append_text("\n", scroll_to="begin") + +register(type="gramplet", + name="Attributes Gramplet", + tname=_("Attributes Gramplet"), + height=150, + expand=True, + content = AttributesGramplet, + title=_("Attributes"), + detached_width = 325, + detached_height = 250, + ) + diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index b66c47f55..dd233bf83 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -12,6 +12,8 @@ pkgdata_PYTHON = \ AgeStats.py\ AncestorTree.py\ AncestorReport.py\ + AttributeMatch.py\ + AttributesGramplet.py\ BookReport.py\ CalculateEstimatedDates.py\ Calendar.py \