diff --git a/ChangeLog b/ChangeLog index 7cede886c..d71a5aeea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2005-04-04 Don Allingham * src/MedaiView.py: pass handle instead of GRAMPS ID during drag-n-drop + * src/GrampsBSDDB.py: remove transaction.batch in favor of signal suppression + * src/GrampsDbBase.py: remove transaction.batch in favor of signal suppression + * src/GrampsInMemDB.py: remove transaction.batch in favor of signal suppression + * src/ReadGedcom.py: fix relation typo, enable/disable signals around import + * src/ReadXML.py: enable/disable signals around import + * src/gramps_main.py: disable signals before undo and exit 2005-04-01 Richard Taylor * src/GrampsDBCallback.py: Don't check callbacks if the dict is empty. diff --git a/src/GrampsBSDDB.py b/src/GrampsBSDDB.py index f99d3a084..3c9d1578f 100644 --- a/src/GrampsBSDDB.py +++ b/src/GrampsBSDDB.py @@ -279,8 +279,7 @@ class GrampsBSDDB(GrampsDbBase): self.genderStats.uncount_person (person) if transaction != None: transaction.add(PERSON_KEY,handle,person.serialize()) - if not transaction.batch: - self.emit('person-delete',([str(handle)],)) + self.emit('person-delete',([str(handle)],)) self.person_map.delete(str(handle)) def remove_source(self,handle,transaction): @@ -288,8 +287,7 @@ class GrampsBSDDB(GrampsDbBase): if transaction != None: old_data = self.source_map.get(str(handle)) transaction.add(SOURCE_KEY,handle,old_data) - if not transaction.batch: - self.emit('source-delete',([handle],)) + self.emit('source-delete',([handle],)) self.source_map.delete(str(handle)) def remove_family(self,handle,transaction): @@ -297,8 +295,7 @@ class GrampsBSDDB(GrampsDbBase): if transaction != None: old_data = self.family_map.get(str(handle)) transaction.add(FAMILY_KEY,handle,old_data) - if not transaction.batch: - self.emit('family-delete',([str(handle)],)) + self.emit('family-delete',([str(handle)],)) self.family_map.delete(str(handle)) def remove_event(self,handle,transaction): @@ -313,8 +310,7 @@ class GrampsBSDDB(GrampsDbBase): if transaction != None: old_data = self.place_map.get(handle) transaction.add(PLACE_KEY,handle,old_data) - if not transaction.batch: - self.emit('place-delete',([handle],)) + self.emit('place-delete',([handle],)) self.place_map.delete(str(handle)) def remove_object(self,handle,transaction): @@ -322,8 +318,7 @@ class GrampsBSDDB(GrampsDbBase): if transaction != None: old_data = self.media_map.get(handle) transaction.add(PLACE_KEY,handle,old_data) - if not transaction.batch: - self.emit('media-delete',([handle],)) + self.emit('media-delete',([handle],)) self.media_map.delete(str(handle)) def get_person_from_gramps_id(self,val): diff --git a/src/GrampsDbBase.py b/src/GrampsDbBase.py index b7a63f955..16887c7ac 100644 --- a/src/GrampsDbBase.py +++ b/src/GrampsDbBase.py @@ -277,11 +277,10 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): transaction.add(PERSON_KEY,handle,old_data) self.person_map[handle] = person.serialize() - if transaction and not transaction.batch: - if old_data: - self.emit('person-update',([handle],)) - else: - self.emit('person-add',([handle],)) + if transaction and old_data: + self.emit('person-update',([handle],)) + else: + self.emit('person-add',([handle],)) def commit_media_object(self,obj,transaction,change_time=None): """ @@ -299,12 +298,11 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): old_data = self.media_map.get(handle) transaction.add(MEDIA_KEY,handle,old_data) self.media_map[handle] = obj.serialize() - if transaction and not transaction.batch: - if old_data: - self.emit('media-update',([handle],)) - else: - self.emit('media-add',([handle],)) - + if transaction and old_data: + self.emit('media-update',([handle],)) + else: + self.emit('media-add',([handle],)) + def commit_source(self,source,transaction,change_time=None): """ Commits the specified Source to the database, storing the changes @@ -321,11 +319,10 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): old_data = self.source_map.get(handle) transaction.add(SOURCE_KEY,handle,old_data) self.source_map[handle] = source.serialize() - if transaction and not transaction.batch: - if old_data: - self.emit('source-update',([handle],)) - else: - self.emit('source-add',([handle],)) + if transaction and old_data: + self.emit('source-update',([handle],)) + else: + self.emit('source-add',([handle],)) def commit_place(self,place,transaction,change_time=None): """ @@ -343,12 +340,11 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): old_data = self.place_map.get(handle) transaction.add(PLACE_KEY,handle,old_data) self.place_map[handle] = place.serialize() - if transaction and not transaction.batch: - if old_data: - self.emit('place-update',([handle],)) - else: - self.emit('place-add',([handle],)) - + if transaction and old_data: + self.emit('place-update',([handle],)) + else: + self.emit('place-add',([handle],)) + def commit_event(self,event,transaction,change_time=None): """ Commits the specified Event to the database, storing the changes @@ -383,11 +379,10 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): transaction.add(FAMILY_KEY,handle,old_data) self.family_map[handle] = family.serialize() - if transaction and not transaction.batch: - if old_data: - self.emit('family-update',([handle],)) - else: - self.emit('family-add',([handle],)) + if transaction and old_data: + self.emit('family-update',([handle],)) + else: + self.emit('family-add',([handle],)) def find_next_person_gramps_id(self): """ @@ -537,8 +532,7 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): if transaction != None: transaction.add(PERSON_KEY, val, None) self.person_map[str(val)] = person.serialize() - if transaction and not transaction.batch: - self.emit('person-add', ([str(val)],)) + self.emit('person-add', ([str(val)],)) self.genderStats.count_person (person, self) return person @@ -967,9 +961,6 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): if self.undo_callback: self.undo_callback(_("_Undo %s") % transaction.get_description()) - if transaction and transaction.batch: - self.request_rebuild() - def undo(self): """ Accesses the last committed transaction, and reverts the data to diff --git a/src/GrampsInMemDB.py b/src/GrampsInMemDB.py index c39e962be..392b060f0 100644 --- a/src/GrampsInMemDB.py +++ b/src/GrampsInMemDB.py @@ -142,8 +142,7 @@ class GrampsInMemDB(GrampsDbBase): if transaction != None: old_data = self.person_map.get(handle) transaction.add(PERSON_KEY,handle,old_data) - if transaction and not transaction.batch: - self.emit('person-delete',([handle],)) + self.emit('person-delete',([handle],)) del self.id_trans[person.get_gramps_id()] del self.person_map[handle] @@ -154,8 +153,7 @@ class GrampsInMemDB(GrampsDbBase): if transaction != None: old_data = self.source_map.get(str(handle)) transaction.add(SOURCE_KEY,handle,old_data) - if transaction and not transaction.batch: - self.emit('source-delete',([handle],)) + self.emit('source-delete',([handle],)) del self.sid_trans[source.get_gramps_id()] del self.source_map[str(handle)] @@ -166,8 +164,7 @@ class GrampsInMemDB(GrampsDbBase): if transaction != None: old_data = self.place_map.get(str(handle)) transaction.add(PLACE_KEY,handle,old_data) - if transaction and not transaction.batch: - self.emit('person-delete',([handle],)) + self.emit('person-delete',([handle],)) del self.pid_trans[place.get_gramps_id()] del self.place_map[str(handle)] @@ -188,8 +185,7 @@ class GrampsInMemDB(GrampsDbBase): if transaction != None: old_data = self.family_map.get(str(handle)) transaction.add(FAMILY_KEY,handle,old_data) - if transaction and not transaction.batch: - self.emit('family-delete',([str(handle),])) + self.emit('family-delete',([str(handle),])) del self.fid_trans[family.get_gramps_id()] del self.family_map[str(handle)] diff --git a/src/ReadGedcom.py b/src/ReadGedcom.py index bf505067e..075efdba0 100644 --- a/src/ReadGedcom.py +++ b/src/ReadGedcom.py @@ -473,6 +473,7 @@ class GedcomParser: self.trans.set_batch(True) else: self.trans = None + self.db.disable_signals() t = time.time() self.index = 0 self.fam_count = 0 @@ -497,8 +498,8 @@ class GedcomParser: if use_trans: self.db.transaction_commit(self.trans,_("GEDCOM import")) - else: - self.db.request_rebuild() + self.db.enable_signals() + self.db.request_rebuild() if self.window: self.infomsg("\n%s" % msg) @@ -828,7 +829,7 @@ class GedcomParser: mrel, frel) break else: - if mrel in rel_types and frel in reltypes: + if mrel in rel_types and frel in rel_types: child.set_main_parent_family_handle(self.family.get_handle()) else: if child.get_main_parents_family_handle() == self.family: @@ -1548,7 +1549,7 @@ class GedcomParser: elif matches[1] == "DATA": date,text = self.parse_source_data(level+1) d = self.dp.parse(date) - source.set_date(d) + source.set_date_object(d) source.set_text(text) elif matches[1] in ["OBJE","REFN","TEXT"]: self.ignore_sub_junk(level+1) diff --git a/src/ReadXML.py b/src/ReadXML.py index 1076cc9f0..72958bc5b 100644 --- a/src/ReadXML.py +++ b/src/ReadXML.py @@ -533,11 +533,15 @@ class GrampsParser: return self.oidswap[handle] def parse(self,file,use_trans=True): + if use_trans: self.trans = self.db.transaction_begin() self.trans.set_batch(True) else: self.trans = None + + self.db.disable_signals() + p = ParserCreate() p.StartElementHandler = self.startElement p.EndElementHandler = self.endElement @@ -561,8 +565,8 @@ class GrampsParser: del p if use_trans: self.db.transaction_commit(self.trans,_("GRAMPS XML import")) - else: - self.db.request_rebuild() + self.db.enable_signals() + self.db.request_rebuild() def start_lds_ord(self,attrs): atype = attrs['type'] diff --git a/src/gramps_main.py b/src/gramps_main.py index 5fcbbb0f3..32567fca5 100755 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -505,6 +505,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): self.emit('database-changed',(self.db,)) def exit_and_undo(self,*args): + self.db.disable_signals() self.db.abort_changes() self.db.set_people_view_maps((None,None,None,None)) gtk.main_quit()