diff --git a/src/config.py b/src/config.py index 66bcd053c..1b624c574 100644 --- a/src/config.py +++ b/src/config.py @@ -274,6 +274,7 @@ register('preferences.hide-ep-msg', False) register('preferences.invalid-date-format', "%s") register('preferences.iprefix', 'I%04d') register('preferences.name-format', 1) +register('preferences.patronimic-surname', False) register('preferences.no-given-text', "[%s]" % _("Missing Given Name")) register('preferences.no-record-text', "[%s]" % _("Missing Record")) register('preferences.no-surname-text', "[%s]" % _("Missing Surname")) diff --git a/src/gen/display/name.py b/src/gen/display/name.py index 90a9be010..50531e39a 100644 --- a/src/gen/display/name.py +++ b/src/gen/display/name.py @@ -103,6 +103,8 @@ _F_ACT = 2 # if the format is active _F_FN = 3 # name format function _F_RAWFN = 4 # name format raw function +PAT_AS_SURN = False + #------------------------------------------------------------------------- # # Local functions @@ -148,6 +150,7 @@ def _raw_full_surname(raw_surn_data_list): def _raw_primary_surname(raw_surn_data_list): """method for the 'm' symbol: primary surname""" + global PAT_AS_SURN nrsur = len(raw_surn_data_list) for raw_surn_data in raw_surn_data_list: if raw_surn_data[_PRIMARY_IN_LIST]: @@ -155,7 +158,8 @@ def _raw_primary_surname(raw_surn_data_list): #is only one surname, then primary has little meaning, and we #assume a pa/matronymic should not be given as primary as it #normally is defined independently - if nrsur == 1 and (raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINPATRO + if not PAT_AS_SURN and nrsur == 1 and \ + (raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINPATRO or raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINMATRO): return '' else: @@ -168,10 +172,12 @@ def _raw_primary_surname(raw_surn_data_list): def _raw_primary_surname_only(raw_surn_data_list): """method to obtain the raw primary surname data, so this returns a string """ + global PAT_AS_SURN nrsur = len(raw_surn_data_list) for raw_surn_data in raw_surn_data_list: if raw_surn_data[_PRIMARY_IN_LIST]: - if nrsur == 1 and (raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINPATRO + if not PAT_AS_SURN and nrsur == 1 and \ + (raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINPATRO or raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINMATRO): return '' else: @@ -180,10 +186,12 @@ def _raw_primary_surname_only(raw_surn_data_list): def _raw_primary_prefix_only(raw_surn_data_list): """method to obtain the raw primary surname data""" + global PAT_AS_SURN nrsur = len(raw_surn_data_list) for raw_surn_data in raw_surn_data_list: if raw_surn_data[_PRIMARY_IN_LIST]: - if nrsur == 1 and (raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINPATRO + if not PAT_AS_SURN and nrsur == 1 and \ + (raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINPATRO or raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINMATRO): return '' else: @@ -192,10 +200,12 @@ def _raw_primary_prefix_only(raw_surn_data_list): def _raw_primary_conn_only(raw_surn_data_list): """method to obtain the raw primary surname data""" + global PAT_AS_SURN nrsur = len(raw_surn_data_list) for raw_surn_data in raw_surn_data_list: if raw_surn_data[_PRIMARY_IN_LIST]: - if nrsur == 1 and (raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINPATRO + if not PAT_AS_SURN and nrsur == 1 and \ + (raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINPATRO or raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINMATRO): return '' else: @@ -301,6 +311,11 @@ def cleanup_name(namestring): class NameDisplay(object): """ Base class for displaying of Name instances. + + property: + * default_format: the default name format to use + * pas_as_surn : if only one surname, see if pa/ma should be considered as + 'the' surname. """ format_funcs = {} @@ -321,6 +336,7 @@ class NameDisplay(object): def __init__(self): global WITH_GRAMP_CONFIG + global PAT_AS_SURN self.name_formats = {} if WITH_GRAMPS_CONFIG: @@ -328,13 +344,27 @@ class NameDisplay(object): if self.default_format == 0: self.default_format = Name.LNFN config.set('preferences.name-format', self.default_format) + #if only one surname, see if pa/ma should be considered as + # 'the' surname. + PAT_AS_SURN = config.get('preferences.patronimic-surname') + config.connect('preferences.patronimic-surname', self.change_pa_sur) else: self.default_format = Name.LNFN + PAT_AS_SURN = False #preinit the name formats, this should be updated with the data #in the database once a database is loaded self.set_name_format(self.STANDARD_FORMATS) + def change_pa_sur(self, *args): + """ How to handle single patronymic as surname is changed""" + global PAT_AS_SURN + PAT_AS_SURN = config.get('preferences.patronimic-surname') + + def get_pat_as_surn(self): + global PAT_AS_SURN + return PAT_AS_SURN + def _format_fn(self, fmt_str): return lambda x: self.format_str(x, fmt_str) @@ -719,8 +749,18 @@ class NameDisplay(object): #------------------------------------------------------------------------- + def primary_surname(self, name): + global PAT_AS_SURN + nrsur = len(name.surname_list) + sur = name.get_primary_surname() + if not PAT_AS_SURN and nrsur <= 1 and \ + (sur.get_origintype().value == _ORIGINPATRO + or sur.get_origintype().value == _ORIGINMATRO): + return '' + return sur.get_surname() + def sort_string(self, name): - return u"%-25s%-30s%s" % (name.get_primary_surname().get_surname(), + return u"%-25s%-30s%s" % (self.primary_surname(name), name.first_name, name.suffix) def sorted(self, person): diff --git a/src/gui/configure.py b/src/gui/configure.py index 3bc9a6bd3..bfabc67a3 100644 --- a/src/gui/configure.py +++ b/src/gui/configure.py @@ -250,12 +250,14 @@ class ConfigureDialog(ManagedWindow.ManagedWindow): self.__config.set(constant, int(obj.get_value())) def add_checkbox(self, table, label, index, constant, start=1, stop=9, - config=None): + config=None, extra_callback=None): if not config: config = self.__config checkbox = gtk.CheckButton(label) checkbox.set_active(config.get(constant)) checkbox.connect('toggled', self.update_checkbox, constant, config) + if extra_callback: + checkbox.connect('toggled', extra_callback) table.attach(checkbox, start, stop, index, index+1, yoptions=0) def add_radiobox(self, table, label, index, constant, group, column, @@ -757,7 +759,14 @@ class GrampsPreferences(ConfigureDialog): config.set('preferences.name-format', new_idx) _nd.set_default_format(new_idx) self.uistate.emit('nameformat-changed') - + + def cb_pa_sur_changed(self,*args): + """ + checkbox patronymic as surname changed, propagate to namedisplayer + """ + _nd.change_pa_sur() + self.uistate.emit('nameformat-changed') + def cb_format_tree_select(self, tree_selection): """ Name format editor TreeView callback @@ -843,6 +852,13 @@ class GrampsPreferences(ConfigureDialog): table.attach(lwidget, 0, 1, row, row+1, yoptions=0) table.attach(hbox, 1, 3, row, row+1, yoptions=0) row += 1 + + # Pa/Matronymic surname handling + self.add_checkbox(table, + _("Consider single pa/matronimic as surname"), + row, 'preferences.patronimic-surname', stop=3, + extra_callback=self.cb_pa_sur_changed) + row += 1 # Date format: obox = gtk.combo_box_new_text() diff --git a/src/plugins/webreport/NarrativeWeb.py b/src/plugins/webreport/NarrativeWeb.py index 11e0c346e..dd1c45b1f 100644 --- a/src/plugins/webreport/NarrativeWeb.py +++ b/src/plugins/webreport/NarrativeWeb.py @@ -6800,7 +6800,7 @@ def sort_people(db, handle_list): surname = primary_name.group_as else: surname = db.get_name_group_mapping( - primary_name.get_primary_surname().get_surname()) + _nd.primary_surname(primary_name)) sortnames[person_handle] = _nd.sort_string(primary_name) sname_sub[surname].append(person_handle) @@ -6855,7 +6855,7 @@ def _get_short_name(gender, name): def __get_person_keyname(db, handle): """ .... """ person = db.get_person_from_handle(handle) - return person.get_primary_name().get_surname() + return _nd.sort_string(person.get_primary_name()) def __get_place_keyname(db, handle): """ ... """