* src/RelLib.py : support for capitalized name formats

* src/EditPerson.py: eliminate capitilzing names, instead rely on
the display formats
* src/Utils.py: new display formats for names
* src/GrampsCfg.py: eliminate name only option in status line,
add support for capitalized name formats
* src/preferences.glade : eliminate name only option in status line,
drop capitalize in favor of expanded name format


svn: r2238
This commit is contained in:
Don Allingham 2003-10-12 04:26:00 +00:00
parent 52839e9ba0
commit fee585d80c
5 changed files with 104 additions and 73 deletions

View File

@ -921,9 +921,6 @@ class EditPerson:
original record""" original record"""
surname = unicode(self.surname_field.get_text()) surname = unicode(self.surname_field.get_text())
if GrampsCfg.capitalize:
surname = surname.upper()
self.birth.setDate(self.bdate.get_text()) self.birth.setDate(self.bdate.get_text())
self.death.setDate(self.ddate.get_text()) self.death.setDate(self.ddate.get_text())
@ -949,12 +946,8 @@ class EditPerson:
changed = 1 changed = 1
if prefix != name.getSurnamePrefix(): if prefix != name.getSurnamePrefix():
changed = 1 changed = 1
if GrampsCfg.capitalize: if surname.upper() != name.getSurname().upper():
if surname != name.getSurname(): changed = 1
changed = 1
else:
if surname.upper() != name.getSurname().upper():
changed = 1
if ntype != const.InverseNameTypesMap[name.getType()]: if ntype != const.InverseNameTypesMap[name.getType()]:
changed = 1 changed = 1
if given != name.getFirstName(): if given != name.getFirstName():
@ -1316,14 +1309,9 @@ class EditPerson:
if ntype != name.getType(): if ntype != name.getType():
name.setType(ntype) name.setType(ntype)
if GrampsCfg.capitalize: if surname != name.getSurname():
if surname.upper() != name.getSurname().upper(): name.setSurname(surname)
name.setSurname(surname.upper()) self.db.addSurname(surname)
self.db.addSurname(surname.upper())
else:
if surname != name.getSurname():
name.setSurname(surname)
self.db.addSurname(surname)
if given != name.getFirstName(): if given != name.getFirstName():
name.setFirstName(given) name.setFirstName(given)

View File

@ -89,6 +89,8 @@ _date_entry_list = [
_name_format_list = [ _name_format_list = [
(_("Firstname Surname"), Utils.normal_name), (_("Firstname Surname"), Utils.normal_name),
(_("Surname, Firstname"), Utils.phonebook_name), (_("Surname, Firstname"), Utils.phonebook_name),
(_("Firstname SURNAME"), Utils.upper_name),
(_("SURNAME, Firstname"), Utils.phonebook_upper_name),
] ]
panellist = [ panellist = [
@ -129,6 +131,8 @@ vc_comment = 0
uncompress = 0 uncompress = 0
lastfile = None lastfile = None
nameof = Utils.normal_name nameof = Utils.normal_name
display_name = Utils.normal_name
display_surname = lambda x : x.getSurname()
status_bar = 1 status_bar = 1
toolbar = 2 toolbar = 2
calendar = 0 calendar = 0
@ -144,7 +148,6 @@ index_visible = 0
mediaref = 1 mediaref = 1
globalprop = 1 globalprop = 1
localprop = 1 localprop = 1
capitalize = 0
defaultview = 0 defaultview = 0
familyview = 0 familyview = 0
@ -199,6 +202,8 @@ def loadConfig(call):
global index_visible global index_visible
global lastfile global lastfile
global nameof global nameof
global display_name
global display_surname
global _name_format global _name_format
global _callback global _callback
global paper_preference global paper_preference
@ -213,7 +218,7 @@ def loadConfig(call):
global mediaref global mediaref
global globalprop global globalprop
global localprop global localprop
global capitalize # global capitalize
global defaultview global defaultview
global familyview global familyview
@ -229,7 +234,7 @@ def loadConfig(call):
vc_comment = get_bool("/apps/gramps/use-comment") vc_comment = get_bool("/apps/gramps/use-comment")
uncompress = get_bool("/apps/gramps/dont-compress-xml") uncompress = get_bool("/apps/gramps/dont-compress-xml")
id_edit = get_bool("/apps/gramps/id-edit") id_edit = get_bool("/apps/gramps/id-edit")
capitalize = get_bool("/apps/gramps/capitalize") # capitalize = get_bool("/apps/gramps/capitalize")
index_visible = get_bool("/apps/gramps/index-visible") index_visible = get_bool("/apps/gramps/index-visible")
status_bar = get_int("/apps/gramps/statusbar") status_bar = get_int("/apps/gramps/statusbar")
toolbar = get_int("/apps/gramps/toolbar",2) toolbar = get_int("/apps/gramps/toolbar",2)
@ -296,11 +301,15 @@ def loadConfig(call):
Calendar.set_format_code(dateFormat) Calendar.set_format_code(dateFormat)
Calendar.Calendar.ENTRYCODE = dateEntry Calendar.Calendar.ENTRYCODE = dateEntry
if _name_format == 0: nameof = _name_format_list[_name_format][1]
nameof = Utils.normal_name
if _name_format%2:
display_name = Utils.phonebook_name
display_surname = lambda x : x.getSurname()
else: else:
nameof = Utils.phonebook_name display_name = Utils.phonebook_upper_name
display_surname = lambda x : x.getUpperSurname()
make_path(os.path.expanduser("~/.gramps")) make_path(os.path.expanduser("~/.gramps"))
make_path(os.path.expanduser("~/.gramps/filters")) make_path(os.path.expanduser("~/.gramps/filters"))
make_path(os.path.expanduser("~/.gramps/plugins")) make_path(os.path.expanduser("~/.gramps/plugins"))
@ -554,7 +563,7 @@ class GrampsPreferences:
auto = self.top.get_widget("autoload") auto = self.top.get_widget("autoload")
asave_int = self.top.get_widget("autosave_interval") asave_int = self.top.get_widget("autosave_interval")
idedit = self.top.get_widget("gid_edit") idedit = self.top.get_widget("gid_edit")
cap = self.top.get_widget('capitalize') # cap = self.top.get_widget('capitalize')
index_vis = self.top.get_widget("show_child_id") index_vis = self.top.get_widget("show_child_id")
lds = self.top.get_widget("uselds") lds = self.top.get_widget("uselds")
ac = self.top.get_widget("autocomp") ac = self.top.get_widget("autocomp")
@ -582,7 +591,7 @@ class GrampsPreferences:
vcom.set_active(vc_comment) vcom.set_active(vc_comment)
compress.set_active(uncompress) compress.set_active(uncompress)
idedit.set_active(id_edit) idedit.set_active(id_edit)
cap.set_active(capitalize) # cap.set_active(capitalize)
index_vis.set_active(index_visible) index_vis.set_active(index_visible)
self.top.get_widget("iprefix").set_text(iprefix) self.top.get_widget("iprefix").set_text(iprefix)
@ -813,7 +822,7 @@ class GrampsPreferences:
global vc_comment global vc_comment
global uncompress global uncompress
global id_edit global id_edit
global capitalize # global capitalize
global index_visible global index_visible
global status_bar global status_bar
global toolbar global toolbar
@ -840,7 +849,7 @@ class GrampsPreferences:
vc_comment = self.top.get_widget("vc_comment").get_active() vc_comment = self.top.get_widget("vc_comment").get_active()
uncompress = self.top.get_widget("uncompress").get_active() uncompress = self.top.get_widget("uncompress").get_active()
id_edit = self.top.get_widget("gid_edit").get_active() id_edit = self.top.get_widget("gid_edit").get_active()
capitalize = self.top.get_widget('capitalize').get_active() # capitalize = self.top.get_widget('capitalize').get_active()
index_visible = self.top.get_widget("show_child_id").get_active() index_visible = self.top.get_widget("show_child_id").get_active()
paper_obj = self.top.get_widget("paper_size").get_menu().get_active() paper_obj = self.top.get_widget("paper_size").get_menu().get_active()
@ -912,7 +921,7 @@ class GrampsPreferences:
set_bool("/apps/gramps/use-comment",vc_comment) set_bool("/apps/gramps/use-comment",vc_comment)
set_bool("/apps/gramps/dont-compress-xml",uncompress) set_bool("/apps/gramps/dont-compress-xml",uncompress)
set_bool("/apps/gramps/id-edit",id_edit) set_bool("/apps/gramps/id-edit",id_edit)
set_bool("/apps/gramps/capitalize",capitalize) # set_bool("/apps/gramps/capitalize",capitalize)
set_bool("/apps/gramps/index-visible",index_visible) set_bool("/apps/gramps/index-visible",index_visible)
set_int("/apps/gramps/statusbar",status_bar) set_int("/apps/gramps/statusbar",status_bar)
set_int("/apps/gramps/toolbar",toolbar) set_int("/apps/gramps/toolbar",toolbar)

View File

@ -38,6 +38,7 @@ import os
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from Date import Date, SingleDate, compare_dates, not_too_old from Date import Date, SingleDate, compare_dates, not_too_old
import GrampsCfg
import sort import sort
import const import const
@ -878,6 +879,10 @@ class Name(DataObj):
"""returns the surname (or last name) for the Name instance""" """returns the surname (or last name) for the Name instance"""
return self.Surname return self.Surname
def getUpperSurname(self):
"""returns the surname (or last name) for the Name instance"""
return self.Surname.upper()
def getSuffix(self): def getSuffix(self):
"""returns the suffix for the Name instance""" """returns the suffix for the Name instance"""
return self.Suffix return self.Suffix
@ -905,6 +910,21 @@ class Name(DataObj):
else: else:
return "%s, %s" % (self.Surname, self.FirstName) return "%s, %s" % (self.Surname, self.FirstName)
def getUpperName(self):
"""returns a name string built from the components of the Name
instance, in the form of Surname, Firstname"""
if self.Suffix:
if self.Prefix:
return "%s %s, %s %s" % (self.Prefix.upper(), self.Surname.upper(), self.FirstName, self.Suffix)
else:
return "%s, %s %s" % (self.Surname.upper(), self.FirstName, self.Suffix)
else:
if self.Prefix:
return "%s %s, %s" % (self.Prefix.upper(), self.Surname.upper(), self.FirstName)
else:
return "%s, %s" % (self.Surname.upper(), self.FirstName)
def getRegularName(self): def getRegularName(self):
"""returns a name string built from the components of the Name """returns a name string built from the components of the Name
instance, in the form of Firstname Surname""" instance, in the form of Firstname Surname"""
@ -919,6 +939,20 @@ class Name(DataObj):
else: else:
return "%s %s, %s" % (self.FirstName, self.Surname, self.Suffix) return "%s %s, %s" % (self.FirstName, self.Surname, self.Suffix)
def getRegularUpperName(self):
"""returns a name string built from the components of the Name
instance, in the form of Firstname Surname"""
if (self.Suffix == ""):
if self.Prefix:
return "%s %s %s" % (self.FirstName, self.Prefix.upper(), self.Surname.upper())
else:
return "%s %s" % (self.FirstName, self.Surname.upper())
else:
if self.Prefix:
return "%s %s %s, %s" % (self.FirstName, self.Prefix.upper(), self.Surname.upper(), self.Suffix)
else:
return "%s %s, %s" % (self.FirstName, self.Surname.upper(), self.Suffix)
def are_equal(self,other): def are_equal(self,other):
"""compares to names to see if they are equal, return 0 if they """compares to names to see if they are equal, return 0 if they
are not""" are not"""
@ -1044,11 +1078,11 @@ class Person(Persistent):
gender = const.unknown gender = const.unknown
bday = self.getBirth().getDateObj() bday = self.getBirth().getDateObj()
dday = self.getDeath().getDateObj() dday = self.getDeath().getDateObj()
return [ self.getPrimaryName().getName(),self.id,gender, return [ GrampsCfg.display_name(self),self.id,gender,
bday.getQuoteDate(), dday.getQuoteDate(), bday.getQuoteDate(), dday.getQuoteDate(),
sort.build_sort_name(self.getPrimaryName()), sort.build_sort_name(self.getPrimaryName()),
sort.build_sort_date(bday),sort.build_sort_date(dday), sort.build_sort_date(bday),sort.build_sort_date(dday),
self.getPrimaryName().getSurname()] GrampsCfg.display_surname(self.PrimaryName)]
def setPrimaryName(self,name): def setPrimaryName(self,name):
"""sets the primary name of the Person to the specified """sets the primary name of the Person to the specified

View File

@ -136,6 +136,24 @@ def phonebook_name(person):
else: else:
return u'' return u''
def phonebook_upper_name(person):
if person:
return person.getPrimaryName().getUpperName()
else:
return u''
def normal_name(person):
if person:
return person.getPrimaryName().getRegularName()
else:
return u''
def upper_name(person):
if person:
return person.getPrimaryName().getRegularUpperName()
else:
return u''
def family_name(family): def family_name(family):
"""Builds a name for the family from the parents names""" """Builds a name for the family from the parents names"""
father = family.getFather() father = family.getFather()
@ -149,18 +167,21 @@ def family_name(family):
else: else:
name = mother.getPrimaryName().getName() name = mother.getPrimaryName().getName()
return name return name
def phonebook_from_name(name,alt):
if alt:
return "%s *" % name.getName()
else:
return name.getName()
def normal_name(person): def family_upper_name(family):
if person: """Builds a name for the family from the parents names"""
return person.getPrimaryName().getRegularName() father = family.getFather()
mother = family.getMother()
if father and mother:
fname = father.getPrimaryName().getUpperName()
mname = mother.getPrimaryName().getUpperName()
name = _("%s and %s") % (fname,mname)
elif father:
name = father.getPrimaryName().getUpperName()
else: else:
return u'' name = mother.getPrimaryName().getUpperName()
return name
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -225,7 +225,7 @@
<widget class="GtkTable" id="table11"> <widget class="GtkTable" id="table11">
<property name="border_width">12</property> <property name="border_width">12</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="n_rows">6</property> <property name="n_rows">5</property>
<property name="n_columns">4</property> <property name="n_columns">4</property>
<property name="homogeneous">False</property> <property name="homogeneous">False</property>
<property name="row_spacing">6</property> <property name="row_spacing">6</property>
@ -252,8 +252,8 @@
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">4</property> <property name="top_attach">3</property>
<property name="bottom_attach">5</property> <property name="bottom_attach">4</property>
<property name="x_options">fill</property> <property name="x_options">fill</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
@ -274,8 +274,8 @@
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">2</property>
<property name="right_attach">3</property> <property name="right_attach">3</property>
<property name="top_attach">4</property> <property name="top_attach">3</property>
<property name="bottom_attach">5</property> <property name="bottom_attach">4</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -301,8 +301,8 @@
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">5</property> <property name="top_attach">4</property>
<property name="bottom_attach">6</property> <property name="bottom_attach">5</property>
<property name="x_options">fill</property> <property name="x_options">fill</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
@ -325,8 +325,8 @@
<packing> <packing>
<property name="left_attach">3</property> <property name="left_attach">3</property>
<property name="right_attach">4</property> <property name="right_attach">4</property>
<property name="top_attach">4</property> <property name="top_attach">3</property>
<property name="bottom_attach">5</property> <property name="bottom_attach">4</property>
<property name="x_options">fill</property> <property name="x_options">fill</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
@ -384,29 +384,8 @@
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">2</property>
<property name="right_attach">4</property> <property name="right_attach">4</property>
<property name="top_attach">5</property> <property name="top_attach">4</property>
<property name="bottom_attach">6</property> <property name="bottom_attach">5</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="capitalize">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Capitalize family names</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">4</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>