1 from Screens.Screen import Screen
2 from Screens.HelpMenu import HelpableScreen
3 from Components.Label import Label
4 from Components.FileList import FileList
5 from Components.MediaPlayer import PlayList
6 from Components.config import config, getConfigListEntry, ConfigSubsection, configfile, ConfigText, ConfigYesNo
7 from Components.ConfigList import ConfigListScreen
8 from Components.ActionMap import ActionMap
10 class ConfigDirectory(ConfigText):
11 def __init__(self, default="", visible_width=60):
12 ConfigText.__init__(self, default, fixed_size = True, visible_width = visible_width)
13 def handleKey(self, key):
19 return ConfigText.getValue(self)
20 def setValue(self, val):
23 ConfigText.setValue(self, val)
24 def getMulti(self, selected):
26 return ("mtext"[1-selected:], _("List of Storage Devices"), range(0))
28 return ConfigText.getMulti(self, selected)
30 config.mediaplayer = ConfigSubsection()
31 config.mediaplayer.repeat = ConfigYesNo(default=False)
32 config.mediaplayer.savePlaylistOnExit = ConfigYesNo(default=True)
33 config.mediaplayer.saveDirOnExit = ConfigYesNo(default=False)
34 config.mediaplayer.defaultDir = ConfigDirectory()
36 class DirectoryBrowser(Screen, HelpableScreen):
38 <screen name="DirectoryBrowser" position="160,62" size="450,376" title="Directory browser" >
39 <ePixmap pixmap="skin_default/buttons/red.png" position="10,0" size="140,40" alphatest="on" />
40 <ePixmap pixmap="skin_default/buttons/green.png" position="300,0" size="140,40" alphatest="on" />
41 <widget source="key_red" render="Label" position="10,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
42 <widget source="key_green" render="Label" position="300,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
43 <widget name="filelist" position="0,44" size="440,322" scrollbarMode="showOnDemand" />
45 def __init__(self, session, currDir):
46 from Components.Sources.StaticText import StaticText
47 Screen.__init__(self, session)
48 HelpableScreen.__init__(self)
50 self["key_red"] = StaticText(_("Cancel"))
51 self["key_green"] = StaticText(_("Use"))
53 self.filelist = FileList(currDir, matchingPattern="")
54 self["filelist"] = self.filelist
56 self["FilelistActions"] = ActionMap(["SetupActions", "ColorActions"],
65 if self.filelist.canDescent():
66 self.filelist.descent()
69 if self.filelist.canDescent() and len(self["filelist"].getFilename()) > len(self["filelist"].getCurrentDirectory()):
70 self.filelist.descent()
71 self.close(self["filelist"].getCurrentDirectory())
76 class MediaPlayerSettings(Screen,ConfigListScreen):
78 <screen name="MediaPlayerSettings" position="160,150" size="450,200" title="Edit settings">
79 <ePixmap pixmap="skin_default/buttons/red.png" position="10,0" size="140,40" alphatest="on" />
80 <ePixmap pixmap="skin_default/buttons/green.png" position="300,0" size="140,40" alphatest="on" />
81 <widget source="key_red" render="Label" position="10,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
82 <widget source="key_green" render="Label" position="300,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
83 <widget name="config" position="10,44" size="430,146" />
86 def __init__(self, session, parent):
87 from Components.Sources.StaticText import StaticText
88 Screen.__init__(self, session)
89 self["key_red"] = StaticText(_("Cancel"))
90 self["key_green"] = StaticText(_("Save"))
92 ConfigListScreen.__init__(self, [])
95 config.mediaplayer.saveDirOnExit.addNotifier(self.initConfigList)
97 self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
101 "cancel": self.cancel,
105 def initConfigList(self, element=None):
106 print "[initConfigList]", element
109 self.list.append(getConfigListEntry(_("repeat playlist"), config.mediaplayer.repeat))
110 self.list.append(getConfigListEntry(_("save playlist on exit"), config.mediaplayer.savePlaylistOnExit))
111 self.list.append(getConfigListEntry(_("save last directory on exit"), config.mediaplayer.saveDirOnExit))
112 if not config.mediaplayer.saveDirOnExit.getValue():
113 self.list.append(getConfigListEntry(_("start directory"), config.mediaplayer.defaultDir))
114 self["config"].setList(self.list)
118 def changedConfigList(self):
119 self.initConfigList()
122 if self["config"].getCurrent()[1] == config.mediaplayer.defaultDir:
123 self.session.openWithCallback(self.DirectoryBrowserClosed, DirectoryBrowser, self.parent.filelist.getCurrentDirectory())
125 def DirectoryBrowserClosed(self, path):
126 print "PathBrowserClosed:" + str(path)
128 config.mediaplayer.defaultDir.setValue(path)
131 for x in self["config"].list: