From 008ef2f5d296880ce18aeedd5a45aee83e8b2e2c Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 29 Sep 2004 02:06:46 +0000 Subject: [PATCH] * src/RelLib.py: Enhanced Name, adding patronymic name support and display and sorting formats * src/EditPerson.py: Name editing changes for the Primary name * src/NameEdit.py: support for patronymic names * src/gramps.glade: NameEditor and EditPerson changes for enhanced name support * src/PeopleModel.py: remove unused map * src/GrampsDbBase.py: remove unused map svn: r3583 --- gramps2/ChangeLog | 13 + gramps2/src/EditPerson.py | 22 +- gramps2/src/GrampsDbBase.py | 18 +- gramps2/src/NameEdit.py | 55 +++- gramps2/src/PeopleModel.py | 75 +---- gramps2/src/RelLib.py | 40 ++- gramps2/src/gramps.glade | 564 ++++++++++++++++++++++++++---------- 7 files changed, 525 insertions(+), 262 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 76d85dbe3..bfadce60f 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,16 @@ +2004-09-28 Don Allingham + * src/RelLib.py: Enhanced Name, adding patronymic name + support and display and sorting formats + * src/EditPerson.py: Name editing changes for the Primary + name + * src/NameEdit.py: support for patronymic names + * src/gramps.glade: NameEditor and EditPerson changes for + enhanced name support + +2004-09-27 Don Allingham + * src/PeopleModel.py: remove unused map + * src/GrampsDbBase.py: remove unused map + 2004-09-27 Alex Roitman * configure.in: Bump up the version number. * src/DateParser.py: Better compliance with the RFC-2822. diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index fc66a3334..68de0645f 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -414,14 +414,13 @@ class EditPerson: "on_event_add_clicked" : self.on_event_add_clicked, "on_event_delete_clicked" : self.on_event_delete_clicked, "on_event_update_clicked" : self.on_event_update_clicked, - "on_name_note_clicked" : self.on_name_note_clicked, + "on_edit_name_clicked" : self.on_edit_name_clicked, "on_ldsbap_note_clicked" : self.on_ldsbap_note_clicked, "on_ldsendow_note_clicked" : self.on_ldsendow_note_clicked, "on_ldsseal_note_clicked" : self.on_ldsseal_note_clicked, "on_ldsbap_src_clicked" : self.on_ldsbap_source_clicked, "on_ldsendow_src_clicked" : self.on_ldsendow_source_clicked, "on_ldsseal_src_clicked" : self.on_ldsseal_source_clicked, - "on_name_source_clicked" : self.on_primary_name_source_clicked, "on_update_address_clicked" : self.on_update_addr_clicked, "on_update_attr_clicked" : self.on_update_attr_clicked, "on_update_url_clicked" : self.on_update_url_clicked, @@ -941,7 +940,7 @@ class EditPerson: def on_add_aka_clicked(self,obj): """Invokes the name editor to add a new name""" import NameEdit - NameEdit.NameEditor(self,None,self.name_edit_callback,self.window) + NameEdit.NameEdit(self,None,self.name_edit_callback,self.window) def on_add_url_clicked(self,obj): """Invokes the url editor to add a new name""" @@ -1648,18 +1647,13 @@ class EditPerson: else: return None - def on_primary_name_source_clicked(self,obj): - Sources.SourceSelector(self.pname.get_source_references(),self, - self.update_primary_name) - - def update_primary_name(self,list): - self.pname.set_source_reference_list(list) - self.lists_changed = True - - def on_name_note_clicked(self,obj): - import NoteEdit - NoteEdit.NoteEditor(self.pname,self,self.window) + def on_edit_name_clicked(self,obj): + import NameEdit + NameEdit.NameEditor(self,self.pname,self.update_name,self.window) + def update_name(self,name): + self.write_primary_name() + def on_ldsbap_source_clicked(self,obj): Sources.SourceSelector(self.lds_baptism.get_source_references(), self,self.update_ldsbap_list) diff --git a/gramps2/src/GrampsDbBase.py b/gramps2/src/GrampsDbBase.py index 66ddcde1c..eeee88437 100644 --- a/gramps2/src/GrampsDbBase.py +++ b/gramps2/src/GrampsDbBase.py @@ -560,13 +560,12 @@ class GrampsDbBase: This allows faster display of the treeview. """ if self.metadata: - return (self.metadata.get('tp_iter'), - self.metadata.get('tp_path'), + return (self.metadata.get('tp_path'), self.metadata.get('p_iter'), self.metadata.get('p_path'), self.metadata.get('sname')) else: - return (None,None,None,None,None) + return (None,None,None,None) def set_people_view_maps(self,maps): """ @@ -574,11 +573,10 @@ class GrampsDbBase: This allows faster display of the treeview. """ if self.metadata: - self.metadata['tp_iter'] = maps[0] - self.metadata['tp_path'] = maps[1] - self.metadata['p_iter'] = maps[2] - self.metadata['p_path'] = maps[3] - self.metadata['sname'] = maps[4] + self.metadata['tp_path'] = maps[0] + self.metadata['p_iter'] = maps[1] + self.metadata['p_path'] = maps[2] + self.metadata['sname'] = maps[3] def get_number_of_people(self): """ @@ -970,8 +968,8 @@ class GrampsDbBase: return self.media_map.has_key(str(handle)) != None def _sortbyname(self,f,s): - n1 = self.person_map.get(str(f))[2].sname - n2 = self.person_map.get(str(s))[2].sname + n1 = self.person_map.get(str(f))[3].sname + n2 = self.person_map.get(str(s))[3].sname return locale.strcoll(n1,n2) def _sortbyplace(self,f,s): diff --git a/gramps2/src/NameEdit.py b/gramps2/src/NameEdit.py index e9ab967bc..a486aa197 100644 --- a/gramps2/src/NameEdit.py +++ b/gramps2/src/NameEdit.py @@ -65,6 +65,9 @@ class NameEditor: self.top = gtk.glade.XML(const.dialogFile, "name_edit","gramps") self.window = self.top.get_widget("name_edit") self.given_field = self.top.get_widget("alt_given") + self.sort_as = self.top.get_widget("sort_as") + self.display_as = self.top.get_widget("display_as") + self.group_as = self.top.get_widget("group_as") self.title_field = self.top.get_widget("alt_title") self.suffix_field = self.top.get_widget("alt_suffix") self.combo = self.top.get_widget("alt_surname_list") @@ -80,6 +83,7 @@ class NameEditor: self.notes_label = self.top.get_widget("noteName") self.flowed = self.top.get_widget("alt_flowed") self.preform = self.top.get_widget("alt_preform") + self.group_over = self.top.get_widget('group_over') types = const.NameTypesMap.get_values() types.sort() @@ -96,11 +100,11 @@ class NameEditor: alt_title = self.top.get_widget("title") if full_name == ", ": - tmsg = _("Alternate Name Editor") + tmsg = _("Name Editor") else: - tmsg = _("Alternate Name Editor for %s") % full_name + tmsg = _("Name Editor for %s") % full_name - Utils.set_titles(self.window, alt_title, tmsg, _('Alternate Name Editor')) + Utils.set_titles(self.window, alt_title, tmsg, _('Name Editor')) self.sourcetab = Sources.SourceTab(self.srcreflist, self, self.top, self.window, self.slist, @@ -111,11 +115,12 @@ class NameEditor: self.note_buffer = self.note_field.get_buffer() self.top.signal_autoconnect({ - "on_help_name_clicked" : self.on_help_clicked, - "on_name_edit_ok_clicked" : self.on_name_edit_ok_clicked, + "on_help_name_clicked" : self.on_help_clicked, + "on_name_edit_ok_clicked" : self.on_name_edit_ok_clicked, "on_name_edit_cancel_clicked" : self.close, - "on_name_edit_delete_event" : self.on_delete_event, - "on_switch_page" : self.on_switch_page + "on_name_edit_delete_event" : self.on_delete_event, + "on_group_over_toggled" : self.on_group_over_toggled, + "on_switch_page" : self.on_switch_page }) if name != None: @@ -132,12 +137,32 @@ class NameEditor: self.preform.set_active(1) else: self.flowed.set_active(1) + self.display_as.set_active(name.get_display_as()) + self.sort_as.set_active(name.get_display_as()) + self.group_as.set_text(name.get_group_as()) + else: + self.display_as.set_active(0) + self.sort_as.set_active(0) if parent_window: self.window.set_transient_for(parent_window) self.add_itself_to_menu() + self.surname_field.connect('changed',self.on_family_changed) self.window.show() + def on_group_over_toggled(self,obj): + if obj.get_active(): + self.group_as.set_sensitive(gtk.TRUE) + self.group_as.set_editable(gtk.TRUE) + else: + self.group_as.set_text(self.surname_field.get_text()) + self.group_as.set_sensitive(gtk.FALSE) + self.group_as.set_editable(gtk.FALSE) + + def on_family_changed(self,obj): + if self.group_over.get_active() == gtk.FALSE: + self.group_as.set_text(self.surname_field.get_text()) + def on_delete_event(self,*obj): self.close_child_windows() self.remove_itself_from_menu() @@ -206,6 +231,22 @@ class NameEditor: self.parent.nlist.append(self.name) self.name.set_source_reference_list(self.srcreflist) + + if self.name.get_display_as() != self.display_as.get_active(): + self.name.set_display_as(self.display_as.get_active()) + self.parent.lists_changed = 1 + + if self.name.get_sort_as() != self.sort_as.get_active(): + self.name.set_sort_as(self.sort_as.get_active()) + self.parent.lists_changed = 1 + + if self.group_over.get_active() == gtk.FALSE: + if self.name.get_group_as() != self.surname_field.get_text(): + self.name.set_group_as("") + self.parent.lists_changed = 1 + elif self.name.set_group_as() != self.group_as.get_text(): + self.name.set_group_as(self.group_as.get_text()) + self.parent.lists_changed = 1 self.update_name(first,last,suffix,title,mtype,note,format,priv) self.parent.lists_changed = 1 diff --git a/gramps2/src/PeopleModel.py b/gramps2/src/PeopleModel.py index 4143391bc..19c68a0c6 100644 --- a/gramps2/src/PeopleModel.py +++ b/gramps2/src/PeopleModel.py @@ -44,7 +44,6 @@ import pango # #------------------------------------------------------------------------- from RelLib import * -import accent #------------------------------------------------------------------------- # @@ -75,11 +74,11 @@ class PeopleModel(gtk.GenericTreeModel): self.top_visible = {} maps = self.db.get_people_view_maps() - if maps[1] != None and len(maps[1]) != 0: - self.top_path2iter = maps[1] - self.iter2path = maps[2] - self.path2iter = maps[3] - self.sname_sub = maps[4] + if maps[0] != None and len(maps[0]) != 0: + self.top_path2iter = maps[0] + self.iter2path = maps[1] + self.path2iter = maps[2] + self.sname_sub = maps[3] else: self.rebuild_data() @@ -120,8 +119,7 @@ class PeopleModel(gtk.GenericTreeModel): self.db.set_people_view_maps(self.get_maps()) def get_maps(self): - return (None, - self.top_path2iter, + return (self.top_path2iter, self.iter2path, self.path2iter, self.sname_sub) @@ -321,67 +319,6 @@ class PeopleModel(gtk.GenericTreeModel): def column_header_view(self,node): return self.top_visible.has_key(node) -# def add_person(self,person): -# pid = person.get_handle() -# need = 0 -# surname = person.get_primary_name().get_surname() -# if self.sname_sub.has_key(surname): -# self.sname_sub[surname].append(pid) -# else: -# self.sname_sub[surname] = [pid] - -# inscol = 0 -# sval = 0 -# name_list = self.db.get_surname_list() -# for name in name_list: -# if self.sname_sub.has_key(name): -# self.top_path2iter[sval] = name -# if name == surname: -# inscol = (sval,) -# need = 1 -# sval += 1 - -# column = 0 -# val = 0 -# entries = self.sname_sub[surname] -# entries.sort(self.byname) -# for person_handle in entries: -# tpl = (surname,val) -# self.iter2path[person_handle] = tpl -# self.path2iter[tpl] = person_handle -# if person_handle == pid: -# column = val -# val += 1 - -# col = self.top_path2iter.index(surname) -# mypath = (col[0],column) -# if need: -# self.row_inserted(inscol,self.get_iter(inscol)) -# self.row_inserted(mypath,self.get_iter(mypath)) - -# def on_row_inserted(self,model,path,iter): -# pass - -# def on_row_deleted(self,model,path): -# surname = self.top_path2iter[path[0]] -# pid = self.path2iter[(surname,path[1])] - -# for idval in self.sname_sub[surname]: -# key = self.iter2path[idval] -# del self.iter2path[idval] -# del self.path2iter[key] -# self.sname_sub[surname].remove(pid) - -# val = 0 -# entries = self.sname_sub[surname] -# entries.sort(self.byname) -# for person_handle in entries: -# tpl = (surname,val) -# self.iter2path[person_handle] = tpl -# self.path2iter[tpl] = person_handle -# val += 1 -# return 0 - _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ] # table of column definitions diff --git a/gramps2/src/RelLib.py b/gramps2/src/RelLib.py index 7bfcbd713..08b57f457 100644 --- a/gramps2/src/RelLib.py +++ b/gramps2/src/RelLib.py @@ -1821,6 +1821,10 @@ class Address(DataObj): class Name(DataObj): """Provides name information about a person. A person may have more that one name throughout his or her life.""" + + DEF = 0 # locale default + LNFN = 1 # last name, first name + FNLN = 2 # first name, last name def __init__(self,source=None): """creates a new Name instance, copying from the source if provided""" @@ -1833,7 +1837,11 @@ class Name(DataObj): self.title = source.title self.type = source.type self.prefix = source.prefix + self.patronymic = source.patronymic self.sname = source.sname + self.group_as = source.group_as + self.sort_as = source.sort_as + self.display_as = source.display_as else: self.first_name = "" self.surname = "" @@ -1841,7 +1849,35 @@ class Name(DataObj): self.title = "" self.type = "Birth Name" self.prefix = "" + self.patronymic = "" self.sname = '@' + self.group_as = "" + self.sort_as = self.DEF + self.display_as = self.DEF + + def get_group_as(self): + if self.group_as: + return self.group_as + else: + return self.surname + + def set_group_as(self,name): + if name == self.surname: + self.group_as = "" + else: + self.group_as = name + + def set_sort_as(self,value): + self.sort_as = value + + def get_sort_as(self): + return self.sort_as + + def set_display_as(self,value): + self.display_as = value + + def get_display_as(self): + return self.display_as def get_surname_prefix(self): return self.prefix @@ -1859,9 +1895,7 @@ class Name(DataObj): def build_sort_name(self): if self.surname: - self.sname = "%-25s%-30s%s" % (self.surname.upper(), - self.first_name.upper(), - self.suffix.upper()) + self.sname = "%-25s%-30s%s" % (self.surname,self.first_name,self.suffix) else: self.sname = "@" diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index f94f63f3a..954e34738 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -7967,7 +7967,7 @@ Other True True GTK_POS_TOP - True + False False @@ -8217,94 +8217,6 @@ Other - - - True - Select source for this name information - True - Source... - True - GTK_RELIEF_NORMAL - True - - - - 4 - 5 - 4 - 5 - fill - - - - - - - True - Enter/modify notes regarding this name - True - Note... - True - GTK_RELIEF_NORMAL - True - - - - 4 - 5 - 5 - 6 - fill - - - - - - - True - The person's given name - True - True - True - True - 0 - - True - * - False - - - - 2 - 5 - 1 - 2 - - - - - - - True - An optional prefix for the family name that is not used in sorting, such as "de" or "van" - True - True - True - 0 - - True - * - False - - - 2 - 5 - 3 - 4 - - - - True @@ -9043,6 +8955,72 @@ Other fill + + + + True + The person's given name + True + True + True + True + 0 + + True + * + False + + + + 2 + 4 + 1 + 2 + + + + + + + True + True + Edit... + True + GTK_RELIEF_NORMAL + True + + + + 4 + 5 + 1 + 2 + fill + + + + + + + True + An optional prefix for the family name that is not used in sorting, such as "de" or "van" + True + True + True + 0 + + True + * + False + + + 2 + 4 + 3 + 4 + + + 0 @@ -29496,8 +29474,8 @@ Other 12 True - 7 - 2 + 13 + 4 False 6 12 @@ -29521,32 +29499,8 @@ Other - 0 - 1 - 0 - 1 - fill - - - - - - - True - _Family name: - True - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 + 1 + 2 1 2 fill @@ -29573,10 +29527,10 @@ Other - 0 - 1 - 3 - 4 + 1 + 2 + 5 + 6 fill @@ -29595,12 +29549,15 @@ Other 0 1 0 + + + - 0 - 1 - 5 - 6 + 1 + 2 + 7 + 8 fill @@ -29625,10 +29582,10 @@ Other - 0 - 1 - 4 - 5 + 1 + 2 + 6 + 7 fill @@ -29647,10 +29604,10 @@ Other True - 1 - 2 - 6 - 7 + 2 + 3 + 12 + 13 fill @@ -29675,10 +29632,10 @@ Other - 0 - 1 - 2 - 3 + 1 + 2 + 4 + 5 fill @@ -29698,10 +29655,10 @@ Other False - 1 - 2 - 0 - 1 + 2 + 3 + 1 + 2 @@ -29719,10 +29676,10 @@ Other False - 1 - 2 - 2 - 3 + 2 + 3 + 4 + 5 @@ -29740,10 +29697,10 @@ Other False - 1 - 2 - 3 - 4 + 2 + 3 + 5 + 6 @@ -29760,11 +29717,66 @@ Other * False + + 2 + 3 + 6 + 7 + + + + + + + True + P_atronymic: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + patronymic + + + + 1 2 - 4 - 5 + 3 + 4 + fill + + + + + + + True + _Family name: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + + + + 1 + 2 + 2 + 3 + fill @@ -29774,24 +29786,258 @@ Other True - 1 - 2 - 1 - 2 + 2 + 3 + 2 + 3 fill fill + + + True + True + True + True + 0 + + True + * + False + + + + + + 2 + 3 + 3 + 4 + + + + + + + True + G_roup as: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + group_as + + + + + + 1 + 2 + 9 + 10 + fill + + + + + + + True + _Sort as: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + + + + 1 + 2 + 10 + 11 + fill + + + + + + + True + False + True + False + True + 0 + + True + * + False + + + 2 + 3 + 9 + 10 + + + + + + + True + _Display as: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + + + + 1 + 2 + 11 + 12 + fill + + + + + + + True + <b>Name Information</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 3 + 0 + 1 + fill + + + + + + + True + <b>Options</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 3 + 8 + 9 + fill + + + + + + + True + True + _Override + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 3 + 4 + 9 + 10 + fill + + + + True - 1 - 2 - 5 - 6 + 2 + 3 + 7 + 8 + fill + fill + + + + + + True + Default (based on locale) +Family name, Given name +Given name, Family name + + + 2 + 3 + 10 + 11 + fill + fill + + + + + + True + Default (based on locale) +Given name Family name +Family name Given name + + + + 2 + 3 + 11 + 12 fill fill