Autoseeding of children names

svn: r683
This commit is contained in:
Don Allingham 2002-01-06 21:35:17 +00:00
parent 0895aceb95
commit 0e34e2cfe4
10 changed files with 244 additions and 40 deletions

View File

@ -33,7 +33,6 @@ from TextDoc import *
from latin_utf8 import latin_to_utf8
import const
import string
from utils import fl2txt
#-------------------------------------------------------------------------
#
@ -81,16 +80,14 @@ class AbiWordDoc(TextDoc):
self.f.write('orientation="portrait" ')
else:
self.f.write('orientation="landscape" ')
self.f.write('width="%s" ' % fl2txt("%.4f",self.width/2.54))
self.f.write('height="%s" ' % fl2txt("%.4f",self.height/2.54))
self.f.write('width="%.4f" ' self.width/2.54)
self.f.write('height="%.4f" ' % self.height/2.54)
self.f.write('units="inch" page-scale="1.000000"/>\n')
self.f.write('<section ')
rmargin = float(self.rmargin)/2.54
lmargin = float(self.lmargin)/2.54
self.f.write('props="page-margin-right:%sin; ' % \
fl2txt("%.4f",rmargin))
self.f.write('page-margin-left:%sin"' % \
fl2txt("%.4f",lmargin))
self.f.write('props="page-margin-right:%.4fin; ' % rmargin)
self.f.write('page-margin-left:%.4fin"' % lmargin)
self.f.write('>\n')
def close(self):
@ -142,10 +139,8 @@ class AbiWordDoc(TextDoc):
self.f.write('<image dataid="')
self.f.write(tag)
width = fl2txt("%.3f",act_width)
height = fl2txt("%.3f",act_height)
self.f.write('" props="width:%sin; ' % width)
self.f.write('height:%sin"/>' % height)
self.f.write('" props="width:%.3fin; ' % act_width)
self.f.write('height:%.3fin"/>' % act_height)
def start_paragraph(self,style_name,leader=None):
style = self.style_list[style_name]
@ -159,13 +154,13 @@ class AbiWordDoc(TextDoc):
self.f.write('text-align:center;')
else:
self.f.write('text-align:justify;')
rmargin = fl2txt("%.4f",float(style.get_right_margin())/2.54)
lmargin = fl2txt("%.4f",float(style.get_left_margin())/2.54)
indent = fl2txt("%.4f",float(style.get_first_indent())/2.54)
self.f.write(' margin-right:%sin;' % rmargin)
self.f.write(' margin-left:%sin;' % lmargin)
self.f.write(' tabstops:%sin/L;' % lmargin)
self.f.write(' text-indent:%sin' % indent)
rmargin = float(style.get_right_margin())/2.54
lmargin = float(style.get_left_margin())/2.54
indent = float(style.get_first_indent())/2.54
self.f.write(' margin-right:%.4fin;' % rmargin)
self.f.write(' margin-left:%.4fin;' % lmargin)
self.f.write(' tabstops:%.4fin/L;' % lmargin)
self.f.write(' text-indent:%.4fin' % indent)
self.f.write('">')
font = style.get_font()
self.f.write('<c props="font-family:')

View File

