[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[PATCH 2/2] Rate limit pulse() calls to ProgressWindow.
- From: Peter Jones <pjones redhat com>
- To: anaconda-devel-list redhat com
- Cc:
- Subject: [PATCH 2/2] Rate limit pulse() calls to ProgressWindow.
- Date: Wed, 29 Apr 2009 15:44:28 -0400
Make the pulsed progress windows only pulse but so quickly. The net
effect is that the filesystem creation progress window now slides back
and forth (albeit with a little much punctuation) rather than blindingly
oscillating at breakneck speed.
---
gui.py | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/gui.py b/gui.py
index 2c5fa9a..ad71dc1 100755
--- a/gui.py
+++ b/gui.py
@@ -487,7 +487,7 @@ class ProgressWindow:
self.window.set_modal(True)
self.window.set_title (title)
self.window.set_position (gtk.WIN_POS_CENTER)
- self.lastUpdate = int(time.time())
+ self.lastUpdate = time.time()
self.updsecs = updsecs
box = gtk.VBox (False, 5)
box.set_border_width (10)
@@ -511,9 +511,18 @@ class ProgressWindow:
processEvents()
def pulse(self):
+ then = self.lastUpdate
+ now = time.time()
+ delta = now-then
+ if delta < 0.01:
+ return
self.progress.set_pulse_step(self.updpct)
- self.progress.pulse()
- processEvents()
+ self.lastUpdate = now
+ # if we've had a largish gap, some smoothing does actually help.
+ while delta > 0:
+ self.progress.pulse()
+ processEvents()
+ delta -= 0.05
def set (self, amount):
# only update widget if we've changed by 5% or our timeout has
@@ -521,7 +530,7 @@ class ProgressWindow:
curval = self.progress.get_fraction()
newval = float (amount) / self.total
then = self.lastUpdate
- now = int(time.time())
+ now = time.time()
if newval < 0.998:
if ((newval - curval) < self.updpct and (now-then) < self.updsecs):
return
--
1.6.2.2
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]