X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/2977b2dfa5d96055c5abc10ec31adb4dbf8f9e2a..7211bd40026fb8b00be038a59abcbfa29569b3ed:/lib/python/Plugins/Extensions/DVDBurn/TitleList.py diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py old mode 100644 new mode 100755 index 19380af4..2cbeb633 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py @@ -1,4 +1,4 @@ -import DVDProject, TitleList, TitleCutter, ProjectSettings, DVDToolbox, Process +import DVDProject, TitleList, TitleCutter, TitleProperties, ProjectSettings, DVDToolbox, Process from Screens.Screen import Screen from Screens.ChoiceBox import ChoiceBox from Screens.InputBox import InputBox @@ -10,28 +10,47 @@ from Components.ActionMap import HelpableActionMap, ActionMap from Components.Sources.List import List from Components.Sources.StaticText import StaticText from Components.Sources.Progress import Progress -from Components.Label import Label -from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT +from Components.MultiContent import MultiContentEntryText +from Components.Label import MultiColorLabel +from enigma import gFont, RT_HALIGN_LEFT, RT_HALIGN_RIGHT from Tools.Directories import resolveFilename, SCOPE_PLUGINS class TitleList(Screen, HelpableScreen): skin = """ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + {"template": [ + MultiContentEntryText(pos = (0, 0), size = (360, 20), font = 0, flags = RT_HALIGN_LEFT, text = 1), # index 1 Title, + MultiContentEntryText(pos = (0, 20), size = (360, 17), font = 1, flags = RT_HALIGN_LEFT, text = 2), # index 2 description, + MultiContentEntryText(pos = (366, 6), size = (152, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 3), # index 3 channel, + MultiContentEntryText(pos = (366, 20), size = (102, 17), font = 1, flags = RT_HALIGN_RIGHT, text = 4), # index 4 begin time, + MultiContentEntryText(pos = (470, 20), size = (48, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 5), # index 5 duration, + ], + "fonts": [gFont("Regular", 20), gFont("Regular", 14)], + "itemHeight": 37 + } + + + + + + + + + + + """ def __init__(self, session, project = None): @@ -41,10 +60,10 @@ class TitleList(Screen, HelpableScreen): self["titleactions"] = HelpableActionMap(self, "DVDTitleList", { "addTitle": (self.addTitle, _("Add a new title"), _("Add title")), - "editTitle": (self.editTitle, _("Edit chapters of current title"), _("Edit title")), + "titleProperties": (self.titleProperties, _("Properties of current title"), _("Title properties")), "removeCurrentTitle": (self.removeCurrentTitle, _("Remove currently selected title"), _("Remove title")), "settings": (self.settings, _("Collection settings"), _("Settings")), - "burnProject": (self.burnProject, _("Burn DVD"), _("Burn DVD")), + "burnProject": (self.askBurnProject, _("Burn DVD"), _("Burn DVD")), }) self["MovieSelectionActions"] = HelpableActionMap(self, "MovieSelectionActions", @@ -57,61 +76,75 @@ class TitleList(Screen, HelpableScreen): "cancel": self.leave }) - self["key_red"] = StaticText(_("Remove title")) + self["key_red"] = StaticText() self["key_green"] = StaticText(_("Add title")) - self["key_yellow"] = StaticText(_("Edit title")) + self["key_yellow"] = StaticText() self["key_blue"] = StaticText(_("Settings")) self["title_label"] = StaticText() - self["error_label"] = Label("") - self["space_label"] = StaticText() - self["space_bar"] = Progress() + self["error_label"] = StaticText() + self["space_label_single"] = StaticText() + self["space_label_dual"] = StaticText() + self["hint"] = StaticText(_("Advanced Options")) + self["medium_label"] = MultiColorLabel() + self["space_bar_single"] = Progress() + self["space_bar_dual"] = Progress() + self["titles"] = List([]) + self.previous_size = 0 if project is not None: self.project = project else: self.newProject() + self.onLayoutFinish.append(self.layoutFinished) + + def layoutFinished(self): + self.setTitle(_("DVD Titlelist")) + + def checkBackgroundJobs(self): + for job in job_manager.getPendingJobs(): + print "type(job):", type(job) + print "Process.DVDJob:", Process.DVDJob + if type(job) == Process.DVDJob: + self.backgroundJob = job + return + self.backgroundJob = None - self["titles"] = List(list = [ ], enableWrapAround = True, item_height=30, fonts = [gFont("Regular", 20)]) - self.updateTitleList() - def showMenu(self): menu = [] + self.checkBackgroundJobs() + if self.backgroundJob: + j = self.backgroundJob + menu.append(("%s: %s (%d%%)" % (j.getStatustext(), j.name, int(100*j.progress/float(j.end))), self.showBackgroundJob)) + menu.append((_("DVD media toolbox"), self.toolbox)) if self.project.settings.output.getValue() == "dvd": - menu.append((_("Burn DVD"), "burn")); + if len(self["titles"].list): + menu.append((_("Burn DVD"), self.burnProject)) elif self.project.settings.output.getValue() == "iso": - menu.append((_("Create DVD-ISO"), "burn")); - menu.append((_("Preview menu"), "previewMenu")); - menu.append((_("DVD media toolbox"), "toolbox")); - menu.append((_("Collection settings"), "settings")); - menu.append((_("Add a new title"), "addtitle")); - menu.append((_("Remove title"), "removetitle")); - menu.append((_("Edit chapters of current title"), "edittitle")); - menu.append((_("Burn existing image to DVD"), "burniso")); - menu.append((_("Exit"), "exit")); + menu.append((_("Create DVD-ISO"), self.burnProject)) + menu.append((_("Burn existing image to DVD"), self.selectImage)) + if len(self["titles"].list): + menu.append((_("Preview menu"), self.previewMenu)) + menu.append((_("Edit chapters of current title"), self.editTitle)) + menu.append((_("Reset and renumerate title names"), self.resetTitles)) + menu.append((_("Exit"), self.leave)) self.session.openWithCallback(self.menuCallback, ChoiceBox, title="", list=menu) def menuCallback(self, choice): - if choice is None: - return - if choice[1] == "removetitle": - self.removeCurrentTitle() - elif choice[1] == "addtitle": - self.addTitle() - elif choice[1] == "edittitle": - self.editTitle() - elif choice[1] == "toolbox": - self.toolbox() - elif choice[1] == "settings": - self.settings() - elif choice[1] == "previewMenu": - self.previewMenu() - elif choice[1] == "burn": - self.burnProject() - elif choice[1] == "burniso": - self.session.openWithCallback(self.burnISO, ProjectSettings.FileBrowser, "image", self.project.settings) - elif choice[1] == "exit": - self.leave() + if choice: + choice[1]() + + def showBackgroundJob(self): + job_manager.in_background = False + self.session.openWithCallback(self.JobViewCB, JobView, self.backgroundJob) + self.backgroundJob = None + + def titleProperties(self): + if self.getCurrentTitle(): + self.session.openWithCallback(self.updateTitleList, TitleProperties.TitleProperties, self, self.project, self["titles"].getIndex()) + + def selectImage(self): + self.session.openWithCallback(self.burnISO, ProjectSettings.FileBrowser, "image", self.project.settings) def newProject(self): self.project = DVDProject.DVDProject() @@ -121,18 +154,43 @@ class TitleList(Screen, HelpableScreen): def addTitle(self): from Screens.MovieSelection import MovieSelection - from Components.Button import Button from Components.ActionMap import HelpableActionMap - class MovieSelectionNoMenu(MovieSelection): + class DVDMovieSelection(MovieSelection): + skin = """ + + + + + + + + + + + ShortDescription + + + Duration + AsLength + + + RecordServiceName + + + ExtendedDescription + + + """ def __init__(self, session): MovieSelection.__init__(self, session) - self.skinName = "MovieSelection" - self["key_red"] = Button(_("Edit title")) - self["key_green"] = Button(_("Add")) + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText(_("Add")) + self["key_yellow"] = StaticText(_("Edit title")) self["ColorActions"] = HelpableActionMap(self, "ColorActions", { - "red": (self.movieSelected, _("Add a new title")), - "green": (self.insertWithoutEdit, ("insert without cutlist editor")) + "red": (self.close, _("Close title selection")), + "green": (self.insertWithoutEdit, ("insert without cutlist editor")), + "yellow": (self.movieSelected, _("Add a new title")) }) def updateTags(self): pass @@ -148,11 +206,14 @@ class TitleList(Screen, HelpableScreen): if current is not None: current.edit = True self.close(current) - self.session.openWithCallback(self.selectedSource, MovieSelectionNoMenu) + self.session.openWithCallback(self.selectedSource, DVDMovieSelection) - def selectedSource(self, source): + def selectedSource(self, source = None): if source is None: return None + if not source.getPath().endswith(".ts"): + self.session.open(MessageBox,text = _("You can only burn Dreambox recordings!"), type = MessageBox.TYPE_ERROR) + return None t = self.project.addService(source) try: editor = source.edit @@ -178,35 +239,36 @@ class TitleList(Screen, HelpableScreen): def settingsCB(self, update=True): if not update: return - self["title_label"].text = _("Table of content for collection") + " \"" + self.project.settings.name.getValue() + "\":" + self.updateTitleList() def loadTemplate(self): - filename = resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/DreamboxDVDtemplate.ddvdp.xml" - if self.project.loadProject(filename): - self["error_label"].hide() + filename = resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/DreamboxDVD.ddvdp.xml" + if self.project.load(filename): + self["error_label"].setText("") return True else: - self["error_label"].text = self.project.error - self["error_label"].show() + self["error_label"].setText(self.project.error) return False - def burnProject(self): + def askBurnProject(self): + if len(self["titles"].list): + self.session.openWithCallback(self.burnProject,MessageBox,text = _("Do you want to burn this collection to DVD medium?"), type = MessageBox.TYPE_YESNO) + + def burnProject(self, answer=True): + if not answer: + return if self.project.settings.authormode.getValue() == "data_ts": 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) job = Process.DVDJob(self.project) job_manager.AddJob(job) job_manager.in_background = False self.session.openWithCallback(self.JobViewCB, JobView, job) - def burnISO(self, path, scope): + def burnISO(self, path, scope, configRef): if path: job = Process.DVDisoJob(self.project, path) job_manager.AddJob(job) @@ -220,33 +282,56 @@ class TitleList(Screen, HelpableScreen): job = Process.DVDJob(self.project, menupreview=True) job_manager.in_background = False job_manager.AddJob(job) - + def updateTitleList(self): - res = [ ] - totalsize = 0 + list = [ ] for title in self.project.titles: - a = [ title, (eListboxPythonMultiContent.TYPE_TEXT, 0, 10, 500, 50, 0, RT_HALIGN_LEFT, title.name) ] - res.append(a) - totalsize += title.estimatedDiskspace - self["titles"].list = res - self.updateSize(totalsize) - - def updateSize(self, totalsize): - size = int((totalsize/1024)/1024) - max_SL = 4370 - max_DL = 7950 - if size > max_DL: - percent = 100 * size / float(max_DL) - self["space_label"].text = "%d MB - " % size + _("exceeds dual layer medium!") + " (%.2f%% " % (100-percent) + _("free") + ")" - self["space_bar"].value = int(percent) - elif size > max_SL: - percent = 100 * size / float(max_DL) - self["space_label"].text = "%d MB " % size + _("of a DUAL layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")" - self["space_bar"].value = int(percent) - elif size < max_SL: - percent = 100 * size / float(max_SL) - self["space_label"].text = "%d MB " % size + _("of a SINGLE layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")" - self["space_bar"].value = int(percent) + list.append((title, title.properties.menutitle.getValue(), title.properties.menusubtitle.getValue(), title.DVBchannel, title.formatDVDmenuText("$D.$M.$Y, $T", 0), title.formatDVDmenuText("$l", 0))) + self["titles"].list = list + self.updateSize() + if len(list): + self["key_red"].text = _("Remove title") + self["key_yellow"].text = _("Title properties") + self["title_label"].text = _("Table of content for collection") + " \"" + self.project.settings.name.getValue() + "\":" + else: + self["key_red"].text = "" + self["key_yellow"].text = "" + self["title_label"].text = _("Please add titles to the compilation.") + + def updateSize(self): + size = self.project.size/(1024*1024) + MAX_DL = self.project.MAX_DL-100 + MAX_SL = self.project.MAX_SL-100 + print "updateSize:", size, "MAX_DL:", MAX_DL, "MAX_SL:", MAX_SL + if size > MAX_DL: + percent = 100 * size / float(MAX_DL) + self["space_label_dual"].text = "%d MB (%.2f%%)" % (size, percent) + self["space_bar_dual"].value = int(percent) + self["space_bar_single"].value = 100 + self["space_label_single"].text = "" + self["medium_label"].setText(_("Exceeds dual layer medium!")) + self["medium_label"].setForegroundColorNum(2) + if self.previous_size < MAX_DL: + self.session.open(MessageBox,text = _("Exceeds dual layer medium!"), type = MessageBox.TYPE_ERROR) + elif size > MAX_SL: + percent = 100 * size / float(MAX_DL) + self["space_label_dual"].text = "%d MB (%.2f%%)" % (size, percent) + self["space_bar_dual"].value = int(percent) + self["space_bar_single"].value = 100 + self["space_label_single"].text = "" + self["medium_label"].setText(_("Required medium type:") + " " + _("DUAL LAYER DVD") + ", %d MB " % (MAX_DL - size) + _("free")) + self["medium_label"].setForegroundColorNum(1) + if self.previous_size < MAX_SL: + self.session.open(MessageBox, text = _("Your collection exceeds the size of a single layer medium, you will need a blank dual layer DVD!"), timeout = 10, type = MessageBox.TYPE_INFO) + elif size < MAX_SL: + percent = 100 * size / float(MAX_SL) + self["space_label_single"].text = "%d MB (%.2f%%)" % (size, percent) + self["space_bar_single"].value = int(percent) + self["space_bar_dual"].value = 0 + self["space_label_dual"].text = "" + self["medium_label"].setText(_("Required medium type:") + " " + _("SINGLE LAYER DVD") + ", %d MB " % (MAX_SL - size) + _("free")) + self["medium_label"].setForegroundColorNum(0) + self.previous_size = size def getCurrentTitle(self): t = self["titles"].getCurrent() @@ -263,13 +348,19 @@ class TitleList(Screen, HelpableScreen): def titleEditDone(self, cutlist): t = self.current_edit_title - t.cuesheet = cutlist - t.produceFinalCuesheet() - if t.sVideoType != 0: + t.titleEditDone(cutlist) + if t.VideoType != 0: self.session.openWithCallback(self.DVDformatCB,MessageBox,text = _("The DVD standard doesn't support H.264 (HDTV) video streams. Do you want to create a Dreambox format data DVD (which will not play in stand-alone DVD players) instead?"), type = MessageBox.TYPE_YESNO) else: self.updateTitleList() + def resetTitles(self): + count = 0 + for title in self.project.titles: + count += 1 + title.initDVDmenuText(count) + self.updateTitleList() + def DVDformatCB(self, answer): t = self.current_edit_title if answer == True: @@ -278,5 +369,13 @@ class TitleList(Screen, HelpableScreen): else: self.removeTitle(t) - def leave(self): - self.close() + def leave(self, close = False): + if not len(self["titles"].list) or close: + self.close() + else: + self.session.openWithCallback(self.exitCB, MessageBox,text = _("Your current collection will get lost!") + "\n" + _("Do you really want to exit?"), type = MessageBox.TYPE_YESNO) + + def exitCB(self, answer): + print "exitCB", answer + if answer is not None and answer: + self.close() \ No newline at end of file