allow DVD burning in background. to view progress of jobs, press extensions key ...
authorAndreas Frisch <andreas.frisch@multimedia-labs.de>
Mon, 13 Oct 2008 18:29:57 +0000 (18:29 +0000)
committerAndreas Frisch <andreas.frisch@multimedia-labs.de>
Mon, 13 Oct 2008 18:29:57 +0000 (18:29 +0000)
data/skin_default.xml
lib/python/Components/Task.py
lib/python/Plugins/Extensions/DVDBurn/Process.py
lib/python/Plugins/Extensions/DVDBurn/TitleList.py
lib/python/Screens/InfoBar.py
lib/python/Screens/InfoBarGenerics.py
lib/python/Screens/TaskView.py
po/de.po

index aeee84a..f541f81 100644 (file)
@@ -1118,7 +1118,7 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y()))
                        <convert type="ConditionalShowHide">Blink</convert>
                </widget>
        </screen>
                        <convert type="ConditionalShowHide">Blink</convert>
                </widget>
        </screen>
-       <screen name="JobView" position="84,122" size="522,324" title="Job View">
+       <screen name="JobView" position="84,122" size="522,374" title="Job View">
                <widget source="job_progress" render="Progress" position="130,184" size="362,28" borderWidth="1" />
                <widget source="job_status" render="Label" position="15,246" size="278,62" font="Regular;28" />
                <widget source="job_name" render="Label" position="25,12" size="464,76" font="Regular;28" />
                <widget source="job_progress" render="Progress" position="130,184" size="362,28" borderWidth="1" />
                <widget source="job_status" render="Label" position="15,246" size="278,62" font="Regular;28" />
                <widget source="job_name" render="Label" position="25,12" size="464,76" font="Regular;28" />
@@ -1126,10 +1126,22 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y()))
                <widget source="job_progress" render="Label" position="16,182" size="106,65" font="Regular;28">
                        <convert type="ProgressToText" />
                </widget>
                <widget source="job_progress" render="Label" position="16,182" size="106,65" font="Regular;28">
                        <convert type="ProgressToText" />
                </widget>
-               <widget source="finished" render="Pixmap" pixmap="skin_default/buttons/green.png" position="339,251" size="140,40" alphatest="on" >
+               <widget source="cancelable" render="Pixmap" pixmap="skin_default/buttons/red.png" position="0,330" size="140,40" alphatest="on" >
                        <convert type="ConditionalShowHide" />
                </widget>
                        <convert type="ConditionalShowHide" />
                </widget>
-               <widget source="finished" render="FixedLabel" text="OK" font="Regular;20" halign="center" valign="center" position="339,251" size="140,40" transparent="1" backgroundColor="#1f771f" >
+               <widget source="cancelable" render="FixedLabel" text="Abort" position="0,330" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" >
+                       <convert type="ConditionalShowHide" />
+               </widget>
+               <widget source="finished" render="Pixmap" pixmap="skin_default/buttons/green.png" position="170,330" size="140,40" alphatest="on" >
+                       <convert type="ConditionalShowHide" />
+               </widget>
+               <widget source="finished" render="FixedLabel" text="OK" font="Regular;20" halign="center" valign="center" position="170,330" size="140,40" transparent="1" backgroundColor="#1f771f" >
+                       <convert type="ConditionalShowHide" />
+               </widget>
+               <widget source="backgroundable" render="Pixmap" pixmap="skin_default/buttons/blue.png" position="380,330" size="140,40" alphatest="on" >
+                       <convert type="ConditionalShowHide" />
+               </widget>
+               <widget source="backgroundable" render="FixedLabel" text="Background" font="Regular;20" halign="center" valign="center" position="380,330" size="140,40" transparent="1" backgroundColor="#18188b" >
                        <convert type="ConditionalShowHide" />
                </widget>
        </screen>
                        <convert type="ConditionalShowHide" />
                </widget>
        </screen>