@ -53,6 +53,13 @@ import ListColors
from intl import gettext
_ = gettext
_surname_styles = [
_("North American (Father's surname)"),
_("None"),
_("Latin American (Combination of mother's and father's surname)"),
_("Icelandic (Father's surname with son/daughter indicator"),
]
_date_format_list = [
_("Month Day, Year"),
_("MON Day, Year"),
@ -112,6 +119,7 @@ toolbar = 2
calendar = 0
paper_preference = None
output_preference = None
lastnamegen = None
report_dir = "./"
web_dir = "./"
db_dir = "./"
@ -187,6 +195,7 @@ def loadConfig(call):
global _callback
global paper_preference
global output_preference
global lastnamegen
global report_dir
global web_dir
global db_dir
@ -228,6 +237,7 @@ def loadConfig(call):
dateEntry = get_int("/gramps/config/dateEntry")
paper_preference = get_string("/gramps/config/paperPreference")
output_preference = get_string("/gramps/config/outputPreference")
lastnamegen = get_int("/gramps/config/surnameGuessing")
_name_format = get_int("/gramps/config/nameFormat")
iprefix = get_string("/gramps/config/iprefix")
@ -348,6 +358,9 @@ def loadConfig(call):
set_format_code(dateFormat)
Date.entryCode = dateEntry
if lastnamegen == None or lastnamegen == 0:
lastnamegen = 0
if _name_format == None or _name_format == 0:
_name_format = 0
nameof = utils.normal_name
@ -461,7 +474,8 @@ def on_propertybox_apply(obj,page):
global report_dir
global web_dir
global db_dir
global lastnamegen
if page != -1:
return
@ -593,6 +607,10 @@ def on_propertybox_apply(obj,page):
nameof = name_tuple[1]
set_int("/gramps/config/nameFormat",active_name)
format_menu = prefsTop.get_widget("lastnamegen").get_menu()
lastnamegen = format_menu.get_active().get_data(DATA)
set_int("/gramps/config/surnameGuessing",lastnamegen)
name = prefsTop.get_widget("resname").get_text()
addr = prefsTop.get_widget("resaddr").get_text()
city = prefsTop.get_widget("rescity").get_text()
@ -784,6 +802,20 @@ def display_preferences_box(db):
menu.set_active(choice)
paper_obj.set_menu(menu)
lastnamegen_obj = prefsTop.get_widget("lastnamegen")
menu = gtk.GtkMenu()
choice = 0
for index in range(0,len(_surname_styles)):
name = _surname_styles[index]
item = gtk.GtkMenuItem(name)
item.set_data(OBJECT,pbox)
item.set_data(DATA,index)
item.connect("activate", on_format_toggled)
item.show()
menu.append(item)
menu.set_active(lastnamegen)
lastnamegen_obj.set_menu(menu)
output_obj = prefsTop.get_widget("output_format")
menu = gtk.GtkMenu()
choice = 0

View File

@ -168,12 +168,11 @@ class HtmlDoc(TextDoc):
self.file_header = top
def build_style_declaration(self):
fl2txt = utils.fl2txt
text = ['<style type="text/css">\n<!--']
for key in self.cell_styles.keys():
style = self.cell_styles[key]
pad = fl2txt("%.3fcm ",style.get_padding())
pad = "%.3fcm" % style.get_padding()
top = bottom = left = right = 'none'
if style.get_top_border():
top = 'thin solid #000000'

View File

@ -26,8 +26,6 @@ from TextDoc import *
from latin_utf8 import latin_to_utf8
import const
import utils
cnv = utils.fl2txt
try:
import PIL.Image
@ -115,7 +113,7 @@ class OpenOfficeDoc(TextDoc):
self.f.write('<style:style style:name="' + style_name + '" ')
self.f.write('style:family="table">\n')
table_width = float(self.get_usable_width())
table_width_str = cnv("%.4f",table_width)
table_width_str = "%.4f" % table_width
self.f.write('<style:properties style:width="%scm" '%table_width_str)
self.f.write('/>\n')
self.f.write('</style:style>\n')

View File

@ -44,6 +44,7 @@ import const
import sort
import utils
import Config
import string
class SelectChild:
@ -206,7 +207,7 @@ class SelectChild:
class NewChild:
def __init__(self,db,family,person,update):
def __init__(self,db,family,person,update,autoname=3):
self.db = db
self.person = person
self.family = family
@ -215,10 +216,22 @@ class NewChild:
self.xml = libglade.GladeXML(const.gladeFile,"addChild")
self.xml.signal_autoconnect({
"on_addchild_ok_clicked" : self.on_addchild_ok_clicked,
"on_combo_insert_text" : utils.combo_insert_text,
"destroy_passed_object" : utils.destroy_passed_object
"on_combo_insert_text" : self.combo_insert_text,
"on_male_toggled" : self.on_male_toggled,
"on_female_toggled" : self.on_female_toggled,
"on_gender_toggled" : self.on_gender_toggled,
"destroy_passed_object" : utils.destroy_passed_object
})
if autoname == 0:
self.update_surname = self.north_american
elif autoname == 2:
self.update_surname = self.latin_american
elif autoname == 3:
self.update_surname = self.icelandic
else:
self.update_surname = self.no_name
self.mrel = self.xml.get_widget("mrel")
self.frel = self.xml.get_widget("frel")
self.top = self.xml.get_widget("addChild")
@ -226,13 +239,7 @@ class NewChild:
self.given = self.xml.get_widget("childGiven")
utils.attach_surnames(self.xml.get_widget("surname_combo"))
surname = ""
if self.person.getGender() == Person.male:
surname = self.person.getPrimaryName().getSurname()
elif self.family:
f = self.family.getFather()
if f:
surname = f.getPrimaryName().getSurname()
self.surname.set_text(self.update_surname(2))
if self.family:
father = self.family.getFather()
@ -258,7 +265,6 @@ class NewChild:
self.xml.get_widget("mlabel").set_text(label)
self.xml.get_widget("fcombo").set_sensitive(0)
self.surname.set_text(surname)
self.mrel.set_text(_("Birth"))
self.frel.set_text(_("Birth"))
@ -268,7 +274,65 @@ class NewChild:
self.top.editable_enters(self.mrel)
self.top.editable_enters(self.frel)
self.top.show()
def on_male_toggled(self,obj):
if obj.get_active():
txt = self.surname.get_text()
if txt == "" or txt == self.update_surname(1):
self.surname.set_text(self.update_surname(0))
def on_female_toggled(self,obj):
if obj.get_active():
txt = self.surname.get_text()
if txt == "" or txt == self.update_surname(0):
self.surname.set_text(self.update_surname(1))
def on_gender_toggled(self,obj):
pass
def combo_insert_text(self,combo,new_text,new_text_len,i_dont_care):
utils.combo_insert_text(combo,new_text,new_text_len,i_dont_care)
def north_american(self,val):
if self.person.getGender() == Person.male:
return self.person.getPrimaryName().getSurname()
elif self.family:
f = self.family.getFather()
if f:
return f.getPrimaryName().getSurname()
return ""
def no_name(self,val):
return ""
def latin_american(self,val):
if self.family:
father = self.family.getFather()
mother = self.family.getMother()
if not father or not mother:
return ""
fsn = father.getPrimaryName().getSurname()
msn = mother.getPrimaryName().getSurname()
if not father or not mother:
return ""
return "%s %s" % (string.split(fsn)[0],string.split(msn)[0])
else:
return ""
def icelandic(self,val):
if self.person.getGender() == Person.male:
surname = self.person.getPrimaryName().getSurname()
elif self.family:
f = self.family.getFather()
if f:
surname = f.getPrimaryName().getSurname()
if val == 0:
return "%ssson" % surname
elif val == 1:
return "%sdóttir" % surname
else:
return ""
def on_addchild_ok_clicked(self,obj):
surname = self.surname.get_text()

View File

@ -2695,6 +2695,107 @@ A4
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox36</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkFrame</class>
<name>frame19</name>
<border_width>5</border_width>
<label>Customization</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkTable</class>
<name>table29</name>
<rows>3</rows>
<columns>3</columns>
<homogeneous>False</homogeneous>
<row_spacing>0</row_spacing>
<column_spacing>0</column_spacing>
<widget>
<class>GtkLabel</class>
<name>label219</name>
<label>Surname Guessing</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>3</xpad>
<ypad>3</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>lastnamegen</name>
<can_focus>True</can_focus>
<items>
</items>
<initial_choice>0</initial_choice>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
</widget>
<widget>
<class>Placeholder</class>
</widget>
<widget>
<class>Placeholder</class>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label218</name>
<label>Special</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>

View File

@ -91,7 +91,7 @@ gtkrcFile = "%s/gtkrc" % rootDir
#
#-------------------------------------------------------------------------
progName = "gramps"
version = "0.7.1pre-snap20020101"
version = "0.7.1pre-snap20020106"
copyright = "© 2001 Donald N. Allingham"
authors = ["Donald N. Allingham", "David Hampton"]
comments = _("Gramps (Genealogical Research and Analysis Management Programming System) is a personal genealogy program.")

View File

@ -6467,6 +6467,11 @@ Unknown
<class>GtkRadioButton</class>
<name>childMale</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_male_toggled</handler>
<last_modification_time>Sun, 06 Jan 2002 15:38:36 GMT</last_modification_time>
</signal>
<label>male</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
@ -6482,6 +6487,11 @@ Unknown
<class>GtkRadioButton</class>
<name>childFemale</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_female_toggled</handler>
<last_modification_time>Sun, 06 Jan 2002 15:38:23 GMT</last_modification_time>
</signal>
<label>female</label>
<active>True</active>
<draw_indicator>True</draw_indicator>
@ -6497,6 +6507,11 @@ Unknown
<class>GtkRadioButton</class>
<name>childUnknown</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_gender_toggled</handler>
<last_modification_time>Sun, 06 Jan 2002 15:37:50 GMT</last_modification_time>
</signal>
<label>unknown</label>
<active>True</active>
<draw_indicator>True</draw_indicator>

View File

@ -361,8 +361,8 @@ def on_add_new_child_clicked(obj):
"""Create a new child to add to the existing family"""
import SelectChild
if active_person:
SelectChild.NewChild(database,active_family,active_person,update_after_newchild)
SelectChild.NewChild(database,active_family,active_person,
update_after_newchild,Config.lastnamegen)
#-------------------------------------------------------------------------
#

View File

@ -1364,7 +1364,7 @@ class GedcomParser:
name = Name()
name.setSurname(lname[-1])
name.setFirstName(string.join(lname[0:l-1]))
self.person.addAlternateName(name)
self.person.addAlternateName(name)
elif matches[1] == "SOUR":
source_ref = SourceRef()
source_ref.setBase(self.db.findSource(matches[2],self.smap))