* src/plugins/RelCalc.py: Use name display preferences throughout;

collapse unique entries in the common ancestors list.


svn: r7276
This commit is contained in:
Alex Roitman 2006-08-27 19:46:11 +00:00
parent 9a0843c4c1
commit 8e1179b16d
2 changed files with 27 additions and 15 deletions

View File

@ -1,4 +1,6 @@
2006-08-27 Alex Roitman <shura@gramps-project.org> 2006-08-27 Alex Roitman <shura@gramps-project.org>
* src/plugins/RelCalc.py: Use name display preferences throughout;
collapse unique entries in the common ancestors list.
* src/plugins/TestcaseGenerator.py: Bring somewhat up to date. * src/plugins/TestcaseGenerator.py: Bring somewhat up to date.
* NEWS: New release name. * NEWS: New release name.

View File

@ -29,6 +29,10 @@
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import os import os
from gettext import gettext as _ from gettext import gettext as _
try:
set()
except NameError:
from sets import Set as set
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -93,13 +97,13 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
glade_file = "%s/relcalc.glade" % base glade_file = "%s/relcalc.glade" % base
self.glade = gtk.glade.XML(glade_file,"relcalc","gramps") self.glade = gtk.glade.XML(glade_file,"relcalc","gramps")
name = self.person.get_primary_name().get_regular_name() name = NameDisplay.displayer.display(self.person)
self.title = _('Relationship calculator: %(person_name)s') % { self.title = _('Relationship calculator: %(person_name)s'
'person_name' : name } ) % {'person_name' : name}
window = self.glade.get_widget('relcalc') window = self.glade.get_widget('relcalc')
self.set_window(window,self.glade.get_widget('title'), self.set_window(window,self.glade.get_widget('title'),
_('Relationship to %(person_name)s') \ _('Relationship to %(person_name)s'
% {'person_name' : name }, ) % {'person_name' : name },
self.title) self.title)
self.tree = self.glade.get_widget("peopleList") self.tree = self.glade.get_widget("peopleList")
@ -118,7 +122,8 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
if not pair[0]: if not pair[0]:
continue continue
name = column_names[pair[1]] name = column_names[pair[1]]
column = gtk.TreeViewColumn(name, gtk.CellRendererText(), markup=pair[1]) column = gtk.TreeViewColumn(name, gtk.CellRendererText(),
markup=pair[1])
column.set_resizable(True) column.set_resizable(True)
column.set_min_width(60) column.set_min_width(60)
column.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY) column.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY)
@ -145,7 +150,10 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
other_person = self.db.get_person_from_handle(handle) other_person = self.db.get_person_from_handle(handle)
if other_person != None: if other_person != None:
(rel_string,common) = self.relationship.get_relationship(self.person,other_person) (rel_string,common) = self.relationship.get_relationship(
self.person,other_person)
# A quick way to get unique list
common = list(set(common))
length = len(common) length = len(common)
else: else:
length = 0 length = 0
@ -154,22 +162,23 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
commontext = "" commontext = ""
elif length == 1: elif length == 1:
person = self.db.get_person_from_handle(common[0]) person = self.db.get_person_from_handle(common[0])
name = person.get_primary_name().get_regular_name() name = NameDisplay.displayer.display(person)
commontext = " " + _("Their common ancestor is %s.") % name commontext = " " + _("Their common ancestor is %s.") % name
elif length == 2: elif length == 2:
p1 = self.db.get_person_from_handle(common[0]) p1 = self.db.get_person_from_handle(common[0])
p2 = self.db.get_person_from_handle(common[1]) p2 = self.db.get_person_from_handle(common[1])
commontext = " " + _("Their common ancestors are %s and %s.") % \ p1str = NameDisplay.displayer.display(p1)
(p1.get_primary_name().get_regular_name(),\ p2str = NameDisplay.displayer.display(p2)
p2.get_primary_name().get_regular_name()) commontext = " " + _("Their common ancestors are %s and %s."
) % (p1str,p2str)
elif length > 2: elif length > 2:
index = 0 index = 0
commontext = " " + _("Their common ancestors are : ") commontext = " " + _("Their common ancestors are: ")
for person_handle in common: for person_handle in common:
person = self.db.get_person_from_handle(person_handle) person = self.db.get_person_from_handle(person_handle)
if index != 0: if index != 0:
commontext = commontext + ", " commontext = commontext + ", "
commontext = commontext + person.get_primary_name().get_regular_name() commontext = commontext + NameDisplay.displayer.display(person)
index = index + 1 index = index + 1
commontext = commontext + "." commontext = commontext + "."
else: else:
@ -189,8 +198,9 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
rstr = _("%(person)s and %(active_person)s are not related.") % { rstr = _("%(person)s and %(active_person)s are not related.") % {
'person' : p2, 'active_person' : p1 } 'person' : p2, 'active_person' : p1 }
else: else:
rstr = _("%(person)s is the %(relationship)s of %(active_person)s.") % { rstr = _("%(person)s is the %(relationship)s of %(active_person)s."
'person' : p2, 'relationship' : rel_string, 'active_person' : p1 } ) % {'person' : p2, 'relationship' : rel_string,
'active_person' : p1 }
text1.set_text("%s %s" % (rstr, commontext)) text1.set_text("%s %s" % (rstr, commontext))