index a87f58d..9a9d9fb 100644 (file)
@@ -244,6 +244,7 @@ class JobManager:
                self.active_jobs = [ ]
                self.failed_jobs = [ ]
                self.job_classes = [ ]
                self.active_jobs = [ ]
                self.failed_jobs = [ ]
                self.job_classes = [ ]
+               self.in_background = False
                self.active_job = None
 
        def AddJob(self, job):
                self.active_job = None
 
        def AddJob(self, job):
@@ -258,8 +259,11 @@ class JobManager:
 
        def jobDone(self, job, task, problems):
                print "job", job, "completed with", problems, "in", task
 
        def jobDone(self, job, task, problems):
                print "job", job, "completed with", problems, "in", task
+               from Tools import Notifications
+               if self.in_background:
+                       from Screens.TaskView import JobView
+                       Notifications.AddNotification(JobView, self.active_job)
                if problems:
                if problems:
-                       from Tools import Notifications
                        from Screens.MessageBox import MessageBox
                        if problems[0].RECOVERABLE:
                                Notifications.AddNotificationWithCallback(self.errorCB, MessageBox, _("Error: %s\nRetry?") % (problems[0].getErrorMessage(task)))
                        from Screens.MessageBox import MessageBox
                        if problems[0].RECOVERABLE:
                                Notifications.AddNotificationWithCallback(self.errorCB, MessageBox, _("Error: %s\nRetry?") % (problems[0].getErrorMessage(task)))
@@ -282,6 +286,12 @@ class JobManager:
                        self.active_job = None
                        self.kick()
 
                        self.active_job = None
                        self.kick()
 
+       def getPendingJobs(self):
+               list = [ ]
+               if self.active_job:
+                       list.append(self.active_job)
+               list += self.active_jobs
+               return list
 # some examples:
 #class PartitionExistsPostcondition:
 #      def __init__(self, device):
 # some examples:
 #class PartitionExistsPostcondition:
 #      def __init__(self, device):
index 71f7c99..c89f79c 100644 (file)
@@ -1,4 +1,4 @@
-from Components.Task import Task, Job, job_manager, DiskspacePrecondition, Condition, ToolExistsPrecondition
+from Components.Task import Task, Job, DiskspacePrecondition, Condition, ToolExistsPrecondition
 from Components.Harddisk import harddiskmanager
 from Screens.MessageBox import MessageBox
 
 from Components.Harddisk import harddiskmanager
 from Screens.MessageBox import MessageBox
 
@@ -663,7 +663,7 @@ class DVDJob(Job):
                DVDAuthorTask(self, diskSpaceNeeded)
                
                nr_titles = len(self.project.titles)
                DVDAuthorTask(self, diskSpaceNeeded)
                
                nr_titles = len(self.project.titles)
-               
+
                if self.menupreview:
                        PreviewTask(self)
                else:
                if self.menupreview:
                        PreviewTask(self)
                else:
@@ -706,18 +706,3 @@ class DVDdataJob(Job):
                        CopyMeta(self, title.inputfile)
                BurnTask(self, ["-follow-links", self.workspace])
                RemoveDVDFolder(self)
                        CopyMeta(self, title.inputfile)
                BurnTask(self, ["-follow-links", self.workspace])
                RemoveDVDFolder(self)
-
-def Burn(session, project):
-       j = DVDJob(project)
-       job_manager.AddJob(j)
-       return j
-
-def PreviewMenu(session, project):
-       j = DVDJob(project, menupreview=True)
-       job_manager.AddJob(j)
-       return j
-
-def BurnDataTS(session, project):
-       j = DVDdataJob(project)
-       job_manager.AddJob(j)
-       return j
index 3a73211..1842a5d 100644 (file)
@@ -1,9 +1,11 @@
-import DVDProject, TitleList, TitleCutter, ProjectSettings, DVDToolbox
+import DVDProject, TitleList, TitleCutter, ProjectSettings, DVDToolbox, Process
 from Screens.Screen import Screen
 from Screens.ChoiceBox import ChoiceBox
 from Screens.InputBox import InputBox
 from Screens.MessageBox import MessageBox
 from Screens.HelpMenu import HelpableScreen
 from Screens.Screen import Screen
 from Screens.ChoiceBox import ChoiceBox
 from Screens.InputBox import InputBox
 from Screens.MessageBox import MessageBox
 from Screens.HelpMenu import HelpableScreen
