summaryrefslogtreecommitdiff
path: root/UpdateManager
diff options
context:
space:
mode:
authorSebastian Heinlein <sebastian.heinlein@web.de>2006-03-13 17:56:15 +0100
committerSebastian Heinlein <sebastian.heinlein@web.de>2006-03-13 17:56:15 +0100
commit32a7e2a37cfaeb7d128c59edd0c32c79de2a5040 (patch)
tree51ef4ff81312bca90c265026e7a4eb692b955c9d /UpdateManager
parente5957364bec1460ca4ae1ea48992c77653ea97be (diff)
downloadpython-apt-32a7e2a37cfaeb7d128c59edd0c32c79de2a5040.tar.gz
* only run the progress bar one time during cache init
* avoid flickering of the dialog and hide the window after the init of MyCache
Diffstat (limited to 'UpdateManager')
-rw-r--r--UpdateManager/GtkProgress.py36
-rw-r--r--UpdateManager/UpdateManager.py11
2 files changed, 33 insertions, 14 deletions
diff --git a/UpdateManager/GtkProgress.py b/UpdateManager/GtkProgress.py
index d11ca3e9..54f60384 100644
--- a/UpdateManager/GtkProgress.py
+++ b/UpdateManager/GtkProgress.py
@@ -26,8 +26,19 @@ import apt
import apt_pkg
from gettext import gettext as _
+# intervals of the start up progress
+# 3x caching and menu creation
+STEPS_UPDATE_CACHE = [33, 66, 100]
+
class GtkOpProgress(apt.OpProgress):
- def __init__(self, host_window, progressbar, status, parent):
+ def __init__(self, host_window, progressbar, status, parent,
+ steps=STEPS_UPDATE_CACHE):
+ # used for the "one run progressbar"
+ self.steps = steps[:]
+ self.base = 0
+ self.old = 0
+ self.next = int(self.steps.pop(0))
+
self._parent = parent
self._window = host_window
self._status = status
@@ -35,27 +46,32 @@ class GtkOpProgress(apt.OpProgress):
# Do not show the close button
self._window.realize()
host_window.window.set_functions(gtk.gdk.FUNC_MOVE)
- #self._progressbar.set_pulse_step(0.01)
- #self._progressbar.pulse()
self._window.set_transient_for(parent)
+
def update(self, percent):
#print percent
#print self.Op
#print self.SubOp
- # Use pulse until apt doesn't restarts the progress bar
- # several times
self._window.show()
self._parent.set_sensitive(False)
+ # if the old percent was higher, a new progress was started
+ if self.old > percent:
+ # set the borders to the next interval
+ self.base = self.next
+ try:
+ self.next = int(self.steps.pop(0))
+ except:
+ pass
+ progress = self.base + percent/100 * (self.next - self.base)
+ self.old = percent
self._status.set_markup("<i>%s</i>" % self.op)
- self._progressbar.set_fraction(percent/100.0)
- #if percent > 99:
- # self._progressbar.set_fraction(1)
- #else:
- # self._progressbar.pulse()
+ self._progressbar.set_fraction(progress/100.0)
while gtk.events_pending():
gtk.main_iteration()
+
def done(self):
self._parent.set_sensitive(True)
+ def hide(self):
self._window.hide()
class GtkFetchProgress(apt.progress.FetchProgress):
diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py
index 20001937..2bb9ed0e 100644
--- a/UpdateManager/UpdateManager.py
+++ b/UpdateManager/UpdateManager.py
@@ -683,10 +683,11 @@ class UpdateManager(SimpleGladeApp):
sys.exit()
try:
- self.cache = MyCache(GtkProgress.GtkOpProgress(self.dialog_cacheprogress,
- self.progressbar_cache,
- self.label_cache,
- self.window_main))
+ progress = GtkProgress.GtkOpProgress(self.dialog_cacheprogress,
+ self.progressbar_cache,
+ self.label_cache,
+ self.window_main)
+ self.cache = MyCache(progress)
except AssertionError:
# we assert a clean cache
msg=("<big><b>%s</b></big>\n\n%s"% \
@@ -703,6 +704,8 @@ class UpdateManager(SimpleGladeApp):
dialog.run()
dialog.destroy()
sys.exit(1)
+ else:
+ progress.hide()
#apt_pkg.Config.Set("Debug::pkgPolicy","1")
#self.depcache = apt_pkg.GetDepCache(self.cache)
self.cache._depcache.ReadPinFile()