Surname prefix support

svn: r1217
This commit is contained in:
Don Allingham 2002-12-04 04:58:07 +00:00
parent efd7282292
commit 37b8945a47
13 changed files with 231 additions and 57 deletions

View File

@ -179,10 +179,12 @@ class EditPerson:
self.alt_last_field = self.get_widget("alt_last")
self.alt_title_field = self.get_widget("alt_title")
self.alt_suffix_field = self.get_widget("alt_suffix")
self.alt_prefix_field = self.get_widget("alt_prefix")
self.name_type_field = self.get_widget("name_type")
self.surname_field = self.get_widget("surname")
self.ntype_field = self.get_widget("ntype")
self.suffix = self.get_widget("suffix")
self.prefix = self.get_widget("prefix")
self.given = self.get_widget("givenName")
self.nick = self.get_widget("nickname")
self.title = self.get_widget("title")
@ -774,6 +776,7 @@ class EditPerson:
surname = self.surname_field.get_text()
ntype = self.ntype_field.entry.get_text()
suffix = self.suffix.get_text()
prefix = self.prefix.get_text()
given = self.given.get_text()
nick = self.nick.get_text()
title = self.title.get_text()
@ -791,6 +794,8 @@ class EditPerson:
changed = 1
if suffix != name.getSuffix():
changed = 1
if prefix != name.getSurnamePrefix():
changed = 1
if surname != name.getSurname():
changed = 1
if ntype != name.getType():
@ -995,6 +1000,7 @@ class EditPerson:
self.alt_title_field.set_text(name.getTitle())
self.alt_last_field.set_text(name.getSurname())
self.alt_suffix_field.set_text(name.getSuffix())
self.alt_prefix_field.set_text(name.getSurnamePrefix())
self.name_type_field.set_text(name.getType())
if len(name.getSourceRefList()) > 0:
psrc = name.getSourceRefList()[0]
@ -1010,6 +1016,7 @@ class EditPerson:
self.alt_title_field.set_text('')
self.alt_last_field.set_text('')
self.alt_suffix_field.set_text('')
self.alt_prefix_field.set_text('')
self.name_type_field.set_text('')
self.name_src_field.set_text('')
self.name_conf_field.set_text('')
@ -1104,6 +1111,7 @@ class EditPerson:
surname = self.surname_field.get_text()
suffix = self.suffix.get_text()
prefix = self.prefix.get_text()
ntype = self.ntype_field.entry.get_text()
given = self.given.get_text()
nick = self.nick.get_text()
@ -1131,6 +1139,9 @@ class EditPerson:
if suffix != name.getSuffix():
name.setSuffix(suffix)
if prefix != name.getSurnamePrefix():
name.setSurnamePrefix(prefix)
if const.NameTypesMap.has_key(ntype):
ntype = const.NameTypesMap[ntype]
else:
@ -1382,6 +1393,7 @@ class EditPerson:
name = GrampsCfg.nameof(self.person)
self.get_widget("activepersonTitle").set_text(name)
self.suffix.set_text(self.pname.getSuffix())
self.prefix.set_text(self.pname.getSurnamePrefix())
self.surname_field.set_text(self.pname.getSurname())
self.given.set_text(self.pname.getFirstName())

View File

@ -38,6 +38,8 @@ CALENDAR_NO = 0
CALENDAR_YES = 1
OBJE_NO = 0
OBJE_YES = 1
PREFIX_NO = 0
PREFIX_YES = 1
RESIDENCE_ADDR = 0
RESIDENCE_PLAC = 1
@ -60,7 +62,8 @@ class GedcomDescription:
self.resi = RESIDENCE_ADDR
self.gramps2tag_map = {}
self.tag2gramps_map = {}
self.prefix = PREFIX_YES
def set_dest(self,val):
self.dest = val
@ -73,6 +76,12 @@ class GedcomDescription:
def get_adopt(self):
return self.adopt
def set_prefix(self,val):
self.prefix=val
def get_prefix(self):
return self.prefix
def set_conc(self,val):
self.conc = val
@ -212,6 +221,9 @@ class GedInfoParser:
elif tag == "object_support":
if attrs['val'] == 'no':
self.current.set_obje(OBJE_NO)
elif tag == "prefix":
if attrs['val'] == 'no':
self.current.set_obje(PREFIX_NO)
elif tag == "residence":
if attrs['val'] == 'place':
self.current.set_resi(RESIDENCE_PLAC)

