diff options
| author | Michael Vogt <egon@top> | 2005-12-01 16:11:53 +0100 |
|---|---|---|
| committer | Michael Vogt <egon@top> | 2005-12-01 16:11:53 +0100 |
| commit | f5b1a4bae67c8eac0e2218b0e3c3e85adaf409ea (patch) | |
| tree | 671364df765fbd8bd56f697fc2eee7e266db5004 /UpdateManager/GtkProgress.py | |
| parent | 7e6db3ee0e78a1c8c99ad949a8e1bf33a5baad0b (diff) | |
| download | python-apt-f5b1a4bae67c8eac0e2218b0e3c3e85adaf409ea.tar.gz | |
* dist-upgade tool can fetch the update tarball now
* update will use the internal fetcher now too
Diffstat (limited to 'UpdateManager/GtkProgress.py')
| -rw-r--r-- | UpdateManager/GtkProgress.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/UpdateManager/GtkProgress.py b/UpdateManager/GtkProgress.py index d1cdf230..f60a06d8 100644 --- a/UpdateManager/GtkProgress.py +++ b/UpdateManager/GtkProgress.py @@ -2,6 +2,7 @@ import pygtk pygtk.require('2.0') import gtk import apt +import apt_pkg from gettext import gettext as _ class GtkOpProgress(apt.progress.OpProgress): @@ -16,3 +17,41 @@ class GtkOpProgress(apt.progress.OpProgress): def done(self): self._progressbar.hide() + +class GtkFetchProgress(apt.progress.FetchProgress): + def __init__(self, parent, summary="", descr=""): + # if this is set to false the download will cancel + self._continue = True + # init vars here + # FIXME: find a more elegant way, this sucks + self.summary = parent.label_fetch_summary + self.status = parent.label_fetch_status + self.progress = parent.progressbar_fetch + self.window_fetch = parent.window_fetch + self.window_fetch.set_transient_for(parent.window_main) + # set summary + if self.summary != "": + self.summary.set_markup("<big><b>%s</b></big> \n\n%s" % + (summary, descr)) + self.window_fetch.set_title(summary) + def start(self): + self.progress.set_fraction(0) + self.window_fetch.show() + def stop(self): + self.window_fetch.hide() + def on_button_fetch_cancel_clicked(self, widget): + self._continue = False + def pulse(self): + apt.progress.FetchProgress.pulse(self) + if self.currentCPS > 0: + self.status.set_text(_("Download rate: %s/s - %s remaining" % (apt_pkg.SizeToStr(self.currentCPS), apt_pkg.TimeToStr(self.eta)))) + else: + self.status.set_text(_("Download rate: unkown")) + self.progress.set_fraction(self.percent/100.0) + currentItem = self.currentItems + 1 + if currentItem > self.totalItems: + currentItem = self.totalItems + self.progress.set_text(_("Downloading file %li of %li" % (currentItem, self.totalItems))) + while gtk.events_pending(): + gtk.main_iteration() + return self._continue |