+from Screens.TaskView import JobView
+from Components.Task import job_manager
 from Components.ActionMap import HelpableActionMap, ActionMap
 from Components.Sources.List import List
 from Components.Sources.StaticText import StaticText
 from Components.ActionMap import HelpableActionMap, ActionMap
 from Components.Sources.List import List
 from Components.Sources.StaticText import StaticText
@@ -185,24 +187,28 @@ class TitleList(Screen, HelpableScreen):
 
        def burnProject(self):
                if self.project.settings.authormode.getValue() == "data_ts":
 
        def burnProject(self):
                if self.project.settings.authormode.getValue() == "data_ts":
-                       import Process
-                       job = Process.BurnDataTS(self.session, self.project)
-                       from Screens.TaskView import JobView
-                       self.session.open(JobView, job)
+                       job = Process.DVDdataJob(self.project)
+                       job_manager.AddJob(job)
+                       job_manager.in_background = False
+                       self.session.openWithCallback(self.JobViewCB, JobView, job)
                else:
                        autochapter = self.project.settings.autochapter.getValue()
                        if autochapter > 0:
                                for title in self.project.titles:
                                        title.produceAutoChapter(autochapter)
                else:
                        autochapter = self.project.settings.autochapter.getValue()
                        if autochapter > 0:
                                for title in self.project.titles:
                                        title.produceAutoChapter(autochapter)
-                       import Process
-                       job = Process.Burn(self.session, self.project)
-                       from Screens.TaskView import JobView
-                       self.session.open(JobView, job)
+                       job = Process.DVDJob(self.project)
+                       job_manager.AddJob(job)
+                       job_manager.in_background = False
+                       self.session.openWithCallback(self.JobViewCB, JobView, job)
 
 
-       def previewMenu(self):
-               import Process
-               job = Process.PreviewMenu(self.session, self.project)
+       def JobViewCB(self, in_background):
+               job_manager.in_background = in_background
 
 
+       def previewMenu(self):
+               job = Process.DVDJob(self.project, menupreview=True)
+               job_manager.in_background = False
+               job_manager.AddJob(job)
+               
        def updateTitleList(self):
                res = [ ]
                totalsize = 0
        def updateTitleList(self):
                res = [ ]
                totalsize = 0
index 9251014..a6b2516 100644 (file)
@@ -20,7 +20,7 @@ from Screens.InfoBarGenerics import InfoBarShowHide, \
        InfoBarSubserviceSelection, InfoBarShowMovies, InfoBarTimeshift,  \
        InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, \
        InfoBarSummarySupport, InfoBarMoviePlayerSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, \
        InfoBarSubserviceSelection, InfoBarShowMovies, InfoBarTimeshift,  \
        InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, \
        InfoBarSummarySupport, InfoBarMoviePlayerSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, \
-       InfoBarSubtitleSupport, InfoBarPiP, InfoBarPlugins, InfoBarSleepTimer, InfoBarServiceErrorPopupSupport
+       InfoBarSubtitleSupport, InfoBarPiP, InfoBarPlugins, InfoBarSleepTimer, InfoBarServiceErrorPopupSupport, InfoBarJobman
 
 profile("LOAD:InitBar_Components")
 from Components.ActionMap import HelpableActionMap
 
 profile("LOAD:InitBar_Components")
 from Components.ActionMap import HelpableActionMap
@@ -36,7 +36,7 @@ class InfoBar(InfoBarBase, InfoBarShowHide,
        HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish,
        InfoBarSubserviceSelection, InfoBarTimeshift, InfoBarSeek,
        InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions,
        HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish,
        InfoBarSubserviceSelection, InfoBarTimeshift, InfoBarSeek,
        InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions,
-       InfoBarPiP, InfoBarPlugins, InfoBarSubtitleSupport, InfoBarSleepTimer, InfoBarServiceErrorPopupSupport,
+       InfoBarPiP, InfoBarPlugins, InfoBarSubtitleSupport, InfoBarSleepTimer, InfoBarServiceErrorPopupSupport, InfoBarJobman,
        Screen):
        
        ALLOW_SUSPEND = True
        Screen):
        
        ALLOW_SUSPEND = True
