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 eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT, 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 position="90,83" 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/blue.png" position="420,0" size="140,40" alphatest="on" />
25 <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" />
26 <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" />
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="serviceinfo" render="Label" position="10,46" size="350,144" font="Regular;18" />
29 <widget name="thumbnail" position="370,46" size="180,144" alphatest="on" />
30 <widget name="config" position="10,206" size="540,228" scrollbarMode="showOnDemand" />
33 def __init__(self, session, parent, project, title_idx):
34 Screen.__init__(self, session)
36 self.project = project
37 self.title_idx = title_idx
39 self["key_red"] = StaticText(_("Cancel"))
40 self["key_green"] = StaticText(_("OK"))
41 self["key_blue"] = StaticText(_("Edit Title"))
42 self["serviceinfo"] = StaticText()
44 self["thumbnail"] = Pixmap()
45 self.picload = ePicLoad()
46 self.picload.PictureData.get().append(self.paintThumbPixmapCB)
48 self.properties = project.titles[title_idx].properties
49 ConfigListScreen.__init__(self, [])
50 self.properties.crop = DVDTitle.ConfigFixedText("crop")
51 self.properties.autochapter.addNotifier(self.initConfigList)
52 self.properties.aspect.addNotifier(self.initConfigList)
53 for audiotrack in self.properties.audiotracks:
54 audiotrack.active.addNotifier(self.initConfigList)
56 self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
60 "blue": self.editTitle,
61 "cancel": self.cancel,
65 self.onShown.append(self.update)
67 def initConfigList(self, element=None):
69 self.properties.position = ConfigInteger(default = self.title_idx+1, limits = (1, len(self.project.titles)))
70 title = self.project.titles[self.title_idx]
72 self.list.append(getConfigListEntry("DVD " + _("Track"), self.properties.position))
73 self.list.append(getConfigListEntry("DVD " + _("Title"), self.properties.menutitle))
74 self.list.append(getConfigListEntry("DVD " + _("Description"), self.properties.menusubtitle))
75 if config.usage.setup_level.index >= 2: # expert+
76 for audiotrack in self.properties.audiotracks:
77 DVB_aud = audiotrack.DVB_lang.getValue() or audiotrack.pid.getValue()
78 self.list.append(getConfigListEntry(_("burn audio track (%s)") % DVB_aud, audiotrack.active))
79 if audiotrack.active.getValue():
80 self.list.append(getConfigListEntry(_("audio track (%s) format") % DVB_aud, audiotrack.format))
81 self.list.append(getConfigListEntry(_("audio track (%s) language") % DVB_aud, audiotrack.language))
83 self.list.append(getConfigListEntry("DVD " + _("Aspect Ratio"), self.properties.aspect))
84 if self.properties.aspect.getValue() == "16:9":
85 self.list.append(getConfigListEntry("DVD " + "widescreen", self.properties.widescreen))
87 self.list.append(getConfigListEntry("DVD " + "widescreen", self.properties.crop))
88 if len(title.chaptermarks) == 0:
89 self.list.append(getConfigListEntry(_("Auto chapter split every ? minutes (0=never)"), self.properties.autochapter))
90 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)
91 chaptermarks = title.getChapterMarks(template="$h:$m:$s")
92 chapters_count = len(chaptermarks)
93 if chapters_count >= 1:
94 infotext += str(chapters_count+1) + ' ' + _("chapters") + ': '
95 infotext += ' / '.join(chaptermarks)
96 self["serviceinfo"].setText(infotext)
97 self["config"].setList(self.list)
98 except AttributeError:
102 self.parent.editTitle()
106 self.initConfigList()
110 thumbfile = self.project.titles[self.title_idx].inputfile.rsplit('.',1)[0] + ".png"
111 sc = AVSwitch().getFramebufferScale()
112 self.picload.setPara((self["thumbnail"].instance.size().width(), self["thumbnail"].instance.size().height(), sc[0], sc[1], False, 1, "#00000000"))
113 self.picload.startDecode(thumbfile)
115 def paintThumbPixmapCB(self, picInfo=None):
116 ptr = self.picload.getData()
118 self["thumbnail"].instance.setPixmap(ptr.__deref__())
120 def changedConfigList(self):
121 self.initConfigList()
127 def applySettings(self):
128 for x in self["config"].list:
130 current_pos = self.title_idx+1
131 new_pos = self.properties.position.getValue()
132 if new_pos != current_pos:
133 print "title got repositioned from ", current_pos, "to", new_pos
134 swaptitle = self.project.titles.pop(current_pos-1)
135 self.project.titles.insert(new_pos-1, swaptitle)
138 #key = self.keydict[self["config"].getCurrent()[1]]
139 #if key in self.project.filekeys:
140 #self.session.openWithCallback(self.FileBrowserClosed, FileBrowser, key, self.settings)
146 from Tools.ISO639 import LanguageCodes
147 class LanguageChoices():
149 from Components.Language import language as syslanguage
150 syslang = syslanguage.getLanguage()[:2]
153 for key, val in LanguageCodes.iteritems():
155 self.langdict[key] = val[0]
156 for key, val in self.langdict.iteritems():
157 if key not in (syslang, 'en'):
158 self.langdict[key] = val
159 self.choices.append((key, val))
161 self.choices.insert(0,("nolang", ("unspecified")))
162 self.choices.insert(1,(syslang, self.langdict[syslang]))
163 self.choices.insert(2,("en", self.langdict["en"]))
165 def getLanguage(self, DVB_lang):
166 DVB_lang = DVB_lang.lower()
167 for word in ("stereo", "audio", "description", "2ch", "dolby digital"):
168 DVB_lang = DVB_lang.replace(word,"").strip()
169 for key, val in LanguageCodes.iteritems():
170 if DVB_lang.find(key.lower()) == 0:
174 DVB_lang = (LanguageCodes[key])[0]
175 elif DVB_lang.find(val[0].lower()) > -1:
179 DVB_lang = (LanguageCodes[key])[0]
180 for key, val in self.langdict.iteritems():
185 languageChoices = LanguageChoices()