* src/PluginUtils/_Tool.py (BatchTool): Add class taking care of
tools with batch transactions. (ActivePersonTool.pass): Remove method. * src/plugins/Check.py (Check): Derive from BatchTool. * src/plugins/ReorderIds.py (ReorderIds): Use batch transactions; derive from BatchTool. * src/plugins/ChangeTypes.py (ChangeTypes): Use batch transactions; derive from BatchTool. * src/plugins/ChangeNames.py (ChangeNames): Derive from BatchTool. * src/plugins/PatchNames.py (PatchNames): Use batch transactions; derive from BatchTool. * src/glade/gramps.glade: Make both buttons' lables in questiondialog use underline property. (ViewManager.import_data): Add undo warning for imports. svn: r6540
This commit is contained in:
parent
23b7ec08d6
commit
4ea2ca6a28
@ -2,6 +2,19 @@
|
||||
* src/ViewManager.py: do a better job of building the buttons.
|
||||
|
||||
2006-05-03 Alex Roitman <shura@gramps-project.org>
|
||||
* src/PluginUtils/_Tool.py (BatchTool): Add class taking care of
|
||||
tools with batch transactions.
|
||||
(ActivePersonTool.pass): Remove method.
|
||||
* src/plugins/Check.py (Check): Derive from BatchTool.
|
||||
* src/plugins/ReorderIds.py (ReorderIds): Use batch transactions;
|
||||
derive from BatchTool.
|
||||
* src/plugins/ChangeTypes.py (ChangeTypes): Use batch
|
||||
transactions; derive from BatchTool.
|
||||
* src/plugins/ChangeNames.py (ChangeNames): Derive from BatchTool.
|
||||
* src/plugins/PatchNames.py (PatchNames): Use batch transactions;
|
||||
derive from BatchTool.
|
||||
* src/glade/gramps.glade: Make both buttons' lables in
|
||||
questiondialog use underline property.
|
||||
* src/GrampsDb/_GrampsInMemDB.py (abort_changes): Remove method.
|
||||
* src/GrampsDb/_GrampsDbBase.py (abort_changes): Remove method.
|
||||
(GrampsDbBase.transaction_begin): No aborting after batch transaction.
|
||||
@ -10,6 +23,7 @@
|
||||
(abort_changes): Remove method.
|
||||
(GrampsBSDDB.transaction_begin): No aborting after batch transaction.
|
||||
* src/ViewManager.py (abort): Add method for abandoning changes.
|
||||
(ViewManager.import_data): Add undo warning for imports.
|
||||
|
||||
* configure.in: Set release to 0.SVN.
|
||||
* src/DataViews/_PersonView.py (define_actions): Change label.
|
||||
|
@ -75,7 +75,7 @@ tool_categories = {
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Report
|
||||
# Tool
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Tool:
|
||||
@ -97,11 +97,39 @@ class Tool:
|
||||
pass
|
||||
|
||||
|
||||
class BatchTool(Tool):
|
||||
"""
|
||||
Same as Tool, except the warning is displayed about the potential
|
||||
loss of undo history. Should be used for tools using batch transactions.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dbstate, options_class, name):
|
||||
from QuestionDialog import QuestionDialog2
|
||||
warn_dialog = QuestionDialog2(
|
||||
_('Undo history warning'),
|
||||
_('Proceeding with this tool will erase the undo history '
|
||||
'for this session. In particular, you will not be able '
|
||||
'to revert the changes made by this tool or any changes '
|
||||
'made prior to it.\n\n'
|
||||
'If you think you may want to revert running this tool, '
|
||||
'please stop here and backup your database.'),
|
||||
_('_Proceed with the tool'), _('_Stop'))
|
||||
if not warn_dialog.run():
|
||||
self.fail = True
|
||||
return
|
||||
|
||||
Tool.__init__(self, dbstate, options_class, name)
|
||||
self.fail = False
|
||||
|
||||
def run_tool(self): pass
|
||||
|
||||
|
||||
class ActivePersonTool(Tool):
|
||||
"""
|
||||
The Tool base class. This is a base class for generating
|
||||
customized tools. It cannot be used as is, but it can be easily
|
||||
sub-classed to create a functional tool.
|
||||
Same as Tool , except the existence of the active person is checked
|
||||
and the tool is aborted if no active person exists. Should be used
|
||||
for tools that depend on active person.
|
||||
"""
|
||||
|
||||
def __init__(self, dbstate, options_class, name):
|
||||
@ -118,7 +146,6 @@ class ActivePersonTool(Tool):
|
||||
Tool.__init__(self, dbstate, options_class, name)
|
||||
self.fail = False
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Command-line tool
|
||||
|
@ -1009,13 +1009,27 @@ class ViewManager:
|
||||
Exporter.Exporter(self.state, self.uistate)
|
||||
|
||||
def import_data(self, obj):
|
||||
# First thing first: import is a batch transaction
|
||||
# so we will lose the undo history. Warn the user.
|
||||
warn_dialog = QuestionDialog.QuestionDialog2(
|
||||
_('Undo history warning'),
|
||||
_('Proceeding with import will erase the undo history '
|
||||
'for this session. In particular, you will not be able '
|
||||
'to revert the import or any changes made prior to it.\n\n'
|
||||
'If you think you may want to revert the import, '
|
||||
'please stop here and backup your database.'),
|
||||
_('_Proceed with import'), _('_Stop'),
|
||||
self.window)
|
||||
if not warn_dialog.run():
|
||||
return False
|
||||
|
||||
choose = gtk.FileChooserDialog(_('GRAMPS: Import database'),
|
||||
self.uistate.window,
|
||||
gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
(gtk.STOCK_CANCEL,
|
||||
gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN,
|
||||
gtk.RESPONSE_OK))
|
||||
self.uistate.window,
|
||||
gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
(gtk.STOCK_CANCEL,
|
||||
gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN,
|
||||
gtk.RESPONSE_OK))
|
||||
choose.set_local_only(False)
|
||||
# Always add automatic (macth all files) filter
|
||||
add_all_files_filter(choose)
|
||||
|
@ -7695,6 +7695,7 @@ Text Beside Icons</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
|
@ -57,12 +57,14 @@ from PluginUtils import Tool, register_tool
|
||||
# ChangeNames
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class ChangeNames(Tool.Tool, ManagedWindow.ManagedWindow):
|
||||
class ChangeNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
|
||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||
self.label = _('Capitalization changes')
|
||||
|
||||
Tool.Tool.__init__(self, dbstate, options_class, name)
|
||||
Tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
if self.fail:
|
||||
return
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||
|
||||
self.cb = callback
|
||||
|
@ -56,11 +56,13 @@ from PluginUtils import Tool, register_tool
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class ChangeTypes(Tool.Tool, ManagedWindow.ManagedWindow):
|
||||
class ChangeTypes(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
|
||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||
|
||||
Tool.Tool.__init__(self, dbstate, options_class, name)
|
||||
Tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
if self.fail:
|
||||
return
|
||||
|
||||
if uistate:
|
||||
self.title = _('Change Event Types')
|
||||
@ -110,7 +112,7 @@ class ChangeTypes(Tool.Tool, ManagedWindow.ManagedWindow):
|
||||
|
||||
modified = 0
|
||||
|
||||
self.trans = self.db.transaction_begin()
|
||||
self.trans = self.db.transaction_begin("",batch=True)
|
||||
if not cli:
|
||||
progress = Utils.ProgressMeter(_('Analyzing events'),'')
|
||||
progress.set_pass('',self.db.get_number_of_people())
|
||||
|
@ -138,10 +138,12 @@ def _table_low_level(db,table):
|
||||
# runTool
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Check(Tool.Tool):
|
||||
class Check(Tool.BatchTool):
|
||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||
|
||||
Tool.Tool.__init__(self, dbstate, options_class, name)
|
||||
Tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
if self.fail:
|
||||
return
|
||||
|
||||
cli = uistate == None
|
||||
|
||||
|
@ -85,16 +85,18 @@ _sn_prefix_re = re.compile("^\s*(%s)\s+(.*)" % '|'.join(prefix_list),
|
||||
# PatchNames
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class PatchNames(Tool.Tool, ManagedWindow.ManagedWindow):
|
||||
class PatchNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
|
||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||
self.label = _('Name and title extraction tool')
|
||||
|
||||
Tool.Tool.__init__(self, dbstate, options_class, name)
|
||||
Tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
if self.fail:
|
||||
return
|
||||
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
|
||||
|
||||
self.cb = callback
|
||||
self.trans = self.db.transaction_begin()
|
||||
self.trans = self.db.transaction_begin("",batch=True)
|
||||
self.title_list = []
|
||||
self.nick_list = []
|
||||
self.prefix1_list = []
|
||||
|
@ -50,9 +50,11 @@ _findint = re.compile('^[^\d]*(\d+)[^\d]*')
|
||||
# Actual tool
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class ReorderIds(Tool.Tool):
|
||||
class ReorderIds(Tool.BatchTool):
|
||||
def __init__(self,dbstate,uistate,options_class,name,callback=None):
|
||||
Tool.Tool.__init__(self,dbstate,options_class,name)
|
||||
Tool.BatchTool.__init__(self,dbstate,options_class,name)
|
||||
if self.fail:
|
||||
return
|
||||
|
||||
db = dbstate.db
|
||||
self.uistate = uistate
|
||||
@ -61,7 +63,7 @@ class ReorderIds(Tool.Tool):
|
||||
else:
|
||||
print "Reordering GRAMPS IDs..."
|
||||
|
||||
self.trans = db.transaction_begin()
|
||||
self.trans = db.transaction_begin("",batch=True)
|
||||
|
||||
if uistate:
|
||||
self.progress.set_pass(_('Reordering People IDs'),
|
||||
|
Loading…
Reference in New Issue
Block a user