View File

@ -303,6 +303,10 @@ class GrampsParser:
self.name.conf = 2
if attrs.has_key("priv"):
self.name.private = int(attrs["priv"])
def start_last(self,attrs):
if attrs.has_key('prefix'):
self.name.Prefix = attrs['prefix']
def start_note(self,attrs):
self.in_note = 1
@ -746,7 +750,7 @@ class GrampsParser:
"first" : (None, stop_first),
"gender" : (None, stop_gender),
"header" : (None, None),
"last" : (None, stop_last),
"last" : (start_last, stop_last),
"mother" : (start_mother,None),
"name" : (start_name, stop_name),
"nick" : (None, stop_nick),

View File

@ -74,6 +74,11 @@ class ListModel:
def connect_model(self):
self.tree.set_model(self.model)
self.model.set_sort_column_id(0,gtk.SORT_ASCENDING)
def sort(self):
val = self.model.get_sort_column_id()
self.model.set_sort_column_id(val[0],val[1])
self.model.sort_column_changed()
def get_selected(self):
return self.selection.get_selected()

View File

@ -821,12 +821,20 @@ class Name(DataObj):
self.Suffix = source.Suffix
self.Title = source.Title
self.type = source.type
self.Prefix = source.Prefix
else:
self.FirstName = ""
self.Surname = ""
self.Suffix = ""
self.Title = ""
self.type = ""
self.Prefix = ""
def getSurnamePrefix(self):
return self.Prefix
def setSurnamePrefix(self,val):
self.Prefix = val
def setType(self,type):
"""sets the type of the Name instance"""
@ -872,10 +880,16 @@ class Name(DataObj):
"""returns a name string built from the components of the Name
instance, in the form of Surname, Firstname"""
if (self.Suffix == ""):
return "%s, %s" % (self.Surname, self.FirstName)
if self.Suffix:
if self.Prefix:
return "%s %s, %s %s" % (self.Prefix, self.Surname, self.FirstName, self.Suffix)
else:
return "%s, %s %s" % (self.Surname, self.FirstName, self.Suffix)
else:
return "%s, %s %s" % (self.Surname, self.FirstName, self.Suffix)
if self.Prefix:
return "%s %s, %s" % (self.Prefix,self.Surname, self.FirstName)
else:
return "%s, %s" % (self.Surname, self.FirstName)
def getRegularName(self):
"""returns a name string built from the components of the Name

View File

@ -437,6 +437,14 @@ class XmlWriter:
else:
self.g.write('>\n')
def write_last(self,name,indent=1):
p = name.Prefix
n = name.Surname
if p:
self.g.write('%s<last prefix="%s">%s</last>\n' % (' '*indent,p,self.fix(n)))
else:
self.g.write('%s<last>%s</last>\n' % (' '*indent,self.fix(n)))
def write_line(self,label,value,indent=1):
if value:
self.g.write('%s<%s>%s</%s>\n' % (' '*indent,label,self.fix(value),label))
@ -486,7 +494,7 @@ class XmlWriter:
else:
self.g.write('%s<%s%s>\n' % (sp,label,conf_priv(name)))
self.write_line("first",name.getFirstName(),index+1)
self.write_line("last",name.getSurname(),index+1)
self.write_last(name,index+1)
self.write_line("suffix",name.getSuffix(),index+1)
self.write_line("title",name.getTitle(),index+1)
if name.getNote() != "":

View File

@ -5,6 +5,7 @@
<adopt val="none"/>
<conc val="standard"/>
<alternate_names val="none"/>
<prefix val="no">
<calendar val="no"/>
<extended_events>
</extended_events>
@ -16,6 +17,7 @@
<adopt val="event"/>
<conc val="broken"/>
<alternate_names val="event_aka"/>
<prefix val="no">
<calendar val="no"/>
<extended_events>
</extended_events>
@ -27,6 +29,7 @@
<adopt val="ftw"/>
<conc val="broken"/>
<alternate_names val="alias"/>
<prefix val="no">
<calendar val="no"/>
<extended_events>
<event tag="_DEG" value="Degree"/>
@ -42,6 +45,7 @@
<adopt val="none"/>
<conc val="broken"/>
<alternate_names val="none"/>
<prefix val="no">
<calendar val="no"/>
<extended_events>
</extended_events>
@ -53,6 +57,7 @@
<adopt val="event_extended"/>
<conc val="standard"/>
<alternate_names val="none"/>
<prefix val="no">
<calendar val="yes"/>
<extended_events>
</extended_events>
@ -63,6 +68,7 @@
<dest val="Legacy"/>
<adopt val="legacy"/>
<conc val="broken"/>
<prefix val="no">
<alternate_names val="standard"/>
<calendar val="no"/>
<extended_events>
@ -75,6 +81,7 @@
<adopt val="pedigree"/>
<conc val="standard"/>
<alternate_names val="aka"/>
<prefix val="no">
<calendar val="no"/>
<extended_events>
</extended_events>
@ -86,6 +93,7 @@
<adopt val="none"/>
<conc val="broken"/>
<alternate_names val="none"/>
<prefix val="no">
<calendar val="no"/>
<extended_events>
</extended_events>
@ -97,6 +105,7 @@
<adopt val="none"/>
<conc val="broken"/>
<alternate_names val="_alias"/>
<prefix val="no">
<calendar val="no"/>
<extended_events>
</extended_events>
@ -108,6 +117,7 @@
<adopt val="none"/>
<conc val="broken"/>
<alternate_names val="none"/>
<prefix val="no">
<calendar val="no"/>
<extended_events>
</extended_events>

View File

@ -2546,7 +2546,7 @@
<child>
<widget class="GtkTable" id="table23">
<property name="visible">True</property>
<property name="n_rows">6</property>
<property name="n_rows">7</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
@ -2617,8 +2617,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@ -2639,8 +2639,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property>
@ -2751,8 +2751,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@ -2857,8 +2857,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property>
@ -2882,8 +2882,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@ -2904,8 +2904,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property>
@ -2926,12 +2926,59 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label290">
<property name="visible">True</property>
<property name="label" translatable="yes">Surname Prefix</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xpad">5</property>
<property name="ypad">8</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="alt_prefix">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>

View File

@ -729,7 +729,7 @@
<child>
<widget class="GtkTable" id="table15">
<property name="visible">True</property>
<property name="n_rows">6</property>
<property name="n_rows">7</property>
<property name="n_columns">3</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
@ -778,8 +778,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_padding">5</property>
<property name="y_padding">5</property>
<property name="x_options">fill</property>
@ -804,8 +804,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_padding">5</property>
<property name="y_padding">5</property>
<property name="x_options">fill</property>
@ -830,8 +830,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_padding">5</property>
<property name="y_padding">5</property>
<property name="x_options">fill</property>
@ -880,8 +880,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property>
@ -927,8 +927,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property>
@ -948,8 +948,8 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="x_options"></property>
@ -972,8 +972,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property>
@ -993,8 +993,8 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="x_options">fill</property>
@ -1019,8 +1019,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_padding">5</property>
<property name="y_padding">5</property>
<property name="x_options">fill</property>
@ -1105,8 +1105,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property>
@ -1153,6 +1153,55 @@
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label293">
<property name="visible">True</property>
<property name="label" translatable="yes">Surname Prefix</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_padding">5</property>
<property name="y_padding">5</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="prefix">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_padding">3</property>
<property name="y_padding">3</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
</child>
@ -1194,6 +1243,7 @@
<child>
<widget class="GtkImage" id="personPix">
<property name="width_request">275</property>
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>

View File

@ -1217,6 +1217,7 @@ class Gramps:
if change:
self.change_active_person(person)
self.goto_active_person()
model.sort()
def redisplay_person_list(self,person):
self.add_to_person_list(person,1)

View File

@ -1339,7 +1339,7 @@ class GedcomParser:
elif matches[1] == "GIVN":
name.setFirstName(matches[2])
elif matches[1] == "SPFX":
pass
name.setSurnamePrefix(matches[2])
elif matches[1] == "SURN":
name.setSurname(matches[2])
self.db.addSurname(matches[2])

View File

@ -379,7 +379,8 @@ class GedcomWriter:
self.cal = self.target_ged.get_alt_calendar()
self.obje = self.target_ged.get_obje()
self.resi = self.target_ged.get_resi()
self.prefix = self.target_ged.get_prefix()
if self.topDialog.get_widget("ansel").get_active():
self.cnvtxt = latin_to_ansel
else:
@ -892,17 +893,33 @@ class GedcomWriter:
def write_person_name(self,name,nick):
firstName = self.cnvtxt(name.getFirstName())
surName = self.cnvtxt(name.getSurname())
surPref = self.cnvtxt(name.getSurnamePrefix())
suffix = self.cnvtxt(name.getSuffix())
title = self.cnvtxt(name.getTitle())
if suffix == "":
self.g.write("1 NAME %s /%s/\n" % (firstName,surName))
if surPref:
self.g.write("1 NAME %s /%s/\n" % (firstName,surName))
else:
self.g.write("1 NAME %s /%s %s/\n" % (firstName,surPref,surName))
else:
self.g.write("1 NAME %s /%s/, %s\n" % (firstName,surName, suffix))
if surPref:
self.g.write("1 NAME %s /%s %s/, %s\n" % (firstName,surPref,surName,suffix))
else:
self.g.write("1 NAME %s /%s/, %s\n" % (firstName,surName,suffix))
if name.getFirstName() != "":
self.g.write("2 GIVN %s\n" % firstName)
if name.getSurname() != "":
self.g.write("2 SURN %s\n" % surName)
if self.prefix:
if surPref:
self.g.write('2 SPFX %s\n' % surPref)
if surName != "":
self.g.write("2 SURN %s\n" % surName)
else:
if surPref:
self.g.write("2 SURN %s %s\n" % (surPref,surName))
else if surName:
self.g.write("2 SURN %s\n" % surName)
if name.getSuffix() != "":
self.g.write("2 NSFX %s\n" % suffix)
if name.getTitle() != "":

View File

@ -39,8 +39,6 @@ import Date
#-------------------------------------------------------------------------
su = string.upper
sp = string.split
_plist = [ 'de', 'van', 'von', 'la', 'di', 'le', 'du' ]
@ -52,14 +50,10 @@ def build_sort_name(n):
"""Builds a name from a RelLib.Name instance that is suitable for
use as a sort key in a GtkCList. The name is converted to upper case
to provide for case-insenstive sorting"""
l = string.split(n.Surname)
if len(l) > 1 and _prefix.has_key(l[0].lower()):
return "%-25s%-30s%s" % (su(l[1]),su(n.FirstName),su(n.Suffix))
if n.Surname:
return "%-25s%-30s%s" % (su(n.Surname),su(n.FirstName),su(n.Suffix))
else:
if n.Surname:
return "%-25s%-30s%s" % (su(n.Surname),su(n.FirstName),su(n.Suffix))
else:
return "%s" % chr(255)
return "%s" % chr(255)
def build_sort_date(n):