From ee51d0bd5f108343a043d0d733f0f82d4778f406 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sat, 9 Feb 2008 21:15:29 +0000 Subject: [PATCH] Added a delay before resetting the download counters in the GUI. Often, we finish a download and then start another one right away (e.g. downloading a feed and then its key). Count that as a sequence of two downloads, not two single downloads. --- zeroinstall/0launch-gui/gui.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/zeroinstall/0launch-gui/gui.py b/zeroinstall/0launch-gui/gui.py index 9adacf1..6d3c3d5 100644 --- a/zeroinstall/0launch-gui/gui.py +++ b/zeroinstall/0launch-gui/gui.py @@ -10,6 +10,16 @@ class GUIHandler(handler.Handler): pulse = None mainwindow = None + def _reset_counters(self): + if not self.monitored_downloads: + self.n_completed_downloads = 0 + self.total_bytes_downloaded = 0 + return False + + def abort_all_downloads(self): + for dl in self.monitored_downloads.values(): + dl.abort() + def downloads_changed(self): if self.monitored_downloads and self.pulse is None: def pulse(): @@ -18,9 +28,8 @@ class GUIHandler(handler.Handler): pulse() self.pulse = gobject.timeout_add(50, pulse) elif len(self.monitored_downloads) == 0: - # Reset counters - self.n_completed_downloads = 0 - self.total_bytes_downloaded = 0 + # Delay before resetting, in case we start a new download quickly + gobject.timeout_add(500, self._reset_counters) # Stop animation if self.pulse: -- 2.11.4.GIT