Working namedisplay
Working display section in preferences svn: r15946
This commit is contained in:
parent
f111dcbad9
commit
e9599d762d
17
src/Utils.py
17
src/Utils.py
@ -1095,13 +1095,18 @@ def profile(func, *args):
|
||||
# keyword, code, translated standard, translated upper
|
||||
KEYWORDS = [("title", "t", _("Person|Title"), _("Person|TITLE")),
|
||||
("given", "f", _("Given"), _("GIVEN")),
|
||||
("prefix", "p", _("Prefix"), _("PREFIX")),
|
||||
("surname", "l", _("Surname"), _("SURNAME")),
|
||||
("surname", "l", _("Surname"), _("SURNAME")),
|
||||
("call", "c", _("Name|Call"), _("Name|CALL")),
|
||||
("common", "x", _("Name|Common"), _("Name|COMMON")),
|
||||
("initials", "i", _("Initials"), _("INITIALS")),
|
||||
("suffix", "s", _("Suffix"), _("SUFFIX")),
|
||||
("patronymic","y", _("Patronymic"),_("PATRONYMIC")),
|
||||
("call", "c", _("Call"), _("CALL")),
|
||||
("common", "x", _("Common"), _("COMMON")),
|
||||
("initials", "i", _("Initials"), _("INITIALS"))
|
||||
("rawsurnames", "q", _("Rawsurnames"), _("RAWSURNAMES")),
|
||||
("patronymic", "y", _("Patronymic"), _("PATRONYMIC")),
|
||||
("notpatronymic", "o", _("Notpatronymic"),_("NOTPATRONYMIC")),
|
||||
("primary", "m", _("Primary"), _("PRIMARY")),
|
||||
("prefix", "p", _("Prefix"), _("PREFIX")),
|
||||
("nickname", "n", _("Nickname"), _("NICKNAME")),
|
||||
("familynick", "g", _("Familynick"), _("FAMILYNICK")),
|
||||
]
|
||||
KEY_TO_TRANS = {}
|
||||
TRANS_TO_KEY = {}
|
||||
|
@ -31,7 +31,7 @@ Specific symbols for parts of a name are defined:
|
||||
'c' : callname
|
||||
'x' : callname if existing, otherwise first first name (common name)
|
||||
'i' : initials of the first names
|
||||
'f' : patronymic surname (father)
|
||||
'y' : patronymic surname (father)
|
||||
'o' : surnames without patronymic
|
||||
'm' : primary surname (main)
|
||||
'p' : list of all prefixes
|
||||
@ -101,7 +101,11 @@ _F_RAWFN = 4 # name format raw function
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# Because of occurring in an exec(), this couldn't be in a lambda:
|
||||
def _make_cmp(a, b): return -cmp(a[1], b[1])
|
||||
# we sort names first on longest first, then last letter first, this to
|
||||
# avoid translations of shorter terms which appear in longer ones, eg
|
||||
# namelast may not be mistaken with name, so namelast must first be
|
||||
# converted to %k before name is converted.
|
||||
def _make_cmp(a, b): return -cmp((len(a[1]),a[1]), (len(b[1]), b[1]))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -144,7 +148,7 @@ def _raw_primary_surname(raw_surn_data_list):
|
||||
return ''
|
||||
|
||||
def _raw_patro_surname(raw_surn_data_list):
|
||||
"""method for the 'f' symbol: patronymic surname"""
|
||||
"""method for the 'y' symbol: patronymic surname"""
|
||||
for raw_surn_data in raw_surn_data_list:
|
||||
if raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINPATRO:
|
||||
result = "%s %s" % (raw_surn_data[_PREFIX_IN_LIST],
|
||||
@ -191,11 +195,11 @@ class NameDisplay(object):
|
||||
|
||||
STANDARD_FORMATS = [
|
||||
(Name.DEF,_("Default format (defined by Gramps preferences)"),'',_ACT),
|
||||
(Name.LNFN,_("Surname, Given"),'%p %l, %f %s',_ACT),
|
||||
(Name.LNFN,_("Surname, Given"),'%l, %f %s',_ACT),
|
||||
(Name.FN,_("Given"),'%f',_ACT),
|
||||
(Name.FNLN,_("Given Surname"),'%f %p %l %s',_ACT),
|
||||
(Name.FNLN,_("Given Surname"),'%f %l %s',_ACT),
|
||||
# DEPRECATED FORMATS
|
||||
(Name.PTFN,_("Patronymic, Given"),'%p %y, %s %f',_INA),
|
||||
(Name.PTFN,_("Patronymic, Given"),'%y, %s %f',_INA),
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
@ -352,21 +356,21 @@ class NameDisplay(object):
|
||||
raw_data[_FIRSTNAME],
|
||||
raw_data[_SUFFIX])
|
||||
|
||||
Specific symbols for parts of a name are defined:
|
||||
't' : title
|
||||
'f' : given (first names)
|
||||
'l' : full surname (lastname)
|
||||
'c' : callname
|
||||
'x' : callname if existing, otherwise first first name (common name)
|
||||
'i' : initials of the first names
|
||||
'f' : patronymic surname (father)
|
||||
'o' : surnames without patronymic
|
||||
'm' : primary surname (main)
|
||||
'p' : list of all prefixes
|
||||
'q' : surnames without prefixes and connectors
|
||||
's' : suffix
|
||||
'n' : nick name
|
||||
'g' : family nick name
|
||||
Specific symbols for parts of a name are defined (keywords given):
|
||||
't' : title = title
|
||||
'f' : given = given (first names)
|
||||
'l' : surname = full surname (lastname)
|
||||
'c' : call = callname
|
||||
'x' : common = callname if existing, otherwise first first name (common name)
|
||||
'i' : initials = initials of the first names
|
||||
'y' : patronymic = patronymic surname (father)
|
||||
'o' : notpatronymic = surnames without patronymic
|
||||
'm' : primary = primary surname (main)
|
||||
'p' : prefix = list of all prefixes
|
||||
'q' : rawsurnames = surnames without prefixes and connectors
|
||||
's' : suffix = suffix
|
||||
'n' : nickname = nick name
|
||||
'g' : familynick = family nick name
|
||||
|
||||
"""
|
||||
|
||||
@ -374,39 +378,39 @@ class NameDisplay(object):
|
||||
# called to fill in each format flag.
|
||||
# Dictionary is "code": ("expression", "keyword", "i18n-keyword")
|
||||
d = {"t": ("raw_data[_TITLE]", "title",
|
||||
_("String replacement keyword Person|title")),
|
||||
_("Person|title")),
|
||||
"f": ("raw_data[_FIRSTNAME]", "given",
|
||||
_("String replacement keyword|given")),
|
||||
_("given")),
|
||||
"l": ("_raw_full_surname(raw_data[_SURNAME_LIST])", "surname",
|
||||
_("String replacement keyword|surname")),
|
||||
_("surname")),
|
||||
"s": ("raw_data[_SUFFIX]", "suffix",
|
||||
_("String replacement keyword|suffix")),
|
||||
_("suffix")),
|
||||
"c": ("raw_data[_CALL]", "call",
|
||||
_("String replacement keyword|call")),
|
||||
_("Name|call")),
|
||||
"x": ("(raw_data[_CALL] or raw_data[_FIRSTNAME].split(' ')[0])",
|
||||
"common",
|
||||
_("String replacement keyword|common")),
|
||||
_("Name|common")),
|
||||
"i": ("''.join([word[0] +'.' for word in ('. ' +" +
|
||||
" raw_data[_FIRSTNAME]).split()][1:])",
|
||||
"initials",
|
||||
_("String replacement keyword|initials")),
|
||||
"f": ("_raw_patro_surname(raw_data[_SURNAME_LIST])", "patronymic",
|
||||
_("String replacement keyword|patronymic")),
|
||||
_("initials")),
|
||||
"y": ("_raw_patro_surname(raw_data[_SURNAME_LIST])", "patronymic",
|
||||
_("patronymic")),
|
||||
"o": ("_raw_nonpatro_surname(raw_data[_SURNAME_LIST])", "notpatronymic",
|
||||
_("String replacement keyword|notpatronymic")),
|
||||
_("notpatronymic")),
|
||||
"m": ("_raw_primary_surname(raw_data[_SURNAME_LIST])",
|
||||
"primarysurname",
|
||||
_("String replacement keyword|primarysurname")),
|
||||
"primary",
|
||||
_("Name|primary")),
|
||||
"p": ("_raw_prefix_surname(raw_data[_SURNAME_LIST])",
|
||||
"prefix",
|
||||
_("String replacement keyword|prefix")),
|
||||
_("prefix")),
|
||||
"q": ("_raw_single_surname(raw_data[_SURNAME_LIST])",
|
||||
"rawsurnames",
|
||||
_("String replacement keyword|rawsurnames")),
|
||||
_("rawsurnames")),
|
||||
"n": ("raw_data[_NICK]", "nickname",
|
||||
_("String replacement keyword|nickname")),
|
||||
"g": ("raw_data[_FAMNICK]", "famnick",
|
||||
_("String replacement keyword|famnick")),
|
||||
_("nickname")),
|
||||
"g": ("raw_data[_FAMNICK]", "familynick",
|
||||
_("familynick")),
|
||||
}
|
||||
args = "raw_data"
|
||||
return self._make_fn(format_str, d, args)
|
||||
@ -427,55 +431,56 @@ class NameDisplay(object):
|
||||
def fn(first, raw_surname_list, suffix, title, call,):
|
||||
return "%s %s" % (first,suffix)
|
||||
|
||||
Specific symbols for parts of a name are defined:
|
||||
't' : title
|
||||
'f' : given (first names)
|
||||
'l' : full surname (lastname)
|
||||
'c' : callname
|
||||
'x' : callname if existing, otherwise first first name (common name)
|
||||
'i' : initials of the first names
|
||||
'f' : patronymic surname (father)
|
||||
'o' : surnames without patronymic
|
||||
'm' : primary surname (main)
|
||||
'p' : list of all prefixes
|
||||
'q' : surnames without prefixes and connectors
|
||||
's' : suffix
|
||||
'n' : nick name
|
||||
'g' : family nick name
|
||||
Specific symbols for parts of a name are defined (keywords given):
|
||||
't' : title = title
|
||||
'f' : given = given (first names)
|
||||
'l' : surname = full surname (lastname)
|
||||
'c' : call = callname
|
||||
'x' : common = callname if existing, otherwise first first name (common name)
|
||||
'i' : initials = initials of the first names
|
||||
'y' : patronymic = patronymic surname (father)
|
||||
'o' : notpatronymic = surnames without patronymic
|
||||
'm' : primary = primary surname (main)
|
||||
'p' : prefix = list of all prefixes
|
||||
'q' : rawsurnames = surnames without prefixes and connectors
|
||||
's' : suffix = suffix
|
||||
'n' : nickname = nick name
|
||||
'g' : familynick = family nick name
|
||||
|
||||
"""
|
||||
|
||||
# we need the names of each of the variables or methods that are
|
||||
# called to fill in each format flag.
|
||||
# Dictionary is "code": ("expression", "keyword", "i18n-keyword")
|
||||
d = {"t": ("title", "title",
|
||||
_("String replacement keyword Person|title")),
|
||||
_("Person|title")),
|
||||
"f": ("first", "given",
|
||||
_("String replacement keyword|given")),
|
||||
_("given")),
|
||||
"l": ("_raw_full_surname(raw_surname_list)", "surname",
|
||||
_("String replacement keyword|surname")),
|
||||
_("surname")),
|
||||
"s": ("suffix", "suffix",
|
||||
_("String replacement keyword|suffix")),
|
||||
_("suffix")),
|
||||
"c": ("call", "call",
|
||||
_("String replacement keyword|call")),
|
||||
_("Name|call")),
|
||||
"x": ("(call or first.split(' ')[0])", "common",
|
||||
_("String replacement keyword|common")),
|
||||
_("Name|common")),
|
||||
"i": ("''.join([word[0] +'.' for word in ('. ' + first).split()][1:])",
|
||||
"initials",
|
||||
_("String replacement keyword|initials")),
|
||||
"f": ("_raw_patro_surname(raw_surname_list)", "patronymic",
|
||||
_("String replacement keyword|patronymic")),
|
||||
"o": ("_raw_nonpatro_surname(raw_surname_list)", "notpatro",
|
||||
_("String replacement keyword|notpatro")),
|
||||
_("initials")),
|
||||
"y": ("_raw_patro_surname(raw_surname_list)", "patronymic",
|
||||
_("patronymic")),
|
||||
"o": ("_raw_nonpatro_surname(raw_surname_list)", "notpatronymic",
|
||||
_("notpatronymic")),
|
||||
"m": ("_raw_primary_surname(raw_surname_list)", "primary",
|
||||
_("String replacement keyword name|primary")),
|
||||
_("Name|primary")),
|
||||
"p": ("_raw_prefix_surname(raw_surname_list)", "prefix",
|
||||
_("String replacement keyword|prefix")),
|
||||
"q": ("_raw_single_surname(raw_surname_list)", "rawlastnames",
|
||||
_("String replacement keyword|rawlastnames")),
|
||||
_("prefix")),
|
||||
"q": ("_raw_single_surname(raw_surname_list)", "rawsurnames",
|
||||
_("rawsurnames")),
|
||||
"n": ("nick", "nickname",
|
||||
_("String replacement keyword|nickname")),
|
||||
"g": ("famnick", "famnick",
|
||||
_("String replacement keyword|famnick")),
|
||||
_("nickname")),
|
||||
"g": ("famnick", "familynick",
|
||||
_("familynick")),
|
||||
}
|
||||
args = "first,raw_surname_list,suffix,title,call,nick,famnick"
|
||||
return self._make_fn(format_str, d, args)
|
||||
@ -497,7 +502,7 @@ class NameDisplay(object):
|
||||
pass
|
||||
else:
|
||||
d_keys = [(code, _tuple[2]) for code, _tuple in d.iteritems()]
|
||||
d_keys.sort(_make_cmp) # reverse sort by ikeyword
|
||||
d_keys.sort(_make_cmp) # reverse on length and by ikeyword
|
||||
for (code, ikeyword) in d_keys:
|
||||
exp, keyword, ikeyword = d[code]
|
||||
#ikeyword = unicode(ikeyword, "utf8")
|
||||
@ -513,7 +518,7 @@ class NameDisplay(object):
|
||||
pass
|
||||
else:
|
||||
d_keys = [(code, _tuple[1]) for code, _tuple in d.iteritems()]
|
||||
d_keys.sort(_make_cmp) # reverse sort by keyword
|
||||
d_keys.sort(_make_cmp) # reverse sort on length and by keyword
|
||||
# if in double quotes, just use % codes
|
||||
for (code, keyword) in d_keys:
|
||||
exp, keyword, ikeyword = d[code]
|
||||
@ -613,7 +618,7 @@ def fn(%s):
|
||||
'%c' : callname
|
||||
'%x' : callname if existing, otherwise first first name (common name)
|
||||
'%i' : initials of the first names
|
||||
'%f' : patronymic surname (father)
|
||||
'%y' : patronymic surname (father)
|
||||
'%o' : surnames without patronymic
|
||||
'%m' : primary surname (main)
|
||||
'%p' : list of all prefixes
|
||||
|
@ -188,5 +188,8 @@ class Surname(SecondaryObject):
|
||||
"""Set if this surname is the primary surname.replace
|
||||
Use :class:`~gen.lib.surname.SurnameBase` to set the primary surname
|
||||
via :method:`~gen.lib.surname.SurnameBase.set_primary_surname`
|
||||
|
||||
:param primary: primay surname or not
|
||||
:type primary: bool
|
||||
"""
|
||||
self.primary = primary
|
||||
|
@ -53,7 +53,7 @@ from gen.display.name import displayer as _nd
|
||||
from gen.display.name import NameDisplayError
|
||||
import Utils
|
||||
import gen.lib
|
||||
from gen.lib import Name
|
||||
from gen.lib import Name, Surname, NameOriginType
|
||||
import ManagedWindow
|
||||
from gui.widgets import MarkupLabel, BasicLabel
|
||||
from QuestionDialog import ErrorDialog, QuestionDialog2, OkDialog
|
||||
@ -98,21 +98,28 @@ class DisplayNameEditor(ManagedWindow.ManagedWindow):
|
||||
table = self.dialog._build_custom_name_ui()
|
||||
label = gtk.Label(_("""The following keywords will be replaced with the name:
|
||||
<tt>
|
||||
<b>Given</b> - given name (first name)
|
||||
<b>Surname</b> - surname (last name)
|
||||
<b>Title</b> - title (Dr., Mrs.)
|
||||
<b>Prefix</b> - prefix (von, de, de la)
|
||||
<b>Suffix</b> - suffix (Jr., Sr.)
|
||||
<b>Call</b> - call name, or nickname
|
||||
<b>Common</b> - call name, otherwise first part of Given
|
||||
<b>Patronymic</b> - patronymic (father's name)
|
||||
<b>Initials</b> - persons's first letters of given names
|
||||
<b>Given</b> - given name (first name) | <b>Surname</b> - surnames (with prefix and connectors)
|
||||
<b>Title</b> - title (Dr., Mrs.) | <b>Suffix</b> - suffix (Jr., Sr.)
|
||||
<b>Call</b> - call name | <b>Nickname</b> - nick name
|
||||
<b>Initials</b> - first letters of Given | <b>Common</b> - Call, otherwise first of Given
|
||||
<b>Primary</b> - primary surname (main) | <b>Familynick</b> - Family nick name
|
||||
Also:
|
||||
<b>Patronymic</b> - patronymic surname (father's name)
|
||||
<b>Notpatronymic</b> - all surnames except patronymic
|
||||
<b>Prefix</b> - all surnames prefixes (von, de, de la)
|
||||
<b>Rawsurnames</b> - all surnames without prefixes and connectors
|
||||
</tt>
|
||||
Use the same keyword in UPPERCASE to force to upper. Parentheses and commas
|
||||
will be removed around empty fields. Other text will appear literally."""))
|
||||
will be removed around empty fields. Other text will appear literally.
|
||||
|
||||
<b>Example fictituous name</b>: 'Dr. Edwin Jose von der Smith and Weston Wilson Sr ("Ed") - Underhills'
|
||||
Here <i>Edwin Jose</i> are given names, <i>Smith</i> and <i>Weston</i> surnames, <i>Wilson</i> patronymic surname,
|
||||
<i>Dr.</i> a title, <i>Sr</i> a suffix, <i>Ed</i> the nick name, <i>Underhills</i> family nick name.
|
||||
Callname is <i>Jose</i>.
|
||||
"""))
|
||||
label.set_use_markup(True)
|
||||
self.window.vbox.add(label)
|
||||
self.window.vbox.add(table)
|
||||
self.window.vbox.pack_start(label, expand=False)
|
||||
self.window.vbox.pack_start(table)
|
||||
self.window.set_default_size(600, 550)
|
||||
self.window.connect('response', self.close)
|
||||
self.show()
|
||||
@ -520,7 +527,7 @@ class GrampsPreferences(ConfigureDialog):
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING)
|
||||
index = 0
|
||||
index = 0
|
||||
the_index = 0
|
||||
for num, name, fmt_str, act in _nd.get_name_format():
|
||||
translation = fmt_str
|
||||
@ -538,40 +545,49 @@ class GrampsPreferences(ConfigureDialog):
|
||||
lyst = ["%s, %s %s (%s)" % (_("Surname"), _("Given"), _("Suffix"),
|
||||
_("Common")),
|
||||
"%s, %s %s (%s)" % (_("Surname"), _("Given"), _("Suffix"),
|
||||
_("Call")),
|
||||
_("Nickname")),
|
||||
"%s, %s %s (%s)" % (_("Surname"), _("Name|Common"), _("Suffix"),
|
||||
_("Nickname")),
|
||||
"%s, %s %s" % (_("Surname"), _("Name|Common"), _("Suffix")),
|
||||
"%s, %s %s (%s)" % (_("SURNAME"), _("Given"), _("Suffix"),
|
||||
_("Call")),
|
||||
"%s, %s (%s)" % (_("Surname"), _("Given"), _("Common")),
|
||||
"%s, %s (%s)" % (_("Surname"), _("Given"), _("Call")),
|
||||
"%s, %s (%s)" % (_("Surname"), _("Given"), _("Name|Common")),
|
||||
"%s, %s (%s)" % (_("Surname"), _("Name|Common"), _("Nickname")),
|
||||
"%s %s" % (_("Given"), _("Surname")),
|
||||
"%s %s, %s" % (_("Given"), _("Surname"), _("Suffix")),
|
||||
"%s %s %s" % (_("Given"), _("Surname"), _("Patronymic")),
|
||||
"%s %s %s" % (_("Given"), _("NotPatronymic"), _("Patronymic")),
|
||||
"%s, %s %s (%s)" % (_("SURNAME"), _("Given"), _("Suffix"),
|
||||
_("Common")),
|
||||
"%s, %s (%s)" % (_("SURNAME"), _("Given"), _("Common")),
|
||||
"%s, %s (%s)" % (_("SURNAME"), _("Given"), _("Call")),
|
||||
"%s, %s (%s)" % (_("SURNAME"), _("Given"), _("Name|Common")),
|
||||
"%s, %s (%s)" % (_("SURNAME"), _("Given"), _("Nickname")),
|
||||
"%s %s" % (_("Given"), _("SURNAME")),
|
||||
"%s %s, %s" % (_("Given"), _("SURNAME"), _("Suffix")),
|
||||
"%s /%s/" % (_("Given"), _("SURNAME")),
|
||||
"%s %s, %s" % (_("Given"), _("Rawsurnames"), _("Suffix")),
|
||||
]
|
||||
fmtlyst = ["%s, %s %s (%s)" % ("Surname", "Given", "Suffix",
|
||||
"Common"),
|
||||
"%s, %s %s (%s)" % ("Surname", "Given", "Suffix",
|
||||
"Call"),
|
||||
"%s, %s %s (%s)" % ("SURNAME", "Given", "Suffix",
|
||||
"Call"),
|
||||
"%s, %s (%s)" % ("Surname", "Given", "Common"),
|
||||
"%s, %s (%s)" % ("Surname", "Given", "Call"),
|
||||
"%s %s" % ("Given", "Surname"),
|
||||
"%s %s, %s" % ("Given", "Surname", "Suffix"),
|
||||
"%s %s %s" % ("Given", "Surname", "Patronymic"),
|
||||
"%s, %s %s (%s)" % ("SURNAME", "Given", "Suffix",
|
||||
"Common"),
|
||||
"%s, %s (%s)" % ("SURNAME", "Given", "Common"),
|
||||
"%s, %s (%s)" % ("SURNAME", "Given", "Call"),
|
||||
"%s %s" % ("Given", "SURNAME"),
|
||||
"%s %s, %s" % ("Given", "SURNAME", "Suffix"),
|
||||
"%s /%s/" % ("Given", "SURNAME"),
|
||||
#repeat above list, but not translated.
|
||||
fmtlyst = ["%s, %s %s (%s)" % (("Surname"), ("Given"), ("Suffix"),
|
||||
("Common")),
|
||||
"%s, %s %s (%s)" % (("Surname"), ("Given"), ("Suffix"),
|
||||
("Nickname")),
|
||||
"%s, %s %s (%s)" % (("Surname"), ("Name|Common"), ("Suffix"),
|
||||
("Nickname")),
|
||||
"%s, %s %s" % (("Surname"), ("Name|Common"), ("Suffix")),
|
||||
"%s, %s %s (%s)" % (("SURNAME"), ("Given"), ("Suffix"),
|
||||
("Call")),
|
||||
"%s, %s (%s)" % (("Surname"), ("Given"), ("Name|Common")),
|
||||
"%s, %s (%s)" % (("Surname"), ("Name|Common"), ("Nickname")),
|
||||
"%s %s" % (("Given"), ("Surname")),
|
||||
"%s %s, %s" % (("Given"), ("Surname"), ("Suffix")),
|
||||
"%s %s %s" % (("Given"), ("NotPatronymic"), ("Patronymic")),
|
||||
"%s, %s %s (%s)" % (("SURNAME"), ("Given"), ("Suffix"),
|
||||
("Common")),
|
||||
"%s, %s (%s)" % (("SURNAME"), ("Given"), ("Name|Common")),
|
||||
"%s, %s (%s)" % (("SURNAME"), ("Given"), ("Nickname")),
|
||||
"%s %s" % (("Given"), ("SURNAME")),
|
||||
"%s %s, %s" % (("Given"), ("SURNAME"), ("Suffix")),
|
||||
"%s /%s/" % (("Given"), ("SURNAME")),
|
||||
"%s %s, %s" % (("Given"), ("Rawsurnames"), ("Suffix")),
|
||||
]
|
||||
rand = int(random.random() * len(lyst))
|
||||
f = lyst[rand]
|
||||
@ -722,11 +738,9 @@ class GrampsPreferences(ConfigureDialog):
|
||||
|
||||
self.insert_button = gtk.Button(stock=gtk.STOCK_ADD)
|
||||
self.insert_button.connect('clicked', self.__new_name)
|
||||
#self.cb_insert_fmt_str)
|
||||
|
||||
self.edit_button = gtk.Button(stock=gtk.STOCK_EDIT)
|
||||
self.edit_button.connect('clicked', self.__edit_name)
|
||||
#self.cb_edit_fmt_str)
|
||||
self.edit_button.set_sensitive(False)
|
||||
|
||||
self.remove_button = gtk.Button(stock=gtk.STOCK_REMOVE)
|
||||
@ -781,44 +795,6 @@ class GrampsPreferences(ConfigureDialog):
|
||||
self.edit_button.set_sensitive(idx)
|
||||
self.name_renderer.set_property('editable', idx)
|
||||
|
||||
|
||||
def cb_edit_fmt_str(self, obj):
|
||||
"""
|
||||
Name format editor Edit button callback
|
||||
"""
|
||||
num, name, fmt = self.selected_fmt[COL_NUM:COL_EXPL]
|
||||
dlg = NameFormatEditDlg(name, fmt, self.examplename)
|
||||
dlg.dlg.set_transient_for(self.window)
|
||||
(res, name, fmt) = dlg.run()
|
||||
|
||||
if res == gtk.RESPONSE_OK and (name != self.selected_fmt[COL_NAME] or
|
||||
fmt != self.selected_fmt[COL_FMT]):
|
||||
exmpl = _nd.format_str(self.examplename, fmt)
|
||||
self.fmt_model.set(self.iter, COL_NAME, name,
|
||||
COL_FMT, fmt,
|
||||
COL_EXPL, exmpl)
|
||||
self.selected_fmt = (num, name, fmt, exmpl)
|
||||
_nd.edit_name_format(num, name, fmt)
|
||||
|
||||
self.dbstate.db.name_formats = _nd.get_name_format(only_custom=True,
|
||||
only_active=False)
|
||||
|
||||
def cb_insert_fmt_str(self, obj):
|
||||
"""
|
||||
Name format editor Insert button callback
|
||||
"""
|
||||
dlg = NameFormatEditDlg('', '', self.examplename)
|
||||
dlg.dlg.set_transient_for(self.window)
|
||||
(res, n, f) = dlg.run()
|
||||
|
||||
if res == gtk.RESPONSE_OK:
|
||||
i = _nd.add_name_format(n, f)
|
||||
self.fmt_model.append(row=[i, n, f,
|
||||
_nd.format_str(self.examplename, f)])
|
||||
|
||||
self.dbstate.db.name_formats = _nd.get_name_format(only_custom=True,
|
||||
only_active=False)
|
||||
|
||||
def cb_del_fmt_str(self, obj):
|
||||
"""
|
||||
Name format editor Remove button callback
|
||||
@ -842,13 +818,26 @@ class GrampsPreferences(ConfigureDialog):
|
||||
|
||||
# Display name:
|
||||
self.examplename = Name()
|
||||
examplesurname = Surname()
|
||||
examplesurnamesecond = Surname()
|
||||
examplesurnamepat = Surname()
|
||||
self.examplename.set_title('Dr.')
|
||||
self.examplename.set_first_name('Edwin Jose')
|
||||
self.examplename.set_surname_prefix('von der')
|
||||
self.examplename.set_surname('Smith')
|
||||
examplesurname.set_prefix('von der')
|
||||
examplesurname.set_surname('Smith')
|
||||
examplesurname.set_connector('and')
|
||||
self.examplename.add_surname(examplesurname)
|
||||
examplesurnamesecond.set_surname('Weston')
|
||||
self.examplename.add_surname(examplesurnamesecond)
|
||||
examplesurnamepat.set_surname('Wilson')
|
||||
examplesurnamepat.set_origintype(
|
||||
NameOriginType(NameOriginType.PATRONYMIC))
|
||||
self.examplename.add_surname(examplesurnamepat)
|
||||
self.examplename.set_primary_surname(0)
|
||||
self.examplename.set_suffix('Sr')
|
||||
self.examplename.set_patronymic('Wilson')
|
||||
self.examplename.set_call_name('Ed')
|
||||
self.examplename.set_call_name('Jose')
|
||||
self.examplename.set_nick_name('Ed')
|
||||
self.examplename.set_family_nick_name('Underhills')
|
||||
# get the model for the combo and the treeview
|
||||
active = _nd.get_default_format()
|
||||
self.fmt_model, active = self._build_name_format_model(active)
|
||||
@ -1186,71 +1175,3 @@ class GrampsPreferences(ConfigureDialog):
|
||||
button.add(image)
|
||||
button.show()
|
||||
return button
|
||||
|
||||
class NameFormatEditDlg(object):
|
||||
"""
|
||||
"""
|
||||
|
||||
def __init__(self, fmt_name, fmt_str, name):
|
||||
self.fmt_name = fmt_name
|
||||
self.fmt_str = fmt_str
|
||||
self.name = name
|
||||
self.valid = True
|
||||
self.top = Glade()
|
||||
|
||||
self.dlg = self.top.get_object('namefmt_edit')
|
||||
ManagedWindow.set_titles(self.dlg, None, _('Name Format Editor'))
|
||||
|
||||
self.examplelabel = self.top.get_object('example_label')
|
||||
|
||||
self.nameentry = self.top.get_object('name_entry')
|
||||
self.nameentry.set_text('<span weight="bold">%s</span>' % self.fmt_name)
|
||||
self.nameentry.set_use_markup(True)
|
||||
|
||||
self.formatentry = self.top.get_object('format_entry')
|
||||
self.formatentry.connect('changed', self.cb_format_changed)
|
||||
self.formatentry.set_text(self.fmt_str)
|
||||
|
||||
def run(self):
|
||||
running = True
|
||||
while running:
|
||||
self.response = self.dlg.run()
|
||||
|
||||
running = False
|
||||
self.fmt_name = self.nameentry.get_text()
|
||||
self.fmt_str = self.formatentry.get_text()
|
||||
|
||||
if self.response == gtk.RESPONSE_OK:
|
||||
if not self.valid:
|
||||
q = QuestionDialog2(
|
||||
_('The format definition is invalid'),
|
||||
_('What would you like to do?'),
|
||||
_('_Continue anyway'), _('_Modify format'),
|
||||
parent=self.dlg)
|
||||
running = not q.run()
|
||||
self.response = gtk.RESPONSE_CANCEL
|
||||
elif self.fmt_name == '' and self.fmt_str == '':
|
||||
self.response = gtk.RESPONSE_CANCEL
|
||||
elif (self.fmt_name == '') ^ (self.fmt_str == ''):
|
||||
ErrorDialog(
|
||||
_('Both Format name and definition have to be defined.'),
|
||||
parent=self.dlg)
|
||||
running = True
|
||||
|
||||
self.dlg.destroy()
|
||||
return (self.response, self.fmt_name, self.fmt_str)
|
||||
|
||||
def cb_format_changed(self, obj):
|
||||
try:
|
||||
t = (_nd.format_str(self.name, escape(obj.get_text())))
|
||||
sample = '<span weight="bold" style="italic">%s</span>' % t
|
||||
self.valid = True
|
||||
except NameDisplayError:
|
||||
t = _("Invalid or incomplete format definition.")
|
||||
sample = '<span foreground="#FF0000">%s</span>' % t
|
||||
self.valid = False
|
||||
|
||||
self.examplelabel.set_text(sample)
|
||||
self.examplelabel.set_use_markup(True)
|
||||
self.nameentry.set_text('<span weight="bold">%s</span>' % obj.get_text())
|
||||
self.nameentry.set_use_markup(True)
|
||||
|
Loading…
Reference in New Issue
Block a user