1 import DVDProject, TitleList, TitleCutter
3 from Screens.Screen import Screen
4 from Screens.ChoiceBox import ChoiceBox
5 from Screens.InputBox import InputBox
6 from Screens.MessageBox import MessageBox
7 from Screens.HelpMenu import HelpableScreen
8 from Components.ActionMap import HelpableActionMap, ActionMap
9 from Components.Sources.List import List
10 from Components.Sources.StaticText import StaticText
11 from Components.Sources.Progress import Progress
12 from Components.FileList import FileList
13 from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT
14 from Tools.Directories import resolveFilename, SCOPE_PLAYLIST
16 class WaitBox(MessageBox):
17 def __init__(self, session, callback):
18 MessageBox.__init__(self, session, text=_("please wait, loading picture..."), type = MessageBox.TYPE_INFO)
19 self.skinName = "MessageBox"
21 self.onShown.append(self.runCB)
27 from enigma import eTimer
28 self.delayTimer = eTimer()
29 self.delayTimer.callback.append(self.CB)
30 self.delayTimer.start(10,1)
32 class FileBrowser(Screen, HelpableScreen):
34 <screen name="FileBrowser" position="100,100" size="520,376" title="DVD File Browser" >
35 <widget name="filelist" position="0,0" size="520,376" scrollbarMode="showOnDemand" />
37 def __init__(self, session, currDir = None, projectBrowser = False):
38 Screen.__init__(self, session)
39 HelpableScreen.__init__(self)
40 self.projectBrowser = projectBrowser
45 self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(ddvdp\.xml)")
47 self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp)")
48 self["filelist"] = self.filelist
50 self["FilelistActions"] = ActionMap(["OkCancelActions"],
57 if self.filelist.canDescent():
58 self.filelist.descent()
60 ret = self["filelist"].getCurrentDirectory() + self["filelist"].getFilename()
61 self.close(ret,self.projectBrowser)
67 class TitleList(Screen):
69 <screen position="90,83" size="560,445" title="DVD Tool" >
70 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
71 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
72 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
73 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
74 <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" />
75 <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" />
76 <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" />
77 <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" />
78 <widget source="title_label" render="Label" position="6,48" size="540,38" font="Regular;18" />
79 <widget source="titles" render="Listbox" scrollbarMode="showOnDemand" position="10,86" size="540,312">
80 <convert type="StaticMultiList" />
82 <widget source="space_bar" render="Progress" position="10,410" size="540,26" borderWidth="1" backgroundColor="#254f7497" />
83 <widget source="space_label" render="Label" position="40,414" size="480,22" zPosition="2" font="Regular;18" halign="center" transparent="1" foregroundColor="#000000" />
86 def __init__(self, session, project = None):
87 Screen.__init__(self, session)
89 self["titleactions"] = HelpableActionMap(self, "DVDTitleList",
91 "addTitle": (self.addTitle, _("Add a new title"), _("Add title")),
92 "editTitle": (self.editTitle, _("Edit chapters of current title"), _("Edit title")),
93 "removeCurrentTitle": (self.removeCurrentTitle, _("Remove currently selected title"), _("Remove title")),
94 "saveProject": (self.saveProject, _("Save current collection to disk"), _("Save")),
95 "burnProject": (self.burnProject, _("Burn DVD"), _("Burn DVD")),
98 self["MovieSelectionActions"] = HelpableActionMap(self, "MovieSelectionActions",
100 "contextMenu": (self.showMenu, _("menu")),
103 self["key_red"] = StaticText(_("Add title"))
104 self["key_green"] = StaticText(_("Edit title"))
105 self["key_yellow"] = StaticText(_("Remove title"))
106 self["key_blue"] = StaticText(_("Save"))
108 self["title_label"] = StaticText()
109 self["space_label"] = StaticText()
110 self["space_bar"] = Progress()
112 self["actions"] = ActionMap(["OkCancelActions"],
117 #Action("addTitle", self.addTitle)
119 if project is not None:
120 self.project = project
124 self["titles"] = List(list = [ ], enableWrapAround = True, item_height=30, fonts = [gFont("Regular", 20)])
125 self.updateTitleList()
126 self.updateCollectionName()
128 #self["addTitle"] = ActionButton("titleactions", "addTitle")
129 #self["editTitle"] = ActionButton("titleactions", "editTitle")
130 #self["removeCurrentTitle"] = ActionButton("titleactions", "removeCurrentTitle")
131 #self["saveProject"] = ActionButton("titleactions", "saveProject")
132 #self["burnProject"] = ActionButton("titleactions", "burnProject")
136 menu.append((_("Add a new title"), "addtitle"));
137 menu.append((_("Remove title"), "removetitle"));
138 menu.append((_("Edit chapters of current title"), "edittitle"));
139 menu.append((_("Set collection name"), "setname"));
140 menu.append((_("Set menu background"), "setbackground"));
141 menu.append((_("Save current collection to disk"), "save"));
142 menu.append((_("Load saved collection from disk"), "load"));
143 menu.append((_("Preview menu"), "previewMenu"));
144 menu.append((_("Burn DVD"), "burn"));
145 self.session.openWithCallback(self.menuCallback, ChoiceBox, title="", list=menu)
147 def menuCallback(self, choice):
151 if choice[1] == "removetitle":
152 self.removeCurrentTitle()
153 elif choice[1] == "addtitle":
155 elif choice[1] == "edittitle":
157 elif choice[1] == "setname":
159 elif choice[1] == "setbackground":
160 self.showFileBrowser(False)
161 elif choice[1] == "save":
163 elif choice[1] == "load":
164 self.showFileBrowser(True)
165 elif choice[1] == "previewMenu":
167 elif choice[1] == "burn":
171 self.session.openWithCallback(self.setNameCallback, InputBox, title=_("Set collection name"), text=self.project.name, maxSize=False, visible_width = 56)
173 def setNameCallback(self, name):
175 self.project.name = name
176 self.updateCollectionName()
178 def newProject(self):
179 self.project = DVDProject.DVDProject()
180 if self.loadProject():
181 self.project.session = self.session
182 self.updateCollectionName()
184 def updateCollectionName(self):
185 self["title_label"].text = _("Table of content for collection") + " \"" + self.project.name + "\":"
188 from Screens.MovieSelection import MovieSelection
189 class MovieSelectionNoMenu(MovieSelection):
190 def __init__(self, session):
191 MovieSelection.__init__(self, session)
192 self.skinName = "MovieSelection"
195 print "context menu forbidden inside DVDBurn to prevent calling multiple instances"
197 self.session.openWithCallback(self.selectedSource, MovieSelectionNoMenu)
199 def selectedSource(self, source):
202 t = self.project.addService(source)
203 self.editTitle(t, readOnly=True)
205 def removeCurrentTitle(self):
206 title = self.getCurrentTitle()
207 if title is not None:
208 self.project.titles.remove(title)
209 self.updateTitleList()
211 def saveProject(self):
212 self.project.saveProject(resolveFilename(SCOPE_PLAYLIST))
214 def loadProject(self, filename=None):
216 filename = resolveFilename(SCOPE_PLAYLIST)+"DreamboxDVDtemplate.ddvdp.xml"
217 if self.project.loadProject(filename):
221 self.session.open(MessageBox,self.project.error,MessageBox.TYPE_ERROR)
223 self["title_label"].text = self.project.error
224 print self.project.error
227 def burnProject(self):
228 self.project.waitboxref = self.project.session.open(WaitBox,self.burnProjectCB)
230 def burnProjectCB(self):
232 job = Process.Burn(self.session, self.project)
233 from Screens.TaskView import JobView
234 self.session.open(JobView, job)
236 def previewMenu(self):
237 self.project.waitboxref = self.project.session.open(WaitBox,self.previewMenuCB)
239 def previewMenuCB(self):
241 job = Process.PreviewMenu(self.session, self.project)
243 def updateTitleList(self):
246 for title in self.project.titles:
247 a = [ title, (eListboxPythonMultiContent.TYPE_TEXT, 0, 10, 500, 50, 0, RT_HALIGN_LEFT, title.name) ]
249 totalsize += title.estimatedDiskspace
250 self["titles"].list = res
251 self.updateSize(totalsize)
253 def updateSize(self, totalsize):
254 size = int((totalsize/1024)/1024)
258 percent = 100 * size / float(max_DL)
259 self["space_label"].text = "%d MB - " % size + _("exceeds dual layer medium!") + " (%.2f%% " % (100-percent) + _("free") + ")"
260 self["space_bar"].value = int(percent)
262 percent = 100 * size / float(max_DL)
263 self["space_label"].text = "%d MB " % size + _("of a DUAL layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")"
264 self["space_bar"].value = int(percent)
266 percent = 100 * size / float(max_SL)
267 self["space_label"].text = "%d MB " % size + _("of a SINGLE layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")"
268 self["space_bar"].value = int(percent)
270 def getCurrentTitle(self):
271 t = self["titles"].getCurrent()
274 def editTitle(self, title = None, readOnly = False):
275 t = title or self.getCurrentTitle()
277 self.current_edit_title = t
279 self.session.openWithCallback(self.titleEditDone, TitleCutter.CutlistReader, t)
281 self.session.openWithCallback(self.titleEditDone, TitleCutter.TitleCutter, t)
283 def titleEditDone(self, cutlist):
284 t = self.current_edit_title
286 t.produceFinalCuesheet()
287 print "title edit of %s done, resulting cutlist:" % (t.source.toString()), t.cutlist, "chaptermarks:", t.chaptermarks
288 self.updateTitleList()
293 def showFileBrowser(self, projectBrowser=False):
295 currDir = resolveFilename(SCOPE_PLAYLIST)
297 currDir = self.project.menubg
299 currDir = (currDir.rstrip("/").rsplit("/",1))[0]
300 self.session.openWithCallback(self.FileBrowserClosed, FileBrowser, currDir, projectBrowser)
302 def FileBrowserClosed(self, path, projectBrowser=False):
304 self.loadProject(path)
306 self.project.menubg = path