diff --git a/ChangeLog b/ChangeLog index 512b2fef4..537408ecb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-04-28 Don Allingham + * src/EditPerson.py: remove dead logic for birth/death editing, + fix list handling + * src/EventEdit.py: fix callbacks for updating events + * src/GrampsDbBase.py: shorten handles + * src/Utils.py: shorten handles + * src/edit_person.glade: fix image spacing + 2005-04-27 Don Allingham * src/EditPerson.py: rewrite of tabbed lists * src/EventEdit.py: bold the label diff --git a/src/EditPerson.py b/src/EditPerson.py index a787edf89..27374b418 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -208,22 +208,9 @@ class EditPerson: self.prefix_label.set_text(_('Patronymic:')) self.prefix_label.set_use_underline(True) - birth_handle = person.get_birth_handle() - if birth_handle: - self.orig_birth = self.db.get_event_from_handle(birth_handle) - else: - self.orig_birth = RelLib.Event() - self.orig_birth.set_name("Birth") + self.birth_handle = person.get_birth_handle() + self.death_handle = person.get_death_handle() - death_handle = person.get_death_handle() - if death_handle: - self.orig_death = self.db.get_event_from_handle(death_handle) - else: - self.orig_death = RelLib.Event() - self.orig_death.set_name("Death") - - self.death = RelLib.Event(self.orig_death) - self.birth = RelLib.Event(self.orig_birth) self.pname = RelLib.Name(person.get_primary_name()) self.gender.set_active(person.get_gender()) @@ -848,13 +835,13 @@ class EditPerson: def update_lists(self): """Updates the person's lists if anything has changed""" if self.lists_changed: - #self.person.set_event_list(self.elist) self.person.set_alternate_names(self.nlist) self.person.set_url_list(self.ulist) self.person.set_attribute_list(self.alist) self.person.set_address_list(self.plist) - self.person.set_birth_handle(self.birth.get_handle()) - self.person.set_death_handle(self.death.get_handle()) + #self.person.set_event_list(self.elist) +# self.person.set_birth_handle(self.birth.get_handle()) +# self.person.set_death_handle(self.death.get_handle()) def on_apply_person_clicked(self,obj): @@ -933,11 +920,11 @@ class EditPerson: p = self.db.get_place_from_handle(key).get_display_info() self.pdmap[p[0]] = key - if not self.orig_birth.are_equal(self.birth): - if self.orig_birth.is_empty(): - self.db.add_event(self.birth,trans) - self.person.set_birth_handle(self.birth.get_handle()) - self.db.commit_event(self.birth,trans) +# if not self.orig_birth.are_equal(self.birth): +# if self.orig_birth.is_empty(): +# self.db.add_event(self.birth,trans) +# self.person.set_birth_handle(self.birth.get_handle()) +# self.db.commit_event(self.birth,trans) # Update each of the families child lists to reflect any # change in ordering due to the new birth date @@ -1294,6 +1281,9 @@ class ListBox: self.blist[0].connect('clicked',self.add) self.blist[1].connect('clicked',self.update) self.blist[2].connect('clicked',self.delete) + + def add_object(self,item): + self.data.append(item) def select_row(self,obj): store, node = obj.get_selected() @@ -1337,6 +1327,7 @@ class ListBox: try: self.list_model.select_iter(self.node_map[str(data)]) except: + print self.node_map, data print "Edit callback failed" def set_label(self): @@ -1493,6 +1484,8 @@ class EventListBox(ReorderListBox): self.node_map = {} for handle in self.data: event = self.db.get_event_from_handle(handle) + if not event: + print "couldn't find",handle pname = place_title(self.db,event) has_note = event.get_note() has_source = len(event.get_source_references())> 0 @@ -1500,7 +1493,7 @@ class EventListBox(ReorderListBox): event.get_description(), event.get_date(), pname, has_source, has_note] node = self.list_model.add(data, event) - self.node_map[str(event)] = node + self.node_map[handle] = node if self.data: self.list_model.select_row(0) self.set_label() diff --git a/src/EventEdit.py b/src/EventEdit.py index 8577be07d..75cab3a77 100644 --- a/src/EventEdit.py +++ b/src/EventEdit.py @@ -346,20 +346,22 @@ class EventEditor: self.elist.append(ename) self.elist.sort() + just_added = False if self.event == None: self.event = RelLib.Event() + self.event.set_handle(Utils.create_id()) self.db.add_event(self.event,trans) self.event.set_source_reference_list(self.srcreflist) self.event.set_witness_list(self.witnesslist) - self.parent.elist.append(self.event.get_handle()) + just_added = True self.update_event(ename,self.date,eplace_obj,edesc,enote,eformat, epriv,ecause,trans) self.db.transaction_commit(trans,_("Edit Event")) + self.close(obj) - self.parent.redraw_event_list() if self.callback: - self.callback(self.event) + self.callback(self.event.get_handle()) def update_event(self,name,date,place,desc,note,format,priv,cause,trans): if place: diff --git a/src/GrampsDbBase.py b/src/GrampsDbBase.py index 3a8ca5c3c..97d61524f 100644 --- a/src/GrampsDbBase.py +++ b/src/GrampsDbBase.py @@ -211,9 +211,8 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): pass def create_id(self): - return "%08x%08x%08x" % ( int(time.time()*10000), - self.rand.randint(0,maxint), - self.rand.randint(0,maxint)) + return "%08x%08x" % ( int(time.time()*10000), + self.rand.randint(0,maxint)) def get_person_cursor(self): assert False, "Needs to be overridden in the derived class" diff --git a/src/Utils.py b/src/Utils.py index d88f2959a..37f36dfb8 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -425,22 +425,12 @@ def unbold_label(label): #------------------------------------------------------------------------- import random import time +from sys import maxint rand = random.Random(time.time()) def create_id(): - s = "" - for val in [ int(time.time()*10000) & 0x7fffffff, - rand.randint(0,0x7fffffff), - rand.randint(0,0x7fffffff)]: - while val != 0: - rem = val % 36 - if rem <= 9: - s += chr(48+rem) - else: - s += chr(rem+55) - val = int(val/36) - return s - + return "%08x%08x" % ( int(time.time()*10000), + rand.randint(0,maxint)) def probably_alive(person,db,current_year=None): """Returns true if the person may be alive. diff --git a/src/edit_person.glade b/src/edit_person.glade index e6781a515..1bdd6a8d3 100644 --- a/src/edit_person.glade +++ b/src/edit_person.glade @@ -283,6 +283,7 @@ Unknown + 124 True 0 0.5