From 91f4dcabd2bd6b83afae5d58928cc8e1353286ef Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 7 Aug 2012 04:13:53 +0200 Subject: widgets.taskview: show progressbar only if task supports it --- ranger/core/loader.py | 2 +- ranger/gui/widgets/taskview.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ranger/core/loader.py b/ranger/core/loader.py index 2b7747c6..7bbd2abf 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -20,7 +20,7 @@ class Loadable(object): def __init__(self, gen, descr): self.load_generator = gen self.description = descr - self.percent = 0 + self.percent = -1 def get_description(self): return self.description diff --git a/ranger/gui/widgets/taskview.py b/ranger/gui/widgets/taskview.py index 582bb76d..53da5826 100644 --- a/ranger/gui/widgets/taskview.py +++ b/ranger/gui/widgets/taskview.py @@ -51,10 +51,14 @@ class TaskView(Widget, Accumulator): clr.append('selected') descr = obj.get_description() - self.addstr(y, 0, "%3d%% - %s" % (obj.percent, descr), self.wid) - wid = int(self.wid / 100.0 * obj.percent) - self.color_at(y, 0, self.wid, tuple(clr)) - self.color_at(y, 0, wid, tuple(clr), 'loaded') + if obj.percent >= 0 and obj.percent <= 100: + self.addstr(y, 0, "%3d%% - %s" % (obj.percent, descr), self.wid) + wid = int(self.wid / 100.0 * obj.percent) + self.color_at(y, 0, self.wid, tuple(clr)) + self.color_at(y, 0, wid, tuple(clr), 'loaded') + else: + self.addstr(y, 0, descr, self.wid) + self.color_at(y, 0, self.wid, tuple(clr)) else: if self.hei > 1: -- cgit 1.4.1-2-gfad0