diff --git a/gramps/src/AddSpouse.py b/gramps/src/AddSpouse.py index f46b12f30..9b0459c13 100644 --- a/gramps/src/AddSpouse.py +++ b/gramps/src/AddSpouse.py @@ -43,7 +43,7 @@ import libglade #------------------------------------------------------------------------- import RelLib import const -import sort +import Sorter import Utils import GrampsCfg @@ -82,8 +82,13 @@ class AddSpouse: self.ok = self.glade.get_widget('spouse_ok') self.ok.set_sensitive(0) - self.name_list = self.db.getPersonMap().values() - self.name_list.sort(sort.by_last_name) + arrow_map = [(2,self.glade.get_widget('NameArrow')), + (3,self.glade.get_widget('DateArrow'))] + + self.spouse_list.set_column_visibility(2,0) + self.spouse_list.set_column_visibility(3,0) + self.sorter = Sorter.Sorter(self.spouse_list,arrow_map,'spouse',self.top) + self.name_list = self.db.getPersonKeys() self.rel_combo.set_popdown_strings(const.familyRelations) title = _("Choose Spouse/Partner of %s") % GrampsCfg.nameof(person) self.glade.get_widget("spouseTitle").set_text(title) @@ -127,11 +132,11 @@ class AddSpouse: QuickAdd.QuickAdd(self.db,gen,self.update_list) def update_list(self,person): - self.name_list.append(person) - self.name_list.sort(sort.by_last_name) + self.name_list.append(person.getId()) self.addperson(person) self.relation_type_changed(self.relation_type) row = self.spouse_list.find_row_from_data(person) + self.sorter.sort_list() self.spouse_list.select_row(row,0) self.spouse_list.moveto(row,0) @@ -143,7 +148,7 @@ class AddSpouse: if len(self.spouse_list.selection) == 0: return row = self.spouse_list.selection[0] - spouse = self.spouse_list.get_row_data(row) + spouse = self.db.getPerson(self.spouse_list.get_row_data(row)) # don't do anything if the marriage already exists for f in self.person.getFamilyList(): @@ -188,13 +193,15 @@ class AddSpouse: index = 0 self.spouse_list.clear() self.spouse_list.freeze() - for person in self.name_list: + for key in self.name_list: + person = self.db.getPerson(key) if person.getGender() == gender: continue - name = person.getPrimaryName().getName() - self.spouse_list.append([name,Utils.birthday(person)]) - self.spouse_list.set_row_data(index,person) + data = person.getDisplayInfo() + self.spouse_list.append([data[0],data[3],data[5],data[6]]) + self.spouse_list.set_row_data(index,key) index = index + 1 + self.sorter.sort_list() self.spouse_list.thaw() #------------------------------------------------------------------------- @@ -280,7 +287,7 @@ class SetSpouse: if len(self.spouse_list.selection) == 0: return row = self.spouse_list.selection[0] - spouse = self.spouse_list.get_row_data(row) + spouse = self.db.getPerson(self.spouse_list.get_row_data(row)) # don't do anything if the marriage already exists for f in self.person.getFamilyList(): diff --git a/gramps/src/Find.py b/gramps/src/Find.py index 77d044673..dca88de4d 100644 --- a/gramps/src/Find.py +++ b/gramps/src/Find.py @@ -56,13 +56,14 @@ _ = gettext class FindBase: """Opens find person dialog for gramps""" - def __init__(self,clist,task,name): + def __init__(self,clist,task,name,db): """Opens a dialog box instance that allows users to search for a person. clist - GtkCList containing the people information task - function to call to change the active person""" - + + self.db = db self.clist = clist self.nlist = [] self.task = task @@ -84,12 +85,36 @@ class FindBase: self.top.editable_enters(self.entry) self.entry.grab_focus() + def get_value(self,id): + return None + def enable_autocomp(self): if GrampsCfg.autocomp: self.comp = AutoComp.AutoEntry(self.entry,self.nlist) def advance(self,func): - pass + try: + self.row = self.clist.selection[0] + except IndexError: + gtk.gdk_beep() + return + + text = self.entry.get_text() + if self.row == None or text == "": + gtk.gdk_beep() + return + orow = self.row + func() + while self.row != orow: + id = self.clist.get_row_data(self.row) + if id == None: + func() + continue + if string.find(string.upper(self.get_value(id)),string.upper(text)) >= 0: + self.task(self.row) + return + func() + gtk.gdk_beep() def forward(self): self.row = self.row + 1 @@ -121,45 +146,22 @@ class FindBase: class FindPerson(FindBase): """Opens a Find Person dialog for GRAMPS""" - def __init__(self,clist,task,plist): + def __init__(self,clist,task,db): """Opens a dialog box instance that allows users to search for a person. clist - GtkCList containing the people information task - function to call to change the active person""" - FindBase.__init__(self,clist,task,_("Find Person")) - for n in plist: - self.nlist.append(n.getPrimaryName().getName()) + FindBase.__init__(self,clist,task,_("Find Person"),db) + for n in self.db.getPersonKeys(): + val = self.db.getPersonDisplay(n) + self.nlist.append(val[0]) self.enable_autocomp() - - def advance(self,func): - try: - self.row = self.clist.selection[0] - except IndexError: - gtk.gdk_beep() - return - text = self.entry.get_text() - if self.row == None or text == "": - gtk.gdk_beep() - return - orow = self.row - func() - person = None - while self.row != orow: - value = self.clist.get_row_data(self.row) - if value == None: - func() - continue - person,alt = value - if alt == 0: - name = person.getPrimaryName().getName() - if string.find(string.upper(name),string.upper(text)) >= 0: - self.task(person) - return - func() - gtk.gdk_beep() + def get_value(self,id): + return self.db.getPersonDisplay(id)[0] + #------------------------------------------------------------------------- # @@ -169,42 +171,20 @@ class FindPerson(FindBase): class FindPlace(FindBase): """Opens a Find Place dialog for GRAMPS""" - def __init__(self,clist,task,plist): + def __init__(self,clist,task,db): """Opens a dialog box instance that allows users to search for a place. clist - GtkCList containing the people information task - function to call to change the active person""" - FindBase.__init__(self,clist,task,_("Find Place")) - for n in plist: - self.nlist.append(n.get_title()) + FindBase.__init__(self,clist,task,_("Find Place"),db) + for n in self.db.getPlaceKeys(): + self.nlist.append(self.db.getPlaceDisplay(n)[0]) self.enable_autocomp() - def advance(self,func): - try: - self.row = self.clist.selection[0] - except IndexError: - gtk.gdk_beep() - return - - text = self.entry.get_text() - if self.row == None or text == "": - gtk.gdk_beep() - return - orow = self.row - func() - while self.row != orow: - value = self.clist.get_row_data(self.row) - if value == None: - func() - continue - name = value.get_title() - if string.find(string.upper(name),string.upper(text)) >= 0: - self.task(self.row) - return - func() - gtk.gdk_beep() + def get_value(self,id): + return self.db.getPlaceDisplay(id)[0] #------------------------------------------------------------------------- # @@ -214,42 +194,20 @@ class FindPlace(FindBase): class FindSource(FindBase): """Opens a Find Place dialog for GRAMPS""" - def __init__(self,clist,task,plist): + def __init__(self,clist,task,db): """Opens a dialog box instance that allows users to search for a place. clist - GtkCList containing the people information task - function to call to change the active person""" - FindBase.__init__(self,clist,task,_("Find Source")) - for n in plist: - self.nlist.append(n.getTitle()) + FindBase.__init__(self,clist,task,_("Find Source"),db) + for n in self.db.getSourceKeys(): + self.nlist.append(n[0]) self.enable_autocomp() - def advance(self,func): - try: - self.row = self.clist.selection[0] - except IndexError: - gtk.gdk_beep() - return - - text = self.entry.get_text() - if self.row == None or text == "": - gtk.gdk_beep() - return - orow = self.row - func() - while self.row != orow: - value = self.clist.get_row_data(self.row) - if value == None: - func() - continue - name = value.getTitle() - if string.find(string.upper(name),string.upper(text)) >= 0: - self.task(self.row) - return - func() - gtk.gdk_beep() + def get_value(self,id): + return self.db.getSourceDisplay(id)[0] #------------------------------------------------------------------------- # diff --git a/gramps/src/GenericFilter.py b/gramps/src/GenericFilter.py index ee377d29d..449019cc1 100644 --- a/gramps/src/GenericFilter.py +++ b/gramps/src/GenericFilter.py @@ -413,12 +413,12 @@ class HasBirth(Rule): def apply(self,p): event = p.getBirth() - if self.list[2] and find(event.getDescription(),self.list[2])==-1: + if len(self.list) > 2 and find(event.getDescription(),self.list[2])==-1: return 0 if self.date: if date_cmp(self.date,event.getDateObj()) == 0: return 0 - if self.list[1] and find(p.getPlaceName(),self.list[1]) == -1: + if len(self.list) > 1 and find(event.getPlaceName(),self.list[1]) == -1: return 0 return 1 diff --git a/gramps/src/RelLib.py b/gramps/src/RelLib.py index 387c342db..f4dec5f32 100644 --- a/gramps/src/RelLib.py +++ b/gramps/src/RelLib.py @@ -1986,6 +1986,10 @@ class GrampsDB(Persistent): """returns a map of gramps's IDs to Family instances""" return extmap(self.familyMap) + def getFamily(self,id): + """returns a map of gramps's IDs to Family instances""" + return self.familyMap[id] + def setFamilyMap(self,map): """sets the map of gramps's IDs to Family instances""" self.familyMap = map diff --git a/gramps/src/gramps.glade b/gramps/src/gramps.glade index d45152fdf..4aec80cba 100644 --- a/gramps/src/gramps.glade +++ b/gramps/src/gramps.glade @@ -4661,12 +4661,9 @@ GtkScrolledWindow - scrolledwindow9 - 10 - 400 - 200 - GTK_POLICY_NEVER - GTK_POLICY_ALWAYS + scrolledwindow36 + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC GTK_UPDATE_CONTINUOUS GTK_UPDATE_CONTINUOUS @@ -4678,28 +4675,143 @@ GtkCList spouseList + 450 + 300 True select_row on_select_row - Fri, 29 Mar 2002 13:44:27 GMT + Sat, 01 Jun 2002 20:59:14 GMT unselect_row on_unselect_row - Fri, 29 Mar 2002 13:44:33 GMT + Sat, 01 Jun 2002 20:59:58 GMT - 2 - 256,80 + 4 + 229,85,5,80 GTK_SELECTION_SINGLE True GTK_SHADOW_IN + + GtkHBox + CList:title + hbox82 + True + 0 + + + GtkHBox + hbox83 + False + 0 + + 0 + False + False + + + + GtkLabel + CList:title + label315 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkArrow + NameArrow + 10 + 10 + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + 5 + False + True + + + + + + + GtkHBox + CList:title + hbox80 + True + 0 + + + GtkHBox + hbox81 + False + 0 + + 0 + False + False + + + + GtkLabel + CList:title + label311 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkArrow + DateArrow + 10 + 10 + False + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkLabel CList:title - label65 - + label318 + GTK_JUSTIFY_CENTER False 0.5 @@ -4711,8 +4823,8 @@ GtkLabel CList:title - label66 - + label319 + GTK_JUSTIFY_CENTER False 0.5 diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index bd813c13e..34e7abcc5 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -330,25 +330,23 @@ class Gramps: def on_find_activate(self,obj): """Display the find box""" if self.notebook.get_current_page() == 4: - Find.FindPlace(self.place_view.place_list,self.find_goto_place, - self.db.getPlaceMap().values()) + Find.FindPlace(self.place_view.place_list,self.find_goto_place,self.db) elif self.notebook.get_current_page() == 3: - Find.FindSource(self.source_view.source_list,self.find_goto_source, - self.db.getSourceMap().values()) + Find.FindSource(self.source_view.source_list,self.find_goto_source,self.db) elif self.notebook.get_current_page() == 5: Find.FindMedia(self.media_view.media_list,self.find_goto_media, self.db.getObjectMap().values()) else: - Find.FindPerson(self.person_list,self.find_goto_to, - self.db.getPersonMap().values()) + Find.FindPerson(self.person_list,self.find_goto_to,self.db) def on_findname_activate(self,obj): """Display the find box""" pass - def find_goto_to(self,person): + def find_goto_to(self,row): """Find callback to jump to the selected person""" - self.change_active_person(person) + id = self.person_list.get_row_data(row) + self.change_active_person(self.db.getPerson(id)) self.goto_active_person() self.update_display(0) @@ -1290,9 +1288,9 @@ class Gramps: EditPerson.EditPerson(person, self.db, self.update_after_edit) def build_spouse_dropdown(self): + list = [] mymap = {} mynmap = {} - list = [] sel = None for f in self.active_person.getFamilyList(): if self.active_person == f.getFather(): @@ -1303,8 +1301,8 @@ class Gramps: list.append(c) if f == self.active_family or sel == None: sel = c - mymap[f] = c - mynmap[f] = sname + mynmap[f.getId()] = sname + mymap[f.getId()] = c self.spouse_combo.disable_activate() self.spouse_combo.list.clear_items(0,-1) self.spouse_combo.list.append_items(list) @@ -1706,10 +1704,13 @@ class Gramps: gnome.ui.GnomeErrorDialog(_("No default/home person has been set")) def on_add_bookmark_activate(self,obj): - self.bookmarks.add(self.active_person) - name = GrampsCfg.nameof(self.active_person) - self.statusbar.set_status(_("%s has been bookmarked") % name) - gtk.timeout_add(5000,self.modify_statusbar) + if self.active_person: + self.bookmarks.add(self.active_person) + name = GrampsCfg.nameof(self.active_person) + self.statusbar.set_status(_("%s has been bookmarked") % name) + gtk.timeout_add(5000,self.modify_statusbar) + else: + GnomeWarningDialog(_("Bookmark could not be set because no one was selected")) def on_edit_bookmarks_activate(self,obj): self.bookmarks.edit() @@ -1760,7 +1761,7 @@ class Gramps: if len(select) == 0: self.active_family = None else: - self.active_family = select[0].get_data('d') + self.active_family = self.db.getFamily(select[0].get_data('d')) if self.active_family == self.active_person.getFamilyList()[0]: self.pref_spouse.set_sensitive(0) diff --git a/gramps/src/plugins/PatchNames.py b/gramps/src/plugins/PatchNames.py index 3cfbc6066..30b24bc2b 100644 --- a/gramps/src/plugins/PatchNames.py +++ b/gramps/src/plugins/PatchNames.py @@ -53,30 +53,30 @@ class PatchNames: self.title_list = [] self.nick_list = [] - personMap = self.db.getPersonMap() - for key in personMap.keys(): + for key in self.db.getPersonKeys(): - person = personMap[key] + person = self.db.getPerson(key) first = person.getPrimaryName().getFirstName() match = _title_re.match(first) if match: groups = match.groups() - self.title_list.append((person,groups[0],groups[1])) - + self.title_list.append((key,groups[0],groups[1])) match = _nick_re.match(first) if match: groups = match.groups() - self.nick_list.append((person,groups[0],groups[1])) + self.nick_list.append((key,groups[0],groups[1])) msg = "" if len(self.nick_list) > 0 or len(self.title_list) > 0: - for name in self.nick_list: + for (id,name,nick) in self.nick_list: + p = self.db.getPerson(id) msg = msg + _("%s will be extracted as a nickname from %s\n") % \ - (name[2],name[0].getPrimaryName().getName()) + (nick,p.getPrimaryName().getName()) - for name in self.title_list: + for (id,title,nick) in self.title_list: + p = self.db.getPerson(id) msg = msg + _("%s will be extracted as a title from %s\n") % \ - (name[0].getPrimaryName().getName(),name[1]) + (title,p.getPrimaryName().getName()) base = os.path.dirname(__file__) glade_file = base + os.sep + "patchnames.glade" @@ -93,15 +93,19 @@ class PatchNames: def on_ok_clicked(self,obj): for grp in self.nick_list: - name = grp[0].getPrimaryName() + p = self.db.getPerson(grp[0]) + name = p.getPrimaryName() name.setFirstName(grp[1]) - grp[0].setNickName(grp[2]) + p.setNickName(grp[2]) + self.db.buildPersonDisplay(grp[0]) Utils.modified() for grp in self.title_list: - name = grp[0].getPrimaryName() + p = self.db.getPerson(grp[0]) + name = p.getPrimaryName() name.setFirstName(grp[2]) name.setTitle(grp[1]) + self.db.buildPersonDisplay(grp[0]) Utils.modified() Utils.destroy_passed_object(obj) diff --git a/gramps/src/plugins/ReadGedcom.py b/gramps/src/plugins/ReadGedcom.py index 9c2020947..804ce8903 100644 --- a/gramps/src/plugins/ReadGedcom.py +++ b/gramps/src/plugins/ReadGedcom.py @@ -1675,11 +1675,9 @@ class GedcomParser: self.db.removePerson(person.getId()) person.setId(new_key) self.db.addPersonAs(person) - # person currently using it was just added, change it - elif self.added.has_key(tp.getId()): - self.db.removePerson(person.getId()) - person.setId(new_key) - self.db.addPersonAs(person) + # give up trying to use the refn as a key + else: + pass self.db.pmapIndex = new_pmax