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 Components.Pixmap import Pixmap
12 from enigma import ePicLoad
13 from Tools.Directories import fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_FONTS, SCOPE_HDD
14 from Components.config import config, getConfigListEntry, ConfigInteger, ConfigSubsection, ConfigSelection
15 from Components.ConfigList import ConfigListScreen
16 from Components.AVSwitch import AVSwitch
19 class TitleProperties(Screen,ConfigListScreen):
21 <screen name="TitleProperties" position="center,center" size="560,445" title="Properties of current title" >
22 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
23 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
24 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
25 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
26 <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" />
27 <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" />
28 <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" />
29 <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" />
30 <widget source="serviceinfo" render="Label" position="10,46" size="350,144" font="Regular;18" />
31 <widget name="thumbnail" position="370,46" size="180,144" alphatest="on" />
32 <widget name="config" position="10,206" size="540,228" scrollbarMode="showOnDemand" />
35 def __init__(self, session, parent, project, title_idx):
36 Screen.__init__(self, session)
38 self.project = project
39 self.title_idx = title_idx
41 self["key_red"] = StaticText(_("Cancel"))
42 self["key_green"] = StaticText(_("OK"))
43 self["key_yellow"] = StaticText(_("Edit Title"))
44 self["key_blue"] = StaticText()
45 self["serviceinfo"] = StaticText()
47 self["thumbnail"] = Pixmap()
48 self.picload = ePicLoad()
49 self.picload.PictureData.get().append(self.paintThumbPixmapCB)
51 self.properties = project.titles[title_idx].properties
52 ConfigListScreen.__init__(self, [])
53 self.properties.crop = DVDTitle.ConfigFixedText("crop")
54 self.properties.autochapter.addNotifier(self.initConfigList)
55 self.properties.aspect.addNotifier(self.initConfigList)
56 for audiotrack in self.properties.audiotracks:
57 audiotrack.active.addNotifier(self.initConfigList)
59 self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
63 "yellow": self.editTitle,
64 "cancel": self.cancel,
68 self.onShown.append(self.update)
69 self.onLayoutFinish.append(self.layoutFinished)
71 def layoutFinished(self):
72 self.setTitle(_("Properties of current title"))
74 def initConfigList(self, element=None):
76 self.properties.position = ConfigInteger(default = self.title_idx+1, limits = (1, len(self.project.titles)))
77 title = self.project.titles[self.title_idx]
79 self.list.append(getConfigListEntry("DVD " + _("Track"), self.properties.position))
80 self.list.append(getConfigListEntry("DVD " + _("Title"), self.properties.menutitle))
81 self.list.append(getConfigListEntry("DVD " + _("Description"), self.properties.menusubtitle))
82 if config.usage.setup_level.index >= 2: # expert+
83 for audiotrack in self.properties.audiotracks:
84 DVB_aud = audiotrack.DVB_lang.getValue() or audiotrack.pid.getValue()
85 self.list.append(getConfigListEntry(_("burn audio track (%s)") % DVB_aud, audiotrack.active))
86 if audiotrack.active.getValue():
87 self.list.append(getConfigListEntry(_("audio track (%s) format") % DVB_aud, audiotrack.format))
88 self.list.append(getConfigListEntry(_("audio track (%s) language") % DVB_aud, audiotrack.language))
90 self.list.append(getConfigListEntry("DVD " + _("Aspect Ratio"), self.properties.aspect))
91 if self.properties.aspect.getValue() == "16:9":
92 self.list.append(getConfigListEntry("DVD " + "widescreen", self.properties.widescreen))
94 self.list.append(getConfigListEntry("DVD " + "widescreen", self.properties.crop))
95 if len(title.chaptermarks) == 0:
96 self.list.append(getConfigListEntry(_("Auto chapter split every ? minutes (0=never)"), self.properties.autochapter))
97 infotext = "DVB " + _("Title") + ': ' + title.DVBname + "\n" + _("Description") + ': ' + title.DVBdescr + "\n" + _("Channel") + ': ' + title.DVBchannel + '\n' + _("Begin time") + title.formatDVDmenuText(": $D.$M.$Y, $T\n", self.title_idx+1)
98 chaptermarks = title.getChapterMarks(template="$h:$m:$s")
99 chapters_count = len(chaptermarks)
100 if chapters_count >= 1:
101 infotext += str(chapters_count+1) + ' ' + _("chapters") + ': '
102 infotext += ' / '.join(chaptermarks)
103 self["serviceinfo"].setText(infotext)
104 self["config"].setList(self.list)
105 except AttributeError:
109 self.parent.editTitle()
113 self.initConfigList()
117 thumbfile = self.project.titles[self.title_idx].inputfile.rsplit('.',1)[0] + ".png"
118 sc = AVSwitch().getFramebufferScale()
119 self.picload.setPara((self["thumbnail"].instance.size().width(), self["thumbnail"].instance.size().height(), sc[0], sc[1], False, 1, "#00000000"))
120 self.picload.startDecode(thumbfile)
122 def paintThumbPixmapCB(self, picInfo=None):
123 ptr = self.picload.getData()
125 self["thumbnail"].instance.setPixmap(ptr.__deref__())
127 def changedConfigList(self):
128 self.initConfigList()
134 def applySettings(self):
135 for x in self["config"].list:
137 current_pos = self.title_idx+1
138 new_pos = self.properties.position.getValue()
139 if new_pos != current_pos:
140 print "title got repositioned from ", current_pos, "to", new_pos
141 swaptitle = self.project.titles.pop(current_pos-1)
142 self.project.titles.insert(new_pos-1, swaptitle)
145 #key = self.keydict[self["config"].getCurrent()[1]]
146 #if key in self.project.filekeys:
147 #self.session.openWithCallback(self.FileBrowserClosed, FileBrowser, key, self.settings)
153 from Tools.ISO639 import LanguageCodes
154 class LanguageChoices():
156 from Components.Language import language as syslanguage
157 syslang = syslanguage.getLanguage()[:2]
160 for key, val in LanguageCodes.iteritems():
162 self.langdict[key] = val[0]
163 for key, val in self.langdict.iteritems():
164 if key not in (syslang, 'en'):
165 self.langdict[key] = val
166 self.choices.append((key, val))
168 self.choices.insert(0,("nolang", ("unspecified")))
169 self.choices.insert(1,(syslang, self.langdict[syslang]))
171 self.choices.insert(2,("en", self.langdict["en"]))
173 def getLanguage(self, DVB_lang):
174 DVB_lang = DVB_lang.lower()
175 for word in ("stereo", "audio", "description", "2ch", "dolby digital"):
176 DVB_lang = DVB_lang.replace(word,"").strip()
177 for key, val in LanguageCodes.iteritems():
178 if DVB_lang.find(key.lower()) == 0:
182 DVB_lang = (LanguageCodes[key])[0]
183 elif DVB_lang.find(val[0].lower()) > -1:
187 DVB_lang = (LanguageCodes[key])[0]
188 for key, val in self.langdict.iteritems():
193 languageChoices = LanguageChoices()