Enhanced Relationship Calculator
svn: r628
This commit is contained in:
parent
43852bf81c
commit
70632c4f2a
Binary file not shown.
@ -36,6 +36,7 @@ _ = intl.gettext
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def filter(person,index,list,map):
|
||||
if person == None:
|
||||
@ -53,45 +54,159 @@ def filter(person,index,list,map):
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def cousin(level,removed):
|
||||
def get_cousin(f,s,level,removed):
|
||||
if level == 1:
|
||||
root = " is the 1st cousin"
|
||||
if removed == 0:
|
||||
return "%s is the first cousin of %s." %(f,s)
|
||||
elif removed == 1:
|
||||
return "%s is the first cousin once removed of %s." %(f,s)
|
||||
elif removed == 2:
|
||||
return "%s is the first cousin twice removed of %s." %(f,s)
|
||||
else:
|
||||
return "%s is the first cousin %d times removed of %s." % (f,s,removed)
|
||||
elif level == 2:
|
||||
root = " is the 2nd cousin"
|
||||
if removed == 0:
|
||||
return "%s is the second cousin of %s." %(f,s)
|
||||
elif removed == 1:
|
||||
return "%s is the second cousin once removed of %s." %(f,s)
|
||||
elif removed == 2:
|
||||
return "%s is the second cousin twice removed of %s." %(f,s)
|
||||
else:
|
||||
return "%s is the second cousin %d times removed of %s." % (f,s,removed)
|
||||
elif level == 3:
|
||||
root = " is the 3rd cousin"
|
||||
if removed == 0:
|
||||
return "%s is the third cousin of %s." %(f,s)
|
||||
elif removed == 1:
|
||||
return "%s is the third cousin once removed of %s." %(f,s)
|
||||
elif removed == 2:
|
||||
return "%s is the third cousin twice removed of %s." %(f,s)
|
||||
else:
|
||||
return "%s is the third cousin %d times removed of %s." % (f,s,removed)
|
||||
else:
|
||||
root = " is the %dth cousin" % level
|
||||
if removed == 0:
|
||||
return "%s is the %dth cousin of %s." %(f,level,s)
|
||||
elif removed == 1:
|
||||
return "%s is the %dth cousin once removed of %s." %(f,level,s)
|
||||
elif removed == 2:
|
||||
return "%s is the %dth cousin twice removed of %s." %(f,level,s)
|
||||
else:
|
||||
return "%s is the %dth cousin %d times removed of %s." % (f,level,s,removed)
|
||||
|
||||
if removed == 0:
|
||||
root = root + " of "
|
||||
elif removed == 1:
|
||||
root = root + " once removed of "
|
||||
elif removed == 2:
|
||||
root = root + " twice removed of "
|
||||
else:
|
||||
root = root + " %d times removed of " % removed
|
||||
|
||||
return root
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def get_prefix(level,root):
|
||||
def get_father(f,s,level):
|
||||
if level == 1:
|
||||
return " is the " + root + " of "
|
||||
return "%s is the father of %s." % (s,f)
|
||||
elif level == 2:
|
||||
return " is the grand" + root + " of "
|
||||
return "%s is the grandfather of %s." % (s,f)
|
||||
elif level == 3:
|
||||
return " is the great grand" + root + " of "
|
||||
return "%s is the great grandfather of %s." % (s,f)
|
||||
elif level == 4:
|
||||
return " is the 2nd great grand" + root + " of "
|
||||
return "%s is the 2nd great grandfather of %s." % (s,f)
|
||||
elif level == 5:
|
||||
return " is the 3rd great grand" + root + " of "
|
||||
return "%s is the 3rd great grandfather of %s." % (s,f)
|
||||
else:
|
||||
return " is the %dth great grand%s of " % (level - 2,root)
|
||||
return "%s is the %dth great grandfather of %s." % (s,level-2,f)
|
||||
|
||||
def get_son(f,s,level):
|
||||
if level == 1:
|
||||
return "%s is the son of %s." % (s,f)
|
||||
elif level == 2:
|
||||
return "%s is the grandson of %s." % (s,f)
|
||||
elif level == 3:
|
||||
return "%s is the great grandson of %s." % (s,f)
|
||||
elif level == 4:
|
||||
return "%s is the 2nd great grandson of %s." % (s,f)
|
||||
elif level == 5:
|
||||
return "%s is the 3rd great grandson of %s." % (s,f)
|
||||
else:
|
||||
return "%s is the %dth great grandson of %s." % (s,level-2,f)
|
||||
|
||||
def get_mother(f,s,level):
|
||||
if level == 1:
|
||||
return "%s is the mother of %s." % (s,f)
|
||||
elif level == 2:
|
||||
return "%s is the grandmother of %s." % (s,f)
|
||||
elif level == 3:
|
||||
return "%s is the great grandmother of %s." % (s,f)
|
||||
elif level == 4:
|
||||
return "%s is the 2nd great grandmother of %s." % (s,f)
|
||||
elif level == 5:
|
||||
return "%s is the 3rd great grandmother of %s." % (s,f)
|
||||
else:
|
||||
return "%s is the %dth great grandmother of %s." % (s,level-2,f)
|
||||
|
||||
def get_daughter(f,s,level):
|
||||
if level == 1:
|
||||
return "%s is the daughter of %s." % (s,f)
|
||||
elif level == 2:
|
||||
return "%s is the granddaughter of %s." % (s,f)
|
||||
elif level == 3:
|
||||
return "%s is the great granddaughter of %s." % (s,f)
|
||||
elif level == 4:
|
||||
return "%s is the 2nd great granddaughter of %s." % (s,f)
|
||||
elif level == 5:
|
||||
return "%s is the 3rd great granddaughter of %s." % (s,f)
|
||||
else:
|
||||
return "%s is the %dth great granddaughter of %s." % (s,level-2,f)
|
||||
|
||||
def get_aunt(f,s,level):
|
||||
if level == 1:
|
||||
return "%s is the sister of %s." % (s,f)
|
||||
elif level == 2:
|
||||
return "%s is the aunt of %s." % (s,f)
|
||||
elif level == 3:
|
||||
return "%s is the grandaunt of %s." % (s,f)
|
||||
elif level == 4:
|
||||
return "%s is the great grandaunt of %s." % (s,f)
|
||||
elif level == 5:
|
||||
return "%s is the 2nd great grandaunt of %s." % (s,f)
|
||||
elif level == 6:
|
||||
return "%s is the 3rd great grandaunt of %s." % (s,f)
|
||||
else:
|
||||
return "%s is the %dth great grandaunt of %s." % (s,level-3,f)
|
||||
|
||||
def get_uncle(f,s,level):
|
||||
if level == 1:
|
||||
return "%s is the brother of %s." % (s,f)
|
||||
elif level == 2:
|
||||
return "%s is the uncle of %s." % (s,f)
|
||||
elif level == 3:
|
||||
return "%s is the granduncle of %s." % (s,f)
|
||||
elif level == 4:
|
||||
return "%s is the great granduncle of %s." % (s,f)
|
||||
elif level == 5:
|
||||
return "%s is the 2nd great granduncle of %s." % (s,f)
|
||||
elif level == 6:
|
||||
return "%s is the 3rd great granduncle of %s." % (s,f)
|
||||
else:
|
||||
return "%s is the %dth great granduncle of %s." % (s,level-3,f)
|
||||
|
||||
def get_nephew(f,s,level):
|
||||
if level == 1:
|
||||
return "%s is the nephew of %s." % (s,f)
|
||||
elif level == 2:
|
||||
return "%s is the grandnephew of %s." % (s,f)
|
||||
elif level == 3:
|
||||
return "%s is the great grandnephew of %s." % (s,f)
|
||||
elif level == 4:
|
||||
return "%s is the 2nd great grandnephew of %s." % (s,f)
|
||||
elif level == 5:
|
||||
return "%s is the 3rd great grandnephew of %s." % (s,f)
|
||||
else:
|
||||
return "%s is the %dth great grandnephew of %s." % (s,level-2,f)
|
||||
|
||||
def get_niece(f,s,level):
|
||||
if level == 1:
|
||||
return "%s is the niece of %s." % (s,f)
|
||||
elif level == 2:
|
||||
return "%s is the grandniece of %s." % (s,f)
|
||||
elif level == 3:
|
||||
return "%s is the great grandniece of %s." % (s,f)
|
||||
elif level == 4:
|
||||
return "%s is the 2nd great grandniece of %s." % (s,f)
|
||||
elif level == 5:
|
||||
return "%s is the 3rd great grandniece of %s." % (s,f)
|
||||
else:
|
||||
return "%s is the %dth great grandniece of %s." % (s,level-2,f)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -99,7 +214,6 @@ def get_prefix(level,root):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def runTool(database,person,callback):
|
||||
|
||||
RelCalc(database,person)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -125,17 +239,19 @@ class RelCalc:
|
||||
name_list = self.db.getPersonMap().values()
|
||||
name_list.sort(sort.by_last_name)
|
||||
index = 0
|
||||
for per in name_list:
|
||||
name = per.getPrimaryName().getName()
|
||||
birthday = per.getBirth().getDate()
|
||||
id = per.getId()
|
||||
self.people.freeze()
|
||||
for p in name_list:
|
||||
name = p.getPrimaryName().getName()
|
||||
birthday = p.getBirth().getDate()
|
||||
id = p.getId()
|
||||
self.people.append([name,id,birthday])
|
||||
self.people.set_row_data(index,per)
|
||||
self.people.set_row_data(index,p)
|
||||
index = index + 1
|
||||
self.people.thaw()
|
||||
|
||||
self.glade.signal_autoconnect({
|
||||
"on_close_clicked" : utils.destroy_passed_object,
|
||||
"on_apply_clicked" : self.on_apply_clicked
|
||||
"on_close_clicked" : utils.destroy_passed_object,
|
||||
"on_apply_clicked" : self.on_apply_clicked
|
||||
})
|
||||
|
||||
def on_apply_clicked(self,obj):
|
||||
@ -169,6 +285,7 @@ class RelCalc:
|
||||
secondName = other_person.getPrimaryName().getRegularName()
|
||||
|
||||
length = len(common)
|
||||
|
||||
if length == 1:
|
||||
person = common[0]
|
||||
secondRel = firstMap[person]
|
||||
@ -194,41 +311,32 @@ class RelCalc:
|
||||
msg = _("There is no relationship between %s and %s.")
|
||||
text = msg % (firstName,secondName)
|
||||
elif firstRel == 0:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
root = "father"
|
||||
else:
|
||||
root = "mother"
|
||||
if secondRel == 0:
|
||||
text = firstName + " and " + secondName + " are the same person."
|
||||
text = "%s and $s are the same person." % (firstName,secondName)
|
||||
elif other_person.getGender() == RelLib.Person.male:
|
||||
text = get_father(firstName,secondName,secondRel)
|
||||
else:
|
||||
text = secondName + get_prefix(secondRel,root) + firstName
|
||||
text = get_mother(firstName,secondName,secondRel)
|
||||
elif secondRel == 0:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
text = secondName + get_prefix(firstRel,"son") + firstName + "."
|
||||
text = get_son(firstName,secondName,firstRel)
|
||||
else:
|
||||
text = secondName + get_prefix(firstRel,"daughter") + firstName + "."
|
||||
text = get_daughter(firstName,secondName,firstRel)
|
||||
elif firstRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
root = "uncle"
|
||||
text = get_uncle(firstName,secondName,secondRel)
|
||||
else:
|
||||
root = "aunt"
|
||||
if secondRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
text = secondName + " is the brother of " + firstName + "."
|
||||
else:
|
||||
text = secondName + " is the sister of " + firstName + "."
|
||||
else:
|
||||
text = secondName + get_prefix(secondRel-1,root) + firstName + "."
|
||||
text = get_aunt(firstName,secondName,secondRel)
|
||||
elif secondRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
text = secondName + get_prefix(firstRel-1,"nephew") + firstName + "."
|
||||
text = get_nephew(firstName,secondName,firstRel-1)
|
||||
else:
|
||||
text = secondName + get_prefix(firstRel-1,"niece") + firstName + "."
|
||||
text = get_niece(firstName,secondName,firstRel-1)
|
||||
else:
|
||||
if secondRel > firstRel:
|
||||
text = secondName + cousin(firstRel-1,secondRel-firstRel) + firstName + "."
|
||||
text = get_cousin(firstName,secondName,firstRel-1,secondRel-firstRel)
|
||||
else:
|
||||
text = secondName + cousin(secondRel-1,firstRel-secondRel) + firstName + "."
|
||||
text = get_cousin(firstName,secondName,secondRel-1,firstRel-secondRel)
|
||||
|
||||
text1 = self.glade.get_widget("text1")
|
||||
text1.set_point(0)
|
||||
|
@ -13,30 +13,40 @@
|
||||
</project>
|
||||
|
||||
<widget>
|
||||
<class>GtkDialog</class>
|
||||
<class>GnomeDialog</class>
|
||||
<name>relcalc</name>
|
||||
<title>Gramps - Relationship Calculator</title>
|
||||
<type>GTK_WINDOW_TOPLEVEL</type>
|
||||
<position>GTK_WIN_POS_CENTER</position>
|
||||
<modal>True</modal>
|
||||
<allow_shrink>True</allow_shrink>
|
||||
<position>GTK_WIN_POS_NONE</position>
|
||||
<modal>False</modal>
|
||||
<allow_shrink>False</allow_shrink>
|
||||
<allow_grow>True</allow_grow>
|
||||
<auto_shrink>False</auto_shrink>
|
||||
<auto_close>False</auto_close>
|
||||
<hide_on_close>False</hide_on_close>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<child_name>Dialog:vbox</child_name>
|
||||
<name>dialog-vbox1</name>
|
||||
<child_name>GnomeDialog:vbox</child_name>
|
||||
<name>dialog-vbox2</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<spacing>8</spacing>
|
||||
<child>
|
||||
<padding>4</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<child_name>Dialog:action_area</child_name>
|
||||
<name>dialog-action_area1</name>
|
||||
<border_width>10</border_width>
|
||||
<homogeneous>True</homogeneous>
|
||||
<spacing>5</spacing>
|
||||
<class>GtkHButtonBox</class>
|
||||
<child_name>GnomeDialog:action_area</child_name>
|
||||
<name>dialog-action_area2</name>
|
||||
<layout_style>GTK_BUTTONBOX_END</layout_style>
|
||||
<spacing>8</spacing>
|
||||
<child_min_width>85</child_min_width>
|
||||
<child_min_height>27</child_min_height>
|
||||
<child_ipad_x>7</child_ipad_x>
|
||||
<child_ipad_y>0</child_ipad_y>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
@ -45,48 +55,30 @@
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHButtonBox</class>
|
||||
<name>hbuttonbox1</name>
|
||||
<layout_style>GTK_BUTTONBOX_END</layout_style>
|
||||
<spacing>30</spacing>
|
||||
<child_min_width>85</child_min_width>
|
||||
<child_min_height>27</child_min_height>
|
||||
<child_ipad_x>7</child_ipad_x>
|
||||
<child_ipad_y>0</child_ipad_y>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
<class>GtkButton</class>
|
||||
<name>button4</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_apply_clicked</handler>
|
||||
<last_modification_time>Sun, 16 Dec 2001 21:43:15 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button1</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_apply_clicked</handler>
|
||||
<last_modification_time>Tue, 06 Feb 2001 23:47:29 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button2</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_close_clicked</handler>
|
||||
<object>relcalc</object>
|
||||
<last_modification_time>Tue, 06 Feb 2001 23:47:17 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button5</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_close_clicked</handler>
|
||||
<object>relcalc</object>
|
||||
<last_modification_time>Sun, 16 Dec 2001 21:43:37 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
@ -144,8 +136,8 @@
|
||||
<widget>
|
||||
<class>GtkCList</class>
|
||||
<name>peopleList</name>
|
||||
<width>500</width>
|
||||
<height>150</height>
|
||||
<width>550</width>
|
||||
<height>200</height>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>select_row</name>
|
||||
@ -225,7 +217,7 @@
|
||||
<widget>
|
||||
<class>GtkText</class>
|
||||
<name>text1</name>
|
||||
<height>75</height>
|
||||
<height>100</height>
|
||||
<can_focus>True</can_focus>
|
||||
<editable>False</editable>
|
||||
<text></text>
|
||||
|
2030
src/po/de.po
2030
src/po/de.po
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user