1 import DVDProject, TitleList, TitleCutter, TitleProperties, ProjectSettings, DVDToolbox, Process
2 from Screens.Screen import Screen
3 from Screens.ChoiceBox import ChoiceBox
4 from Screens.InputBox import InputBox
5 from Screens.MessageBox import MessageBox
6 from Screens.HelpMenu import HelpableScreen
7 from Screens.TaskView import JobView
8 from Components.Task import job_manager
9 from Components.ActionMap import HelpableActionMap, ActionMap
10 from Components.Sources.List import List
11 from Components.Sources.StaticText import StaticText
12 from Components.Sources.Progress import Progress
13 from Components.MultiContent import MultiContentEntryText
14 from enigma import gFont, RT_HALIGN_LEFT, RT_HALIGN_RIGHT
15 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
17 class TitleList(Screen, HelpableScreen):
19 <screen name="TitleList" position="center,center" size="560,445" title="DVD Tool" >
20 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
21 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
22 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
23 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
24 <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
25 <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
26 <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
27 <widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
28 <widget source="title_label" render="Label" position="10,48" size="540,38" font="Regular;18" transparent="1" />
29 <widget source="error_label" render="Label" position="10,48" size="540,395" zPosition="3" font="Regular;20" transparent="1" />
30 <widget source="titles" render="Listbox" scrollbarMode="showOnDemand" position="10,86" size="540,312" zPosition="3" transparent="1" >
31 <convert type="TemplatedMultiContent">
33 MultiContentEntryText(pos = (0, 0), size = (420, 20), font = 0, flags = RT_HALIGN_LEFT, text = 1), # index 1 Title,
34 MultiContentEntryText(pos = (0, 20), size = (328, 17), font = 1, flags = RT_HALIGN_LEFT, text = 2), # index 2 description,
35 MultiContentEntryText(pos = (420, 6), size = (120, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 3), # index 3 begin time,
36 MultiContentEntryText(pos = (328, 20), size = (154, 17), font = 1, flags = RT_HALIGN_RIGHT, text = 4), # index 4 channel,
37 MultiContentEntryText(pos = (482, 20), size = (58, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 5), # index 4 channel,
39 "fonts": [gFont("Regular", 20), gFont("Regular", 14)],
44 <widget source="space_bar" render="Progress" position="10,410" size="540,26" borderWidth="1" backgroundColor="#254f7497" />
45 <widget source="space_label" render="Label" position="40,414" size="480,22" zPosition="2" font="Regular;18" halign="center" transparent="1" foregroundColor="#000000" />
48 def __init__(self, session, project = None):
49 Screen.__init__(self, session)
50 HelpableScreen.__init__(self)
52 self["titleactions"] = HelpableActionMap(self, "DVDTitleList",
54 "addTitle": (self.addTitle, _("Add a new title"), _("Add title")),
55 "titleProperties": (self.titleProperties, _("Properties of current title"), _("Title properties")),
56 "removeCurrentTitle": (self.removeCurrentTitle, _("Remove currently selected title"), _("Remove title")),
57 "settings": (self.settings, _("Collection settings"), _("Settings")),
58 "burnProject": (self.askBurnProject, _("Burn DVD"), _("Burn DVD")),
61 self["MovieSelectionActions"] = HelpableActionMap(self, "MovieSelectionActions",
63 "contextMenu": (self.showMenu, _("menu")),
66 self["actions"] = ActionMap(["OkCancelActions"],
71 self["key_red"] = StaticText()
72 self["key_green"] = StaticText(_("Add title"))
73 self["key_yellow"] = StaticText()
74 self["key_blue"] = StaticText(_("Settings"))
76 self["title_label"] = StaticText()
77 self["error_label"] = StaticText()
78 self["space_label"] = StaticText()
79 self["space_bar"] = Progress()
81 if project is not None:
82 self.project = project
86 self["titles"] = List([])
87 self.updateTitleList()
88 self.previous_size = 0
89 self.onLayoutFinish.append(self.layoutFinished)
91 def layoutFinished(self):
92 self.setTitle(_("DVD Titlelist"))
94 def checkBackgroundJobs(self):
95 for job in job_manager.getPendingJobs():
96 print "type(job):", type(job)
97 print "Process.DVDJob:", Process.DVDJob
98 if type(job) == Process.DVDJob:
99 self.backgroundJob = job
101 self.backgroundJob = None
105 self.checkBackgroundJobs()
106 if self.backgroundJob:
107 j = self.backgroundJob
108 menu.append(("%s: %s (%d%%)" % (j.getStatustext(), j.name, int(100*j.progress/float(j.end))), self.showBackgroundJob))
109 menu.append((_("DVD media toolbox"), self.toolbox))
110 menu.append((_("Preview menu"), self.previewMenu))
111 if self.project.settings.output.getValue() == "dvd":
112 if len(self["titles"].list):
113 menu.append((_("Burn DVD"), self.burnProject))
114 elif self.project.settings.output.getValue() == "iso":
115 menu.append((_("Create DVD-ISO"), self.burnProject))
116 menu.append((_("Burn existing image to DVD"), self.selectImage))
117 menu.append((_("Edit chapters of current title"), self.editTitle))
118 menu.append((_("Reset and renumerate title names"), self.resetTitles))
119 menu.append((_("Exit"), self.leave))
120 self.session.openWithCallback(self.menuCallback, ChoiceBox, title="", list=menu)
122 def menuCallback(self, choice):
126 def showBackgroundJob(self):
127 job_manager.in_background = False
128 self.session.openWithCallback(self.JobViewCB, JobView, self.backgroundJob)
129 self.backgroundJob = None
131 def titleProperties(self):
132 if self.getCurrentTitle():
133 self.session.openWithCallback(self.updateTitleList, TitleProperties.TitleProperties, self, self.project, self["titles"].getIndex())
135 def selectImage(self):
136 self.session.openWithCallback(self.burnISO, ProjectSettings.FileBrowser, "image", self.project.settings)
138 def newProject(self):
139 self.project = DVDProject.DVDProject()
140 if self.loadTemplate():
141 self.project.session = self.session
145 from Screens.MovieSelection import MovieSelection
146 from Components.ActionMap import HelpableActionMap
147 class DVDMovieSelection(MovieSelection):
148 skin = """<screen name="DVDMovieSelection" position="center,center" size="560,445" title="Select a movie">
149 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
150 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
151 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
152 <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
153 <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
154 <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
155 <widget name="waitingtext" position="0,45" size="560,395" zPosition="4" font="Regular;22" halign="center" valign="center" />
156 <widget name="list" position="5,40" size="550,375" zPosition="2" scrollbarMode="showOnDemand" />
157 <widget name="DescriptionBorder" pixmap="skin_default/border_eventinfo.png" position="0,316" zPosition="1" size="560,103" transparent="1" alphatest="on" />
158 <widget source="Service" render="Label" position="5,318" zPosition="1" size="480,35" font="Regular;17" foregroundColor="#cccccc">
159 <convert type="MovieInfo">ShortDescription</convert>
161 <widget source="Service" render="Label" position="495,318" zPosition="1" size="60,22" font="Regular;17" halign="right">
162 <convert type="ServiceTime">Duration</convert>
163 <convert type="ClockToText">AsLength</convert>
165 <widget source="Service" render="Label" position="380,337" zPosition="2" size="175,22" font="Regular;17" halign="right">
166 <convert type="MovieInfo">RecordServiceName</convert>
168 <widget source="Service" render="Label" position="5,357" zPosition="1" size="550,58" font="Regular;19">
169 <convert type="EventName">ExtendedDescription</convert>
171 <widget name="freeDiskSpace" position="10,425" size="540,20" font="Regular;19" valign="center" halign="right" />
173 def __init__(self, session):
174 MovieSelection.__init__(self, session)
175 self["key_red"] = StaticText(_("Close"))
176 self["key_green"] = StaticText(_("Add"))
177 self["key_yellow"] = StaticText(_("Edit title"))
178 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
180 "red": (self.close, _("Close title selection")),
181 "green": (self.insertWithoutEdit, ("insert without cutlist editor")),
182 "yellow": (self.movieSelected, _("Add a new title"))
184 def updateTags(self):
187 print "context menu forbidden inside DVDBurn to prevent calling multiple instances"
188 def insertWithoutEdit(self):
189 current = self.getCurrent()
190 if current is not None:
193 def movieSelected(self):
194 current = self.getCurrent()
195 if current is not None:
198 self.session.openWithCallback(self.selectedSource, DVDMovieSelection)
200 def selectedSource(self, source):
203 t = self.project.addService(source)
206 except AttributeError:
208 self.editTitle(t, editor)
210 def removeCurrentTitle(self):
211 title = self.getCurrentTitle()
212 self.removeTitle(title)
214 def removeTitle(self, title):
215 if title is not None:
216 self.project.titles.remove(title)
217 self.updateTitleList()
220 self.session.open(DVDToolbox.DVDToolbox)
223 self.session.openWithCallback(self.settingsCB, ProjectSettings.ProjectSettings, self.project)
225 def settingsCB(self, update=True):
228 self["title_label"].text = _("Table of content for collection") + " \"" + self.project.settings.name.getValue() + "\":"
230 def loadTemplate(self):
231 filename = resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/DreamboxDVD.ddvdp.xml"
232 if self.project.load(filename):
233 self["error_label"].setText("")
236 self["error_label"].setText(self.project.error)
239 def askBurnProject(self):
240 if len(self["titles"].list):
241 self.session.openWithCallback(self.burnProject,MessageBox,text = _("Do you want to burn this collection to DVD medium?"), type = MessageBox.TYPE_YESNO)
243 def burnProject(self, answer=True):
246 if self.project.settings.authormode.getValue() == "data_ts":
247 job = Process.DVDdataJob(self.project)
248 job_manager.AddJob(job)
249 job_manager.in_background = False
250 self.session.openWithCallback(self.JobViewCB, JobView, job)
252 job = Process.DVDJob(self.project)
253 job_manager.AddJob(job)
254 job_manager.in_background = False
255 self.session.openWithCallback(self.JobViewCB, JobView, job)
257 def burnISO(self, path, scope, configRef):
259 job = Process.DVDisoJob(self.project, path)
260 job_manager.AddJob(job)
261 job_manager.in_background = False
262 self.session.openWithCallback(self.JobViewCB, JobView, job)
264 def JobViewCB(self, in_background):
265 job_manager.in_background = in_background
267 def previewMenu(self):
268 job = Process.DVDJob(self.project, menupreview=True)
269 job_manager.in_background = False
270 job_manager.AddJob(job)
272 def updateTitleList(self):
274 for title in self.project.titles:
275 list.append((title, title.properties.menutitle.getValue(), title.properties.menusubtitle.getValue(), title.DVBchannel, title.formatDVDmenuText("$D.$M.$Y, $T", 0), title.formatDVDmenuText("$l", 0)))
276 self["titles"].list = list
279 self["key_red"].text = _("Remove title")
280 self["key_yellow"].text = _("Title properties")
282 self["key_red"].text = ""
283 self["key_yellow"].text = ""
285 def updateSize(self):
286 size = self.project.size/(1024*1024)
287 MAX_DL = self.project.MAX_DL-100
288 MAX_SL = self.project.MAX_SL-100
289 print "updateSize:", size, "MAX_DL:", MAX_DL, "MAX_SL:", MAX_SL
291 percent = 100 * size / float(MAX_DL)
292 self["space_label"].text = "%d MB - " % size + _("exceeds dual layer medium!") + " (%.2f%% " % (100-percent) + _("free") + ")"
293 self["space_bar"].value = int(percent)
294 if self.previous_size < MAX_DL:
295 self.session.open(MessageBox,text = _("exceeds dual layer medium!"), type = MessageBox.TYPE_ERROR)
297 percent = 100 * size / float(MAX_DL)
298 self["space_label"].text = "%d MB " % size + _("of a DUAL layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")"
299 self["space_bar"].value = int(percent)
300 if self.previous_size < MAX_SL:
301 self.session.open(MessageBox,text = _("Your collection exceeds the size of a single layer medium, you will need a blank dual layer DVD!"), type = MessageBox.TYPE_INFO)
303 percent = 100 * size / float(MAX_SL)
304 self["space_label"].text = "%d MB " % size + _("of a SINGLE layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")"
305 self["space_bar"].value = int(percent)
306 self.previous_size = size
308 def getCurrentTitle(self):
309 t = self["titles"].getCurrent()
312 def editTitle(self, title = None, editor = True):
313 t = title or self.getCurrentTitle()
315 self.current_edit_title = t
317 self.session.openWithCallback(self.titleEditDone, TitleCutter.TitleCutter, t)
319 self.session.openWithCallback(self.titleEditDone, TitleCutter.CutlistReader, t)
321 def titleEditDone(self, cutlist):
322 t = self.current_edit_title
323 t.initDVDmenuText(self.project,len(self.project.titles))
325 t.produceFinalCuesheet()
327 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)
329 self.updateTitleList()
331 def resetTitles(self):
333 for title in self.project.titles:
335 title.initDVDmenuText(self.project,count)
336 self.updateTitleList()
338 def DVDformatCB(self, answer):
339 t = self.current_edit_title
341 self.project.settings.authormode.setValue("data_ts")
342 self.updateTitleList()