* src/plugins/Rebuild.py (__init__): Proper progress indication.

svn: r7743
This commit is contained in:
Alex Roitman
2006-12-01 16:26:34 +00:00
parent 2c4d5d0750
commit 4fff3e494a
5 changed files with 59 additions and 26 deletions

View File

@@ -53,47 +53,49 @@ import gtk.glade
#
#-------------------------------------------------------------------------
import RelLib
import Utils
import const
from PluginUtils import Tool, register_tool
from QuestionDialog import OkDialog
from BasicUtils import UpdateCallback
#-------------------------------------------------------------------------
#
# runTool
#
#-------------------------------------------------------------------------
class Rebuild(Tool.Tool):
class Rebuild(Tool.Tool,UpdateCallback):
def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.Tool.__init__(self, dbstate, options_class, name)
if self.db.readonly:
# TODO: split plugin in a check and repair part to support
# checking of a read only database
return
self.db.disable_signals()
if uistate:
progress = Utils.ProgressMeter(
_('Rebuilding Secondary Indices'))
# Six indices to rebuild, and the first step is removing
# old ones
total = 7
progress.set_pass('',total)
self.db.rebuild_secondary(progress.step)
progress.close()
OkDialog(_("Secondary indices rebuilt"),
_('All secondary indices have been rebuilt.'))
self.callback = uistate.pulse_progressbar
uistate.set_busy_cursor(1)
uistate.progress.show()
uistate.push_message(dbstate, _("Rebuilding secondary indices..."))
else:
print "Rebuilding Secondary Indices..."
self.db.rebuild_secondary(self.empty)
print "All secondary indices have been rebuilt."
self.db.enable_signals()
def empty(self):
pass
UpdateCallback.__init__(self,self.callback)
self.set_total(11)
self.db.rebuild_secondary(self.update)
self.reset()
if uistate:
uistate.set_busy_cursor(0)
uistate.progress.hide()
OkDialog(_("Secondary indices rebuilt"),
_('All secondary indices have been rebuilt.'))
else:
print "All secondary indices have been rebuilt."
self.db.enable_signals()
#------------------------------------------------------------------------
#

View File

@@ -55,17 +55,17 @@ import gtk.glade
#
#-------------------------------------------------------------------------
import RelLib
import Utils
import const
from PluginUtils import Tool, register_tool
from QuestionDialog import OkDialog
from BasicUtils import UpdateCallback
#-------------------------------------------------------------------------
#
# runTool
#
#-------------------------------------------------------------------------
class RebuildRefMap(Tool.Tool):
class RebuildRefMap(Tool.Tool,UpdateCallback):
def __init__(self, dbstate, uistate, options_class, name, callback=None):
@@ -76,12 +76,25 @@ class RebuildRefMap(Tool.Tool):
self.db.disable_signals()
if uistate:
self.db.reindex_reference_map()
self.callback = uistate.pulse_progressbar
uistate.set_busy_cursor(1)
uistate.progress.show()
uistate.push_message(dbstate, _("Rebuilding reference maps..."))
else:
self.callback = None
print "Rebuilding reference maps..."
UpdateCallback.__init__(self,self.callback)
self.set_total(6)
self.db.reindex_reference_map(self.update)
self.reset()
if uistate:
uistate.set_busy_cursor(0)
uistate.progress.hide()
OkDialog(_("Reference maps rebuilt"),
_('All reference maps have been rebuilt.'))
else:
print "Rebuilding reference maps..."
self.db.reindex_reference_map()
print "All reference maps have been rebuilt."
self.db.enable_signals()