Added new Attribute gramplet, quick view, and link (for gramplets)

svn: r11604
This commit is contained in:
Doug Blank 2009-01-10 16:31:45 +00:00
parent 832acac4c9
commit 6c1fd069f5
5 changed files with 129 additions and 0 deletions

View File

@ -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

View File

@ -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):

View File

@ -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"
)

View File

@ -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: <b>%s</b>") % 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,
)

View File

@ -12,6 +12,8 @@ pkgdata_PYTHON = \
AgeStats.py\
AncestorTree.py\
AncestorReport.py\
AttributeMatch.py\
AttributesGramplet.py\
BookReport.py\
CalculateEstimatedDates.py\
Calendar.py \