1 from Screens.Screen import Screen
2 from Screens.ChoiceBox import ChoiceBox
3 from Screens.InputBox import InputBox
4 from Screens.MessageBox import MessageBox
5 from Screens.HelpMenu import HelpableScreen
6 from Components.ActionMap import HelpableActionMap, ActionMap
7 from Components.Sources.List import List
8 from Components.Sources.StaticText import StaticText
9 from Components.Sources.Progress import Progress
10 from Components.FileList import FileList
11 from Tools.Directories import fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_FONTS, SCOPE_HDD
12 from Components.config import config, getConfigListEntry
13 from Components.ConfigList import ConfigListScreen
15 class FileBrowser(Screen, HelpableScreen):
17 def __init__(self, session, scope, configRef):
18 Screen.__init__(self, session)
19 # for the skin: first try FileBrowser_DVDBurn, then FileBrowser, this allows individual skinning
20 self.skinName = ["FileBrowser_DVDBurn", "FileBrowser" ]
22 HelpableScreen.__init__(self)
25 self.configRef = configRef
27 if self.scope == "project":
28 currDir = self.getDir()
29 pattern = "(?i)^.*\.(ddvdp\.xml)"
30 elif self.scope == "menutemplate":
31 currDir = self.getDir()
32 pattern = "(?i)^.*\.(ddvdm\.xml)"
33 if self.scope == "menubg":
34 currDir = self.getDir(configRef.getValue())
35 pattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp)"
36 elif self.scope == "menuaudio":
37 currDir = self.getDir(configRef.getValue())
38 pattern = "(?i)^.*\.(mp2|m2a|ac3)"
39 elif self.scope == "vmgm":
40 currDir = self.getDir(configRef.getValue())
41 pattern = "(?i)^.*\.(mpg|mpeg)"
42 elif self.scope == "font_face":
43 currDir = self.getDir(configRef.getValue(), resolveFilename(SCOPE_FONTS))
44 pattern = "(?i)^.*\.(ttf)"
45 elif self.scope == "isopath":
46 currDir = configRef.getValue()
47 elif self.scope == "image":
48 currDir = resolveFilename(SCOPE_HDD)
49 pattern = "(?i)^.*\.(iso)"
51 self.filelist = FileList(currDir, matchingPattern=pattern)
52 self["filelist"] = self.filelist
54 self["FilelistActions"] = ActionMap(["SetupActions"],
60 self["key_red"] = StaticText(_("Cancel"))
61 self["key_green"] = StaticText(_("OK"))
62 self.onLayoutFinish.append(self.layoutFinished)
64 def layoutFinished(self):
65 self.setTitle(_("DVD File Browser"))
67 def getDir(self, currentVal=None, defaultDir=None):
69 return (currentVal.rstrip("/").rsplit("/",1))[0]
70 return defaultDir or (resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/")
73 if self.filelist.canDescent():
74 self.filelist.descent()
75 if self.scope == "image":
76 path = self["filelist"].getCurrentDirectory() or ""
77 if fileExists(path+"VIDEO_TS"):
78 self.close(path,self.scope,self.configRef)
80 ret = self["filelist"].getCurrentDirectory() + '/' + self["filelist"].getFilename()
81 self.close(ret,self.scope,self.configRef)
84 if self.scope == "isopath":
85 self.close(self["filelist"].getCurrentDirectory(),self.scope,self.configRef)
86 self.close(None,False,None)
88 class ProjectSettings(Screen,ConfigListScreen):
90 <screen name="ProjectSettings" position="center,center" size="560,440" title="Collection settings" >
91 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
92 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
93 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
94 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
95 <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;19" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
96 <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;19" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
97 <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;19" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
98 <widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;19" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
99 <widget name="config" position="5,50" size="550,276" scrollbarMode="showOnDemand" />
100 <ePixmap pixmap="skin_default/div-h.png" position="0,350" zPosition="1" size="560,2" />
101 <widget source="info" render="Label" position="10,360" size="550,80" font="Regular;18" halign="center" valign="center" />
104 def __init__(self, session, project = None):
105 Screen.__init__(self, session)
106 self.project = project
108 self["key_red"] = StaticText(_("Cancel"))
109 self["key_green"] = StaticText(_("OK"))
110 self["key_yellow"] = StaticText(_("Load"))
111 if config.usage.setup_level.index >= 2: # expert+
112 self["key_blue"] = StaticText(_("Save"))
114 self["key_blue"] = StaticText()
116 if config.usage.setup_level.index >= 2: # expert+
117 infotext = _("Available format variables") + ":\n$i=" + _("Track") + ", $t=" + _("Title") + ", $d=" + _("Description") + ", $l=" + _("length") + ", $c=" + _("chapters") + ",\n" + _("Record") + " $T=" + _("Begin time") + ", $Y=" + _("Year") + ", $M=" + _("month") + ", $D=" + _("day") + ",\n$A=" + _("audio tracks") + ", $C=" + _("Channel") + ", $f=" + _("filename")
120 self["info"] = StaticText(infotext)
123 self.settings = project.settings
124 ConfigListScreen.__init__(self, [])
125 self.initConfigList()
127 self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
131 "blue": self.saveProject,
132 "yellow": self.loadProject,
133 "cancel": self.cancel,
136 self.onLayoutFinish.append(self.layoutFinished)
138 def layoutFinished(self):
139 self.setTitle(_("Collection settings"))
141 def changedConfigList(self):
142 key = self.keydict[self["config"].getCurrent()[1]]
143 if key == "authormode" or key == "output":
144 self.initConfigList()
146 def initConfigList(self):
147 authormode = self.settings.authormode.getValue()
148 output = self.settings.output.getValue()
150 self.list.append(getConfigListEntry(_("Collection name"), self.settings.name))
151 self.list.append(getConfigListEntry(_("Authoring mode"), self.settings.authormode))
152 self.list.append(getConfigListEntry(("Output"), self.settings.output))
154 self.list.append(getConfigListEntry(_("ISO path"), self.settings.isopath))
155 if authormode.startswith("menu"):
156 self.list.append(getConfigListEntry(_("Menu")+' '+_("template file"), self.settings.menutemplate))
157 if config.usage.setup_level.index >= 2: # expert+
158 self.list.append(getConfigListEntry(_("Menu")+' '+_("Title"), self.project.menutemplate.settings.titleformat))
159 self.list.append(getConfigListEntry(_("Menu")+' '+_("Subtitles"), self.project.menutemplate.settings.subtitleformat))
160 self.list.append(getConfigListEntry(_("Menu")+' '+_("background image"), self.project.menutemplate.settings.menubg))
161 self.list.append(getConfigListEntry(_("Menu")+' '+_("Language selection"), self.project.menutemplate.settings.menulang))
162 #self.list.append(getConfigListEntry(_("Menu")+' '+_("headline")+' '+_("color"), self.settings.color_headline))
163 #self.list.append(getConfigListEntry(_("Menu")+' '+_("text")+' '+_("color"), self.settings.color_button))
164 #self.list.append(getConfigListEntry(_("Menu")+' '+_("highlighted button")+' '+_("color"), self.settings.color_highlight))
165 #self.list.append(getConfigListEntry(_("Menu")+' '+_("font face"), self.settings.font_face))
166 #self.list.append(getConfigListEntry(_("Font size")+' ('+_("headline")+', '+_("Title")+', '+_("Subtitles")+')', self.settings.font_size))
167 #self.list.append(getConfigListEntry(_("Menu")+' '+_("spaces (top, between rows, left)"), self.settings.space))
168 #self.list.append(getConfigListEntry(_("Menu")+' '+_("Audio"), self.settings.menuaudio))
169 if config.usage.setup_level.index >= 2: # expert+
170 if authormode != "data_ts":
171 self.list.append(getConfigListEntry(_("Titleset mode"), self.settings.titlesetmode))
172 if self.settings.titlesetmode.getValue() == "single" or authormode == "just_linked":
173 self.list.append(getConfigListEntry(_("VMGM (intro trailer)"), self.settings.vmgm))
175 self.list.append(getConfigListEntry(("DVD data format"), self.settings.dataformat))
177 self["config"].setList(self.list)
179 for key, val in self.settings.dict().iteritems():
180 self.keydict[val] = key
181 for key, val in self.project.menutemplate.settings.dict().iteritems():
182 self.keydict[val] = key
185 ConfigListScreen.keyLeft(self)
186 key = self.keydict[self["config"].getCurrent()[1]]
187 if key == "authormode" or key == "output" or key=="titlesetmode":
188 self.initConfigList()
191 ConfigListScreen.keyRight(self)
192 key = self.keydict[self["config"].getCurrent()[1]]
193 if key == "authormode" or key == "output" or key=="titlesetmode":
194 self.initConfigList()
200 def applySettings(self):
201 for x in self["config"].list:
205 key = self.keydict[self["config"].getCurrent()[1]]
206 from DVDProject import ConfigFilename
207 if type(self["config"].getCurrent()[1]) == ConfigFilename:
208 self.session.openWithCallback(self.FileBrowserClosed, FileBrowser, key, self["config"].getCurrent()[1])
213 def loadProject(self):
214 self.session.openWithCallback(self.FileBrowserClosed, FileBrowser, "project", self.settings)
216 def saveProject(self):
217 if config.usage.setup_level.index >= 2: # expert+
219 ret = self.project.saveProject(resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/")
221 text = _("Save")+' '+_('OK')+':\n'+ret
222 self.session.open(MessageBox,text,type = MessageBox.TYPE_INFO)
224 text = _("Save")+' '+_('Error')
225 self.session.open(MessageBox,text,type = MessageBox.TYPE_ERROR)
227 def FileBrowserClosed(self, path, scope, configRef):
228 if scope == "menutemplate":
229 if self.project.menutemplate.loadTemplate(path):
230 print "[ProjectSettings] menu template loaded"
231 configRef.setValue(path)
232 self.initConfigList()
234 self.session.open(MessageBox,self.project.error,MessageBox.TYPE_ERROR)
235 elif scope == "project":
236 if self.project.loadProject(path):
237 self.initConfigList()
239 self.session.open(MessageBox,self.project.error,MessageBox.TYPE_ERROR)
241 configRef.setValue(path)
242 self.initConfigList()