2006-06-14 Alex Roitman <shura@gramps-project.org>

* src/NameDisplay.py: Factor out commont code.
	* src/Editors/_EditName.py (_setup_fields): Remove Default item.
	* src/RelLib/_Name.py (Name.DEF): Replace with CUSTOM, use LNFN in
	place of previous DEF.
	* src/GrampsCfg.py (add_name_panel): Add Name Display panel.
	* src/GrampsDb/_ReadXML.py (stop_name): Properly set name type;
	do not set conf attribute on attr, addr, and event.



svn: r6889
This commit is contained in:
Alex Roitman 2006-06-14 20:20:39 +00:00
parent 18aa102799
commit 5b113d9558
7 changed files with 108 additions and 94 deletions

View File

@ -1,3 +1,12 @@
2006-06-14 Alex Roitman <shura@gramps-project.org>
* src/NameDisplay.py: Factor out commont code.
* src/Editors/_EditName.py (_setup_fields): Remove Default item.
* src/RelLib/_Name.py (Name.DEF): Replace with CUSTOM, use LNFN in
place of previous DEF.
* src/GrampsCfg.py (add_name_panel): Add Name Display panel.
* src/GrampsDb/_ReadXML.py (stop_name): Properly set name type;
do not set conf attribute on attr, addr, and event.
2006-06-13 Brian Matherly <brian@gramps-project.org> 2006-06-13 Brian Matherly <brian@gramps-project.org>
* src/PluginUtils/_Plugins.py: pass dbstate to report * src/PluginUtils/_Plugins.py: pass dbstate to report

View File

@ -36,6 +36,3 @@ else:
from _GrampsGconfKeys import * from _GrampsGconfKeys import *
except: except:
from _GrampsIniKeys import * from _GrampsIniKeys import *

View File

@ -77,7 +77,8 @@ class EditName(EditSecondary):
Utils.bold_label(self.general_label) Utils.bold_label(self.general_label)
def _post_init(self): def _post_init(self):
if self.original_group_as and self.original_group_as != self.obj.get_surname(): if self.original_group_as and \
(self.original_group_as != self.obj.get_surname()):
self.group_over.set_active(True) self.group_over.set_active(True)
def _connect_signals(self): def _connect_signals(self):
@ -99,18 +100,20 @@ class EditName(EditSecondary):
self.top.get_widget('sort_as'), self.top.get_widget('sort_as'),
self.obj.set_sort_as, self.obj.set_sort_as,
self.obj.get_sort_as, self.obj.get_sort_as,
[(_('Default (based on locale)'),RelLib.Name.DEF), [(_('Given name Family name'), RelLib.Name.FNLN),
(_('Given name Family name'), RelLib.Name.FNLN), (_('Family name Given Name Patronymic'), RelLib.Name.LNFN),
(_('Family name Given Name'), RelLib.Name.LNFN)], (_('Custom'), RelLib.Name.CUSTOM),
],
self.db.readonly) self.db.readonly)
self.display_as = MonitoredMenu( self.display_as = MonitoredMenu(
self.top.get_widget('display_as'), self.top.get_widget('display_as'),
self.obj.set_display_as, self.obj.set_display_as,
self.obj.get_display_as, self.obj.get_display_as,
[(_('Default (based on locale)'),RelLib.Name.DEF), [(_('Given name Family name'), RelLib.Name.FNLN),
(_('Given name Family name'), RelLib.Name.FNLN), (_('Family name Given Name Patronymic'), RelLib.Name.LNFN),
(_('Family name Given Name'), RelLib.Name.LNFN)], (_('Custom'), RelLib.Name.CUSTOM),
],
self.db.readonly) self.db.readonly)
self.given_field = MonitoredEntry( self.given_field = MonitoredEntry(

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2005 Donald N. Allingham # Copyright (C) 2000-2006 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -42,6 +42,7 @@ import gtk.glade
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import Config import Config
import DateHandler import DateHandler
import NameDisplay
import ManagedWindow import ManagedWindow
from GrampsWidgets import * from GrampsWidgets import *
@ -86,13 +87,14 @@ def get_researcher():
class GrampsPreferences(ManagedWindow.ManagedWindow): class GrampsPreferences(ManagedWindow.ManagedWindow):
def __init__(self, uistate): def __init__(self, uistate):
ManagedWindow.ManagedWindow.__init__(self, uistate, [], GrampsPreferences) ManagedWindow.ManagedWindow.__init__(self,uistate,[],GrampsPreferences)
tlabel = gtk.Label() tlabel = gtk.Label()
self.set_window(gtk.Dialog(_('Preferences'), self.set_window(
flags=gtk.DIALOG_NO_SEPARATOR, gtk.Dialog(_('Preferences'),
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)), flags=gtk.DIALOG_NO_SEPARATOR,
tlabel, _('Preferences'), None) buttons=(gtk.STOCK_CLOSE,gtk.RESPONSE_CLOSE)),
tlabel, _('Preferences'), None)
panel = gtk.Notebook() panel = gtk.Notebook()
self.window.vbox.pack_start(tlabel, padding=12) self.window.vbox.pack_start(tlabel, padding=12)
@ -102,6 +104,8 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
MarkupLabel("<b>%s</b>" % _('General'))) MarkupLabel("<b>%s</b>" % _('General')))
panel.append_page(self.add_formats_panel(), panel.append_page(self.add_formats_panel(),
MarkupLabel("<b>%s</b>" % _('Display'))) MarkupLabel("<b>%s</b>" % _('Display')))
panel.append_page(self.add_name_panel(),
MarkupLabel("<b>%s</b>" % _('Name Display')))
panel.append_page(self.add_prefix_panel(), panel.append_page(self.add_prefix_panel(),
MarkupLabel("<b>%s</b>" % _('ID Formats'))) MarkupLabel("<b>%s</b>" % _('ID Formats')))
panel.append_page(self.add_advanced_panel(), panel.append_page(self.add_advanced_panel(),
@ -199,6 +203,30 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
for widget in [self.comp_color,self.todo_color,self.custom_color]: for widget in [self.comp_color,self.todo_color,self.custom_color]:
widget.emit('color-set') widget.emit('color-set')
def add_name_panel(self):
table = gtk.Table(3,3)
table.set_border_width(12)
table.set_col_spacings(6)
table.set_row_spacings(6)
obox = gtk.combo_box_new_text()
for key,value in NameDisplay.formats.items():
obox.append_text(value)
active = Config.get(Config.NAME_FORMAT)
if active >= len(NameDisplay.formats):
active = 0
obox.set_active(active)
obox.connect('changed',
lambda obj: Config.set(Config.NAME_FORMAT,
obj.get_active()))
lwidget = BasicLabel("%s: " % _('Preset format'))
table.attach(lwidget, 0, 1, 0, 1, yoptions=0)
table.attach(obox, 1,3,0, 1, yoptions=0)
return table
def add_formats_panel(self): def add_formats_panel(self):
table = gtk.Table(3,8) table = gtk.Table(3,8)
table.set_border_width(12) table.set_border_width(12)
@ -317,5 +345,3 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
def build_menu_names(self,obj): def build_menu_names(self,obj):
return (_('Preferences'),None) return (_('Preferences'),None)

View File

@ -752,7 +752,6 @@ class GrampsParser(UpdateCallback):
self.event.gramps_id = gramps_id self.event.gramps_id = gramps_id
except KeyError: except KeyError:
self.event = self.find_event_by_gramps_id(gramps_id) self.event = self.find_event_by_gramps_id(gramps_id)
self.event.conf = int(attrs.get("conf",2))
self.event.private = bool(attrs.get("priv")) self.event.private = bool(attrs.get("priv"))
def start_eventref(self,attrs): def start_eventref(self,attrs):
@ -782,7 +781,6 @@ class GrampsParser(UpdateCallback):
def start_attribute(self,attrs): def start_attribute(self,attrs):
self.attribute = RelLib.Attribute() self.attribute = RelLib.Attribute()
self.attribute.conf = int(attrs.get("conf",2))
self.attribute.private = bool(attrs.get("priv")) self.attribute.private = bool(attrs.get("priv"))
self.attribute.type = RelLib.AttributeType() self.attribute.type = RelLib.AttributeType()
if attrs.has_key('type'): if attrs.has_key('type'):
@ -801,7 +799,6 @@ class GrampsParser(UpdateCallback):
def start_address(self,attrs): def start_address(self,attrs):
self.address = RelLib.Address() self.address = RelLib.Address()
self.address.conf = int(attrs.get("conf",2))
self.address.private = bool(attrs.get("priv")) self.address.private = bool(attrs.get("priv"))
def start_bmark(self,attrs): def start_bmark(self,attrs):
@ -1013,11 +1010,13 @@ class GrampsParser(UpdateCallback):
if not self.in_witness: if not self.in_witness:
self.name = RelLib.Name() self.name = RelLib.Name()
self.name.type.set_from_xml_str(attrs['type']) self.name.type.set_from_xml_str(attrs['type'])
self.name.sort_as = int(attrs.get("sort",RelLib.Name.DEF))
self.name.display_as = int(attrs.get("display",RelLib.Name.DEF))
self.name.conf = int(attrs.get("conf",2))
self.name.set_private = bool(attrs.get("priv")) self.name.set_private = bool(attrs.get("priv"))
self.alt_name = bool(attrs.get("alt")) self.alt_name = bool(attrs.get("alt"))
try:
self.name.sort_as = int(attrs["sort"])
self.name.display_as = int(attrs["display"])
except KeyError:
pass
def start_last(self,attrs): def start_last(self,attrs):
self.name.prefix = attrs.get('prefix','') self.name.prefix = attrs.get('prefix','')
@ -1479,11 +1478,11 @@ class GrampsParser(UpdateCallback):
elif self.alt_name: elif self.alt_name:
# former aka tag -- alternate name # former aka tag -- alternate name
if self.name.get_type() == "": if self.name.get_type() == "":
self.name.set_type("Also Known As") self.name.set_type(NameType.AKA)
self.person.add_alternate_name(self.name) self.person.add_alternate_name(self.name)
else: else:
if self.name.get_type() == "": if self.name.get_type() == "":
self.name.set_type("Birth Name") self.name.set_type(NameType.BIRTH)
self.person.set_primary_name (self.name) self.person.set_primary_name (self.name)
self.name = None self.name = None

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2004-2005 Donald N. Allingham # Copyright (C) 2004-2006 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -48,6 +48,14 @@ _GROUP = 12
_SORT = 13 _SORT = 13
_DISPLAY = 14 _DISPLAY = 14
formats = {
Name.LNFN: _("Family name, Given name Patronymic"),
Name.FNLN: _("Given name Family name"),
Name.PTFN: _("Patronymic Given name"),
Name.FN: _("Given name"),
Name.CUSTOM: _("Custom"),
}
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# NameDisplay class # NameDisplay class
@ -57,6 +65,12 @@ class NameDisplay:
""" """
Base class for displaying of Name instances. Base class for displaying of Name instances.
""" """
# FIXME: Is this used anywhere? I cannot see that it is.
sort_field = (Name.get_surname, Name.get_surname,
Name.get_first_name, Name.get_patronymic,
Name.get_first_name)
def __init__(self,use_upper=False): def __init__(self,use_upper=False):
""" """
Creates a new NameDisplay class. Creates a new NameDisplay class.
@ -126,23 +140,8 @@ class NameDisplay:
SurnamePrefix Patronymic SurnameSuffix, FirstName SurnamePrefix Patronymic SurnameSuffix, FirstName
""" """
first = name.first_name return self._ptfn_base(name.first_name,name.suffix,
name.prefix,name.patronymic)
if self.force_upper:
last = name.patronymic.upper()
else:
last = name.patronymic
if name.suffix:
if name.prefix:
return "%s %s %s, %s" % (name.prefix, last, name.suffix, first)
else:
return "%s %s, %s" % (last, name.suffix, first)
else:
if name.prefix:
return "%s %s, %s" % (name.prefix, last, first)
else:
return "%s, %s" % (last, first)
def _ptfn_raw(self,raw_data): def _ptfn_raw(self,raw_data):
""" """
@ -157,6 +156,9 @@ class NameDisplay:
prefix = raw_data[_PREFIX] prefix = raw_data[_PREFIX]
patronymic = raw_data[_PATRONYM] patronymic = raw_data[_PATRONYM]
return self._ptfn_base(first,suffix,prefix,patronymic)
def _ptfn_base(self,first,suffix,prefix,patronymic):
if self.force_upper: if self.force_upper:
last = patronymic.upper() last = patronymic.upper()
else: else:
@ -180,26 +182,8 @@ class NameDisplay:
FirstName Patronymic SurnamePrefix Surname SurnameSuffix FirstName Patronymic SurnamePrefix Surname SurnameSuffix
""" """
first = name.first_name return self._fnln_base(name.first_name,name.surname,name.suffix,
name.prefix,name.patronymic)
if name.patronymic:
first = "%s %s" % (first, name.patronymic)
if self.force_upper:
last = name.surname.upper()
else:
last = name.surname
if name.suffix:
if name.prefix:
return "%s %s %s, %s" % (first, name.prefix, last, name.suffix)
else:
return "%s %s, %s" % (first, last, name.suffix)
else:
if name.prefix:
return "%s %s %s" % (first, name.prefix, last)
else:
return "%s %s" % (first, last)
def _fnln_raw(self,raw_data): def _fnln_raw(self,raw_data):
""" """
@ -213,7 +197,9 @@ class NameDisplay:
suffix = raw_data[_SUFFIX] suffix = raw_data[_SUFFIX]
prefix = raw_data[_PREFIX] prefix = raw_data[_PREFIX]
patronymic = raw_data[_PATRONYM] patronymic = raw_data[_PATRONYM]
return self._fnln_base(first,surname,suffix,prefix,patronymic)
def _fnln_base(self,first,surname,suffix,prefix,patronymic):
if patronymic: if patronymic:
first = "%s %s" % (first, patronymic) first = "%s %s" % (first, patronymic)
@ -240,16 +226,8 @@ class NameDisplay:
SurnamePrefix Surname, FirstName Patronymic SurnameSuffix SurnamePrefix Surname, FirstName Patronymic SurnameSuffix
""" """
if self.force_upper: return self._lnfn_base(name.first_name,name.surname,name.prefix,
last = name.surname.upper() name.suffix,name.patronymic)
else:
last = name.surname
if last:
last += ","
return " ".join([x for x in [name.prefix, last, name.first_name,
name.patronymic, name.suffix]])
def _lnfn_raw(self,raw_data): def _lnfn_raw(self,raw_data):
""" """
@ -258,17 +236,25 @@ class NameDisplay:
SurnamePrefix Surname, FirstName Patronymic SurnameSuffix SurnamePrefix Surname, FirstName Patronymic SurnameSuffix
""" """
surname = raw_data[_SURNAME]
prefix = raw_data[_PREFIX]
first = raw_data[_FIRSTNAME]
patronymic = raw_data[_PATRONYM]
suffix = raw_data[_SUFFIX]
return self._lnfn_base(first,surname,prefix,suffix,patronymic)
def _lnfn_base(self,first,surname,prefix,suffix,patronymic):
if self.force_upper: if self.force_upper:
last = raw_data[_SURNAME].upper() last = surname.upper()
else: else:
last = raw_data[_SURNAME] last = surname
if last: if last:
last += "," last += ","
return " ".join([x for x in return " ".join([prefix, last, first, patronymic, suffix])
[raw_data[_PREFIX], last, raw_data[_FIRSTNAME],
raw_data[_PATRONYM], raw_data[_SUFFIX]]])
def sorted_name(self,name): def sorted_name(self,name):
""" """
@ -363,10 +349,6 @@ class NameDisplay:
return self.name_grouping_name(db,person.primary_name) return self.name_grouping_name(db,person.primary_name)
sort_field = (Name.get_surname, Name.get_surname,
Name.get_first_name, Name.get_patronymic,
Name.get_first_name)
def name_grouping_name(self,db,pn): def name_grouping_name(self,db,pn):
if pn.group_as: if pn.group_as:
return pn.group_as return pn.group_as

View File

@ -55,11 +55,11 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
A person may have more that one name throughout his or her life. A person may have more that one name throughout his or her life.
""" """
DEF = 0 # locale default CUSTOM = -1 # user-built ordering
LNFN = 1 # last name first name [patronymic] LNFN = 0 # last name first name [patronymic]
FNLN = 2 # first name last name FNLN = 1 # first name last name
PTFN = 3 # patronymic last name PTFN = 2 # patronymic first name
FN = 4 # first name FN = 3 # first name
def __init__(self,source=None,data=None): def __init__(self,source=None,data=None):
"""creates a new Name instance, copying from the source if provided""" """creates a new Name instance, copying from the source if provided"""
@ -105,8 +105,8 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
self.patronymic = "" self.patronymic = ""
self.sname = '@' self.sname = '@'
self.group_as = "" self.group_as = ""
self.sort_as = self.DEF self.sort_as = self.LNFN
self.display_as = self.DEF self.display_as = self.LNFN
self.call = '' self.call = ''
def serialize(self): def serialize(self):
@ -199,8 +199,7 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
def get_sort_as(self): def get_sort_as(self):
""" """
Returns the selected sorting method for the name. The options are Returns the selected sorting method for the name. The options are
DEF (default for the current locale), LNFN (last name, first name), LNFN (last name, first name), FNLN (first name, last name), etc.
or FNLN (first name, last name).
""" """
return self.sort_as return self.sort_as
@ -215,8 +214,7 @@ class Name(SecondaryObject,PrivacyBase,SourceBase,NoteBase,DateBase):
def get_display_as(self): def get_display_as(self):
""" """
Returns the selected display format for the name. The options are Returns the selected display format for the name. The options are
DEF (default for the current locale), LNFN (last name, first name), LNFN (last name, first name), FNLN (first name, last name), etc.
or FNLN (first name, last name).
""" """
return self.display_as return self.display_as