* 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
This commit is contained in:
Alex Roitman 2006-05-03 23:21:49 +00:00
parent 2edee552db
commit 7011115d16
5 changed files with 61 additions and 40 deletions

View File

@ -1,4 +1,11 @@
2006-05-03 Alex Roitman <shura@gramps-project.org>
* 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.

View File

@ -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:
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:
if status:
self.txn.commit()
else:
self.txn.abort()
self.txn = None
return status
def undo_reference(self,data,handle):
if data == None:

View File

@ -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,16 +1230,13 @@ 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)
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,
repository_add= self._do_commit(transaction.repository_add,
self.repository_map)
person_upd = self._do_commit(transaction.person_update,
@ -1253,7 +1251,7 @@ class GrampsDbBase(GrampsDBCallback):
self.media_map)
event_upd = self._do_commit(transaction.event_update,
self.event_map)
repository_upd = self._do_commit(transaction.repository_update,
repository_upd= self._do_commit(transaction.repository_update,
self.repository_map)
self._do_emit('person', person_add, person_upd, transaction.person_del)

View File

@ -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]

View File

@ -319,7 +319,7 @@ class ViewManager:
('Export', gtk.STOCK_SAVE_AS, _('_Export'), "<control>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()