From 7011115d16cad5aaef1b3d3db1f3d4a6fcfc10e0 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 3 May 2006 23:21:49 +0000 Subject: [PATCH] * src/GrampsDb/_GrampsInMemDB.py (abort_changes): Remove method. * src/GrampsDb/_GrampsDbBase.py (abort_changes): Remove method. * src/GrampsDb/_GrampsBSDDB.py (undo,redo): Use the status from GrampsDbBase undo/redo; (abort_changes): Remove method. * src/ViewManager.py (abort): Add method for abandoning changes. svn: r6536 --- ChangeLog | 7 +++++ src/GrampsDb/_GrampsBSDDB.py | 23 +++++++++------- src/GrampsDb/_GrampsDbBase.py | 50 ++++++++++++++++------------------ src/GrampsDb/_GrampsInMemDB.py | 3 -- src/ViewManager.py | 18 +++++++++++- 5 files changed, 61 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index 599b359d3..0da0f8b6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,11 @@ 2006-05-03 Alex Roitman + * src/GrampsDb/_GrampsInMemDB.py (abort_changes): Remove method. + * src/GrampsDb/_GrampsDbBase.py (abort_changes): Remove method. + * src/GrampsDb/_GrampsBSDDB.py (undo,redo): Use the status from + GrampsDbBase undo/redo; + (abort_changes): Remove method. + * src/ViewManager.py (abort): Add method for abandoning changes. + * configure.in: Set release to 0.SVN. * src/DataViews/_PersonView.py (define_actions): Change label. diff --git a/src/GrampsDb/_GrampsBSDDB.py b/src/GrampsDb/_GrampsBSDDB.py index 55c4a4ae9..9b35568a8 100644 --- a/src/GrampsDb/_GrampsBSDDB.py +++ b/src/GrampsDb/_GrampsBSDDB.py @@ -795,11 +795,6 @@ class GrampsBSDDB(GrampsDbBase): return - def abort_changes(self): - while self.undo(): - pass - self.close() - def close(self): if not self.db_is_open: return @@ -1138,19 +1133,27 @@ class GrampsBSDDB(GrampsDbBase): print "Undoing it" if self.UseTXN: self.txn = self.env.txn_begin() - GrampsDbBase.undo(self) + status = GrampsDbBase.undo(self) if self.UseTXN: - self.txn.commit() + if status: + self.txn.commit() + else: + self.txn.abort() self.txn = None + return status def redo(self): print "Redoing it" if self.UseTXN: self.txn = self.env.txn_begin() - GrampsDbBase.redo(self) + status = GrampsDbBase.redo(self) if self.UseTXN: - self.txn.commit() - self.txn = None + if status: + self.txn.commit() + else: + self.txn.abort() + self.txn = None + return status def undo_reference(self,data,handle): if data == None: diff --git a/src/GrampsDb/_GrampsDbBase.py b/src/GrampsDb/_GrampsDbBase.py index e9590b302..783eaad7a 100644 --- a/src/GrampsDb/_GrampsDbBase.py +++ b/src/GrampsDb/_GrampsDbBase.py @@ -259,6 +259,7 @@ class GrampsDbBase(GrampsDBCallback): self.undoindex = -1 self.translist = [None] * _UNDO_SIZE + self.abort_possible = True self.default = None self.owner = Researcher() self.bookmarks = [] @@ -345,9 +346,6 @@ class GrampsDbBase(GrampsDBCallback): """ pass - def abort_changes(self): - pass - def is_open(self): """ Returns 1 if the database has been opened. @@ -1221,6 +1219,9 @@ class GrampsDbBase(GrampsDBCallback): transaction.set_description(msg) self.undoindex += 1 if self.undoindex >= _UNDO_SIZE: + # We overran the undo size. + # Aborting the session completely will become impossible. + self.abort_possible = False self.translist = self.translist[0:-1] + [ transaction ] else: self.translist[self.undoindex] = transaction @@ -1229,32 +1230,29 @@ class GrampsDbBase(GrampsDBCallback): for index in range(self.undoindex+1, _UNDO_SIZE): self.translist[index] = None - person_add = self._do_commit(transaction.person_add, - self.person_map) - family_add = self._do_commit(transaction.family_add, - self.family_map) - source_add = self._do_commit(transaction.source_add, - self.source_map) - place_add = self._do_commit(transaction.place_add, self.place_map) - media_add = self._do_commit(transaction.media_add, self.media_map) - event_add = self._do_commit(transaction.event_add, self.event_map) - repository_add = self._do_commit(transaction.repository_add, + person_add = self._do_commit(transaction.person_add,self.person_map) + family_add = self._do_commit(transaction.family_add,self.family_map) + source_add = self._do_commit(transaction.source_add,self.source_map) + place_add = self._do_commit(transaction.place_add, self.place_map) + media_add = self._do_commit(transaction.media_add, self.media_map) + event_add = self._do_commit(transaction.event_add, self.event_map) + repository_add= self._do_commit(transaction.repository_add, self.repository_map) - person_upd = self._do_commit(transaction.person_update, - self.person_map) - family_upd = self._do_commit(transaction.family_update, - self.family_map) - source_upd = self._do_commit(transaction.source_update, - self.source_map) - place_upd = self._do_commit(transaction.place_update, + person_upd = self._do_commit(transaction.person_update, + self.person_map) + family_upd = self._do_commit(transaction.family_update, + self.family_map) + source_upd = self._do_commit(transaction.source_update, + self.source_map) + place_upd = self._do_commit(transaction.place_update, self.place_map) - media_upd = self._do_commit(transaction.media_update, - self.media_map) - event_upd = self._do_commit(transaction.event_update, - self.event_map) - repository_upd = self._do_commit(transaction.repository_update, - self.repository_map) + media_upd = self._do_commit(transaction.media_update, + self.media_map) + event_upd = self._do_commit(transaction.event_update, + self.event_map) + repository_upd= self._do_commit(transaction.repository_update, + self.repository_map) self._do_emit('person', person_add, person_upd, transaction.person_del) self._do_emit('family', family_add, family_upd, transaction.family_del) diff --git a/src/GrampsDb/_GrampsInMemDB.py b/src/GrampsDb/_GrampsInMemDB.py index e2a6e7cc1..ceee636ed 100644 --- a/src/GrampsDb/_GrampsInMemDB.py +++ b/src/GrampsDb/_GrampsInMemDB.py @@ -137,9 +137,6 @@ class GrampsInMemDB(GrampsDbBase): except: pass - def abort_changes(self): - pass - def set_name_group_mapping(self,name,group): if group == None and self.name_group.has_key(name): del self.name_group[name] diff --git a/src/ViewManager.py b/src/ViewManager.py index 0386ba14b..db87a9292 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -319,7 +319,7 @@ class ViewManager: ('Export', gtk.STOCK_SAVE_AS, _('_Export'), "e", None, self.export_data), ('Abandon', gtk.STOCK_REVERT_TO_SAVED, - _('_Abandon changes and quit')), + _('_Abandon changes and quit'), None, None, self.abort), ('CmpMerge', None, _('_Compare and merge')), ('FastMerge', None, _('_Fast merge')), ('ScratchPad', gtk.STOCK_PASTE, _('_ScratchPad'), "", None, @@ -409,6 +409,22 @@ class ViewManager: Config.sync() gtk.main_quit() + def abort(self,obj=None): + """ + Abandon changes and quit. + """ + if self.state.db.abort_possible: + self.state.db.disable_signals() + while self.state.db.undo(): + pass + self.quit() + else: + QuestionDialog.WarningDialog( + _('Cannot cleanly abandon changes'), + _('Changes cannot be abandoned because the number of ' + 'changes made exceeded the limit.')) + + def _build_ui_manager(self): self.merge_ids = [] self.uimanager = gtk.UIManager()