aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2008-04-14 23:31:55 +0000
committerFelix Domke <tmbinc@elitedvb.net>2008-04-14 23:31:55 +0000
commit803d9e3bf21e233a3100ed32904d9035e67774a9 (patch)
tree247307f8d64aa7725446884c83dbd4ce9fed643f /lib
parent7323c18997d7dad3d7e6fea1a45f01e1528a93a7 (diff)
downloadenigma2-803d9e3bf21e233a3100ed32904d9035e67774a9.tar.gz
enigma2-803d9e3bf21e233a3100ed32904d9035e67774a9.zip
Add TaskView, a screen to display job progress
Diffstat (limited to 'lib')
-rw-r--r--lib/python/Screens/Makefile.am2
-rw-r--r--lib/python/Screens/TaskView.py53
2 files changed, 54 insertions, 1 deletions
diff --git a/lib/python/Screens/Makefile.am b/lib/python/Screens/Makefile.am
index 0451c6d1..dd3baf08 100644
--- a/lib/python/Screens/Makefile.am
+++ b/lib/python/Screens/Makefile.am
@@ -13,4 +13,4 @@ install_PYTHON = \
TimerSelection.py PictureInPicture.py TimeDateInput.py \
SubtitleDisplay.py SubservicesQuickzap.py ParentalControlSetup.py NumericalTextInputHelpDialog.py \
SleepTimerEdit.py Ipkg.py RdsDisplay.py Globals.py \
- SessionGlobals.py LocationBox.py WizardLanguage.py
+ SessionGlobals.py LocationBox.py WizardLanguage.py TaskView.py
diff --git a/lib/python/Screens/TaskView.py b/lib/python/Screens/TaskView.py
new file mode 100644
index 00000000..25285852
--- /dev/null
+++ b/lib/python/Screens/TaskView.py
@@ -0,0 +1,53 @@
+from Screen import Screen
+
+class JobView(Screen):
+ def __init__(self, session, job, cancelable = True, close_on_finish = False):
+ from Components.Sources.StaticText import StaticText
+ from Components.Sources.Progress import Progress
+ from Components.ActionMap import ActionMap
+ Screen.__init__(self, session)
+ self.job = job
+ self.close_on_finish = close_on_finish
+
+ self["job_name"] = StaticText(job.name)
+ self["job_progress"] = Progress()
+ self["job_status"] = StaticText()
+ self["job_task"] = StaticText()
+
+ self.onShow.append(self.windowShow)
+ self.onHide.append(self.windowHide)
+
+ self["actions"] = ActionMap(["OkCancelActions"],
+ {
+ "ok": self.ok,
+ "cancel": self.abort
+ })
+
+ def windowShow(self):
+ self.job.state_changed.append(self.state_changed)
+ self.state_changed()
+
+ def windowHide(self):
+ self.job.state_changed.remove(self.state_changed)
+
+ def state_changed(self):
+ j = self.job
+ self["job_progress"].range = len(j.tasks)
+ self["job_progress"].value = j.current_task
+ self["job_status"].text = {j.NOT_STARTED: _("Waiting"), j.IN_PROGRESS: _("In Progress"), j.FINISHED: _("Finished"), j.FAILED: _("Failed")}[j.status]
+ if j.status == j.IN_PROGRESS:
+ self["job_task"].text = j.tasks[j.current_task].name
+ else:
+ self["job_task"].text = ""
+ if j.status in [j.FINISHED, j.FAILED] and self.close_on_finish:
+ self.close()
+
+ def ok(self):
+ if self.job.status in [self.job.FINISHED, self.job.FAILED]:
+ self.close()
+
+ def abort(self):
+ if self.job.status in [self.job.FINISHED, self.job.FAILED]:
+ self.close()
+ if self.cancelable:
+ self.job.cancel()