* 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.
|
* src/ViewManager.py: do a better job of building the buttons.
|
||||||
|
|
||||||
2006-05-03 Alex Roitman <shura@gramps-project.org>
|
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/_GrampsInMemDB.py (abort_changes): Remove method.
|
||||||
* src/GrampsDb/_GrampsDbBase.py (abort_changes): Remove method.
|
* src/GrampsDb/_GrampsDbBase.py (abort_changes): Remove method.
|
||||||
(GrampsDbBase.transaction_begin): No aborting after batch transaction.
|
(GrampsDbBase.transaction_begin): No aborting after batch transaction.
|
||||||
@ -10,6 +23,7 @@
|
|||||||
(abort_changes): Remove method.
|
(abort_changes): Remove method.
|
||||||
(GrampsBSDDB.transaction_begin): No aborting after batch transaction.
|
(GrampsBSDDB.transaction_begin): No aborting after batch transaction.
|
||||||
* src/ViewManager.py (abort): Add method for abandoning changes.
|
* src/ViewManager.py (abort): Add method for abandoning changes.
|
||||||
|
(ViewManager.import_data): Add undo warning for imports.
|
||||||
|
|
||||||
* configure.in: Set release to 0.SVN.
|
* configure.in: Set release to 0.SVN.
|
||||||
* src/DataViews/_PersonView.py (define_actions): Change label.
|
* src/DataViews/_PersonView.py (define_actions): Change label.
|
||||||
|
@ -75,7 +75,7 @@ tool_categories = {
|
|||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Report
|
# Tool
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class Tool:
|
class Tool:
|
||||||
@ -97,11 +97,39 @@ class Tool:
|
|||||||
pass
|
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):
|
class ActivePersonTool(Tool):
|
||||||
"""
|
"""
|
||||||
The Tool base class. This is a base class for generating
|
Same as Tool , except the existence of the active person is checked
|
||||||
customized tools. It cannot be used as is, but it can be easily
|
and the tool is aborted if no active person exists. Should be used
|
||||||
sub-classed to create a functional tool.
|
for tools that depend on active person.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, dbstate, options_class, name):
|
def __init__(self, dbstate, options_class, name):
|
||||||
@ -118,7 +146,6 @@ class ActivePersonTool(Tool):
|
|||||||
Tool.__init__(self, dbstate, options_class, name)
|
Tool.__init__(self, dbstate, options_class, name)
|
||||||
self.fail = False
|
self.fail = False
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Command-line tool
|
# Command-line tool
|
||||||
|
@ -1009,6 +1009,20 @@ class ViewManager:
|
|||||||
Exporter.Exporter(self.state, self.uistate)
|
Exporter.Exporter(self.state, self.uistate)
|
||||||
|
|
||||||
def import_data(self, obj):
|
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'),
|
choose = gtk.FileChooserDialog(_('GRAMPS: Import database'),
|
||||||
self.uistate.window,
|
self.uistate.window,
|
||||||
gtk.FILE_CHOOSER_ACTION_OPEN,
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||||
|
@ -7695,6 +7695,7 @@ Text Beside Icons</property>
|
|||||||
<property name="can_default">True</property>
|
<property name="can_default">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label">gtk-cancel</property>
|
<property name="label">gtk-cancel</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
<property name="focus_on_click">True</property>
|
<property name="focus_on_click">True</property>
|
||||||
|
@ -57,12 +57,14 @@ from PluginUtils import Tool, register_tool
|
|||||||
# ChangeNames
|
# ChangeNames
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class ChangeNames(Tool.Tool, ManagedWindow.ManagedWindow):
|
class ChangeNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||||
|
|
||||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||||
self.label = _('Capitalization changes')
|
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__)
|
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||||
|
|
||||||
self.cb = callback
|
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):
|
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:
|
if uistate:
|
||||||
self.title = _('Change Event Types')
|
self.title = _('Change Event Types')
|
||||||
@ -110,7 +112,7 @@ class ChangeTypes(Tool.Tool, ManagedWindow.ManagedWindow):
|
|||||||
|
|
||||||
modified = 0
|
modified = 0
|
||||||
|
|
||||||
self.trans = self.db.transaction_begin()
|
self.trans = self.db.transaction_begin("",batch=True)
|
||||||
if not cli:
|
if not cli:
|
||||||
progress = Utils.ProgressMeter(_('Analyzing events'),'')
|
progress = Utils.ProgressMeter(_('Analyzing events'),'')
|
||||||
progress.set_pass('',self.db.get_number_of_people())
|
progress.set_pass('',self.db.get_number_of_people())
|
||||||
|
@ -138,10 +138,12 @@ def _table_low_level(db,table):
|
|||||||
# runTool
|
# runTool
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class Check(Tool.Tool):
|
class Check(Tool.BatchTool):
|
||||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
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
|
cli = uistate == None
|
||||||
|
|
||||||
|
@ -85,16 +85,18 @@ _sn_prefix_re = re.compile("^\s*(%s)\s+(.*)" % '|'.join(prefix_list),
|
|||||||
# PatchNames
|
# PatchNames
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class PatchNames(Tool.Tool, ManagedWindow.ManagedWindow):
|
class PatchNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||||
|
|
||||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||||
self.label = _('Name and title extraction tool')
|
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__)
|
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
|
||||||
|
|
||||||
self.cb = callback
|
self.cb = callback
|
||||||
self.trans = self.db.transaction_begin()
|
self.trans = self.db.transaction_begin("",batch=True)
|
||||||
self.title_list = []
|
self.title_list = []
|
||||||
self.nick_list = []
|
self.nick_list = []
|
||||||
self.prefix1_list = []
|
self.prefix1_list = []
|
||||||
|
@ -50,9 +50,11 @@ _findint = re.compile('^[^\d]*(\d+)[^\d]*')
|
|||||||
# Actual tool
|
# Actual tool
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class ReorderIds(Tool.Tool):
|
class ReorderIds(Tool.BatchTool):
|
||||||
def __init__(self,dbstate,uistate,options_class,name,callback=None):
|
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
|
db = dbstate.db
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
@ -61,7 +63,7 @@ class ReorderIds(Tool.Tool):
|
|||||||
else:
|
else:
|
||||||
print "Reordering GRAMPS IDs..."
|
print "Reordering GRAMPS IDs..."
|
||||||
|
|
||||||
self.trans = db.transaction_begin()
|
self.trans = db.transaction_begin("",batch=True)
|
||||||
|
|
||||||
if uistate:
|
if uistate:
|
||||||
self.progress.set_pass(_('Reordering People IDs'),
|
self.progress.set_pass(_('Reordering People IDs'),
|
||||||
|
Loading…
Reference in New Issue
Block a user