@@ -57,8 +57,8 @@ class InfoBar(InfoBarBase, InfoBarShowHide,
                                InfoBarInstantRecord, InfoBarAudioSelection, \
                                InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
                                InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, \
                                InfoBarInstantRecord, InfoBarAudioSelection, \
                                InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
                                InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, \
-                               InfoBarTeletextPlugin, InfoBarExtensions, InfoBarPiP, InfoBarSubtitleSupport, InfoBarSleepTimer, \
-                               InfoBarPlugins, InfoBarServiceErrorPopupSupport:
+                               InfoBarTeletextPlugin, InfoBarExtensions, InfoBarPiP, InfoBarSubtitleSupport, InfoBarJobman, \
+                               InfoBarSleepTimer, InfoBarPlugins, InfoBarServiceErrorPopupSupport:
                        x.__init__(self)
 
                self.helpList.append((self["actions"], "InfobarActions", [("showMovies", _("view recordings..."))]))
                        x.__init__(self)
 
                self.helpList.append((self["actions"], "InfobarActions", [("showMovies", _("view recordings..."))]))
index f0130fc..6cd310b 100644 (file)
@@ -1274,6 +1274,30 @@ class InfoBarPlugins:
        def runPlugin(self, plugin):
                plugin(session = self.session, servicelist = self.servicelist)
 
        def runPlugin(self, plugin):
                plugin(session = self.session, servicelist = self.servicelist)
 
+from Components.Task import job_manager
+class InfoBarJobman:
+       def __init__(self):
+               self.addExtension(extension = self.getJobList, type = InfoBarExtensions.EXTENSION_LIST)
+
+       def getJobList(self):
+               list = []
+               for job in job_manager.getPendingJobs():
+                       list.append(((boundFunction(self.getJobName, job), boundFunction(self.showJobView, job), lambda: True), None))
+               return list
+
+       def getJobName(self, job):
+               statustext = {job.NOT_STARTED: _("Waiting"), job.IN_PROGRESS: _("In Progress"), job.FINISHED: _("Finished"), job.FAILED: _("Failed")}[job.status]
+               return "%s: %s (%d%%)" % (statustext, job.name, int(100*job.progress/float(job.end)))
+
+       def showJobView(self, job):
+               from Screens.TaskView import JobView
+               job_manager.in_background = False
+               self.session.openWithCallback(self.JobViewCB, JobView, job)
+       
+       def JobViewCB(self, in_background):
+               from Screens.TaskView import JobView
+               job_manager.in_background = in_background
+
 # depends on InfoBarExtensions
 class InfoBarSleepTimer:
        def __init__(self):
 # depends on InfoBarExtensions
 class InfoBarSleepTimer:
        def __init__(self):
index 790e9bc..48961f6 100644 (file)
@@ -2,22 +2,27 @@ from Screen import Screen
 from InfoBarGenerics import InfoBarNotifications
 
 class JobView(InfoBarNotifications, Screen):
 from InfoBarGenerics import InfoBarNotifications
 
 class JobView(InfoBarNotifications, Screen):
-       def __init__(self, session, job, cancelable = True, close_on_finish = False):
+       def __init__(self, session, job, parent=None, cancelable = True, backgroundable = True, close_on_finish = False):
                from Components.Sources.StaticText import StaticText
                from Components.Sources.Progress import Progress
                from Components.Sources.Boolean import Boolean
                from Components.ActionMap import ActionMap
                from Components.Sources.StaticText import StaticText
                from Components.Sources.Progress import Progress
                from Components.Sources.Boolean import Boolean
                from Components.ActionMap import ActionMap
-               Screen.__init__(self, session)
+               Screen.__init__(self, session, parent)
                InfoBarNotifications.__init__(self)
                InfoBarNotifications.__init__(self)
+               self.parent = parent
                self.job = job
                self.job = job
+               self.job.taskview = self
                self.close_on_finish = close_on_finish
                self.close_on_finish = close_on_finish
-               self.cancelable = cancelable
 
                self["job_name"] = StaticText(job.name)
                self["job_progress"] = Progress()
                self["job_status"] = StaticText()
                self["job_task"] = StaticText()
                self["finished"] = Boolean()
 
                self["job_name"] = StaticText(job.name)
                self["job_progress"] = Progress()
                self["job_status"] = StaticText()
                self["job_task"] = StaticText()
                self["finished"] = Boolean()
+               self["cancelable"] = Boolean(cancelable)
+               self["backgroundable"] = Boolean(backgroundable)
+
+               self["key_blue"] = StaticText(_("Background"))
 
                self.onShow.append(self.windowShow)
                self.onHide.append(self.windowHide)
 
                self.onShow.append(self.windowShow)
                self.onHide.append(self.windowHide)
@@ -25,7 +30,13 @@ class JobView(InfoBarNotifications, Screen):
                self["actions"] = ActionMap(["OkCancelActions"], 
                        {
                                "ok": self.ok,
                self["actions"] = ActionMap(["OkCancelActions"], 
                        {
                                "ok": self.ok,
-                               "cancel": self.abort
+                               "cancel": self.ok
+                       })
+               self["ColorActions"] = ActionMap(["ColorActions"],
+                       {
+                               "red": self.abort,
+                               "green": self.ok,
+                               "blue": self.background,
                        })
 
        def windowShow(self):
                        })
 
        def windowShow(self):
@@ -40,7 +51,7 @@ class JobView(InfoBarNotifications, Screen):
                j = self.job
                self["job_progress"].range = j.end
                self["job_progress"].value = j.progress
                j = self.job
                self["job_progress"].range = j.end
                self["job_progress"].value = j.progress
-               print "JobView::state_changed:", j.end, j.progress
+               #print "JobView::state_changed:", j.end, j.progress
                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
                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
@@ -49,15 +60,24 @@ class JobView(InfoBarNotifications, Screen):
                if j.status in [j.FINISHED, j.FAILED]:
                        if self.close_on_finish:
                                self.close()
                if j.status in [j.FINISHED, j.FAILED]:
                        if self.close_on_finish:
                                self.close()
-                       else:
+                       self["backgroundable"].boolean = False
+                       if j.status == j.FINISHED:
                                self["finished"].boolean = True
                                self["finished"].boolean = True
+                               self["cancelable"].boolean = False
+                       elif j.status == j.FAILED:
+                               self["cancelable"].boolean = True
+
+       def background(self):
+               print "[background]"
+               if self["backgroundable"].boolean == True:
+                       self.close(True)
 
        def ok(self):
                if self.job.status in [self.job.FINISHED, self.job.FAILED]:
 
        def ok(self):
                if self.job.status in [self.job.FINISHED, self.job.FAILED]:
-                       self.close()
+                       self.close(False)
 
        def abort(self):
                if self.job.status in [self.job.FINISHED, self.job.FAILED]:
 
        def abort(self):
                if self.job.status in [self.job.FINISHED, self.job.FAILED]:
-                       self.close()
-               if self.cancelable:
+                       self.close(False)
+               if self["cancelable"].boolean == True:
                        self.job.cancel()
                        self.job.cancel()
index b4a4f03..c44ea88 100644 (file)
--- a/po/de.po
+++ b/po/de.po
@@ -498,7 +498,7 @@ msgid "Brightness"
 msgstr "Helligkeit"
 
 msgid "Burn DVD"
 msgstr "Helligkeit"
 
 msgid "Burn DVD"
-msgstr "brenne DVD"
+msgstr "Brenne DVD"
 
 msgid "Burn to DVD..."
 msgstr "Auf DVD brennen..."
 
 msgid "Burn to DVD..."
 msgstr "Auf DVD brennen..."