2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# count_anc.py - Ancestor counting plugin for gramps
|
|
|
|
#
|
|
|
|
# Copyright (C) 2001 Jesper Zedlitz
|
2004-05-07 07:50:39 +05:30
|
|
|
# Copyright (C) 2004 Donald Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2004-05-07 07:50:39 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"View/Number of ancestors"
|
|
|
|
|
|
|
|
import os
|
|
|
|
import Utils
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
from gnome.ui import *
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
def report(database,person):
|
|
|
|
try:
|
|
|
|
CountAncestors(database,person)
|
|
|
|
except:
|
|
|
|
import DisplayTrace
|
|
|
|
DisplayTrace.DisplayTrace()
|
|
|
|
|
|
|
|
class CountAncestors:
|
|
|
|
|
|
|
|
def __init__(self,database,person):
|
|
|
|
|
|
|
|
text = ""
|
2002-12-14 10:37:09 +05:30
|
|
|
glade_file = "%s/summary.glade" % os.path.dirname(__file__)
|
2003-08-17 07:44:33 +05:30
|
|
|
topDialog = gtk.glade.XML(glade_file,"summary","gramps")
|
2002-10-20 19:55:16 +05:30
|
|
|
topDialog.signal_autoconnect({
|
|
|
|
"destroy_passed_object" : Utils.destroy_passed_object,
|
|
|
|
})
|
|
|
|
thisgen = []
|
|
|
|
allgen = []
|
2004-05-07 07:50:39 +05:30
|
|
|
thisgen.append(person.get_id())
|
2004-02-14 11:10:30 +05:30
|
|
|
title = _("Number of ancestors of \"%s\" by generation") % person.get_primary_name().get_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
text = text + title + ':\n'
|
2004-05-07 07:50:39 +05:30
|
|
|
thisgensize = 1
|
|
|
|
gen = 1
|
|
|
|
while thisgensize > 0:
|
|
|
|
thisgensize = 0
|
|
|
|
if thisgen:
|
|
|
|
thisgensize = len( thisgen )
|
|
|
|
gen = gen - 1
|
2002-10-20 19:55:16 +05:30
|
|
|
if thisgensize == 1 :
|
|
|
|
text = text + _("Generation %d has 1 individual.\n") % (gen)
|
|
|
|
else:
|
|
|
|
text = text + _("Generation %d has %d individuals.\n") % (gen, thisgensize)
|
|
|
|
temp = thisgen
|
|
|
|
thisgen = []
|
2004-04-28 09:36:25 +05:30
|
|
|
for person_id in temp:
|
* src/RelLib.py (try_to_find_person_from_id): Remove transaction;
(try_to_find_source_from_id, try_to_find_object_from_id,
try_to_find_place_from_id): Add functions.
* src/plugins/WriteCD.py, src/plugins/WritePkg.py,
src/plugins/WebPage.py, src/plugins/Verify.py,
src/plugins/TimeLine.py, src/plugins/Summary.py,
src/plugins/SoundGen.py, src/plugins/RelGraph.py,
src/plugins/RelCalc.py, src/plugins/PatchNames.py,
src/plugins/Merge.py, src/plugins/IndivSummary.py,
src/plugins/IndivComplete.py, src/plugins/GraphViz.py,
src/plugins/FtmStyleDescendants.py,
src/plugins/FtmStyleAncestors.py, src/plugins/FilterEditor.py,
src/plugins/FanChart.py, src/plugins/FamilyGroup.py,
src/plugins/EventCmp.py, src/plugins/DetDescendantReport.py,
src/plugins/DetAncestralReport.py, src/plugins/DescendReport.py,
src/plugins/Desbrowser.py, src/plugins/CountAncestors.py,
src/plugins/Check.py, src/plugins/ChangeTypes.py,
src/plugins/BookReport.py, src/plugins/Ancestors.py,
src/plugins/AncestorReport.py, src/plugins/AncestorChart.py,
src/plugins/AncestorChart2.py, src/Relationship.py,
src/Sort.py, src/GenericFilter.py, src/SubstKeywords.py,
src/GraphLayout.py: Switch from find_* to try_to_find_* methods.
svn: r3191
2004-05-26 07:35:02 +05:30
|
|
|
person = database.try_to_find_person_from_id(person_id)
|
2004-04-28 09:36:25 +05:30
|
|
|
family_id = person.get_main_parents_family_id()
|
|
|
|
if family_id:
|
|
|
|
family = database.find_family_from_id(family_id)
|
2004-05-07 07:50:39 +05:30
|
|
|
father_id = family.get_father_id()
|
|
|
|
mother_id = family.get_mother_id()
|
|
|
|
if father_id:
|
|
|
|
thisgen.append(father_id)
|
|
|
|
if mother_id:
|
|
|
|
thisgen.append(mother_id)
|
2002-10-20 19:55:16 +05:30
|
|
|
allgen = allgen + thisgen
|
|
|
|
|
2004-05-07 07:50:39 +05:30
|
|
|
text = text + _("Total ancestors in generations %d to -1 is %d.\n") % (gen, len(allgen))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
top = topDialog.get_widget("summary")
|
|
|
|
textwindow = topDialog.get_widget("textwindow")
|
2003-05-02 05:05:27 +05:30
|
|
|
topDialog.get_widget("title").set_text(title)
|
2002-12-14 10:37:09 +05:30
|
|
|
textwindow.get_buffer().set_text(text)
|
2002-10-20 19:55:16 +05:30
|
|
|
top.show()
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from Plugins import register_report
|
|
|
|
|
|
|
|
register_report(
|
|
|
|
report,
|
|
|
|
_("Number of ancestors"),
|
|
|
|
category=_("View"),
|
|
|
|
description=_("Counts number of ancestors of selected person")
|
|
|
|
)
|
|
|
|
|