Merge branch 'bug_124_m2ts_support'
[enigma2.git] / lib / python / Plugins / Extensions / MediaPlayer / settings.py
index 5f9ce7cd0a46fa393742c1b46729e52198ce9193..7f42677de3df56894c4119892ba9e9d2b6e485e9 100755 (executable)
@@ -1,7 +1,7 @@
 from Screens.Screen import Screen
 from Screens.HelpMenu import HelpableScreen
 from Screens.Screen import Screen
 from Screens.HelpMenu import HelpableScreen
-from Components.Label import Label
 from Components.FileList import FileList
 from Components.FileList import FileList
+from Components.Sources.StaticText import StaticText
 from Components.MediaPlayer import PlayList
 from Components.config import config, getConfigListEntry, ConfigSubsection, configfile, ConfigText, ConfigYesNo, ConfigDirectory
 from Components.ConfigList import ConfigListScreen
 from Components.MediaPlayer import PlayList
 from Components.config import config, getConfigListEntry, ConfigSubsection, configfile, ConfigText, ConfigYesNo, ConfigDirectory
 from Components.ConfigList import ConfigListScreen
@@ -12,21 +12,18 @@ config.mediaplayer.repeat = ConfigYesNo(default=False)
 config.mediaplayer.savePlaylistOnExit = ConfigYesNo(default=True)
 config.mediaplayer.saveDirOnExit = ConfigYesNo(default=False)
 config.mediaplayer.defaultDir = ConfigDirectory()
 config.mediaplayer.savePlaylistOnExit = ConfigYesNo(default=True)
 config.mediaplayer.saveDirOnExit = ConfigYesNo(default=False)
 config.mediaplayer.defaultDir = ConfigDirectory()
+config.mediaplayer.useAlternateUserAgent = ConfigYesNo(default=False)
+config.mediaplayer.alternateUserAgent = ConfigText(default="")
 
 class DirectoryBrowser(Screen, HelpableScreen):
 
 class DirectoryBrowser(Screen, HelpableScreen):
-       skin = """
-               <screen name="DirectoryBrowser" position="center,center" size="560,400" title="Directory browser" >
-                       <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
-                       <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
-                       <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" />
-                       <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" />
-                       <widget name="filelist" position="5,50" size="550,350" scrollbarMode="showOnDemand" />
-               </screen>"""
+
        def __init__(self, session, currDir):
        def __init__(self, session, currDir):
-               from Components.Sources.StaticText import StaticText
                Screen.__init__(self, session)
                Screen.__init__(self, session)
+               # for the skin: first try MediaPlayerDirectoryBrowser, then FileBrowser, this allows individual skinning
+               self.skinName = ["MediaPlayerDirectoryBrowser", "FileBrowser" ]
+
                HelpableScreen.__init__(self)
                HelpableScreen.__init__(self)
-               
+
                self["key_red"] = StaticText(_("Cancel"))
                self["key_green"] = StaticText(_("Use"))
 
                self["key_red"] = StaticText(_("Cancel"))
                self["key_green"] = StaticText(_("Use"))
 
@@ -40,36 +37,39 @@ class DirectoryBrowser(Screen, HelpableScreen):
                                "ok": self.ok,
                                "cancel": self.exit
                        })
                                "ok": self.ok,
                                "cancel": self.exit
                        })
+               self.onLayoutFinish.append(self.layoutFinished)
+
+       def layoutFinished(self):
+               self.setTitle(_("Directory browser"))
 
        def ok(self):
                if self.filelist.canDescent():
                        self.filelist.descent()
 
        def use(self):
 
        def ok(self):
                if self.filelist.canDescent():
                        self.filelist.descent()
 
        def use(self):
-               if self.filelist.canDescent() and self["filelist"].getFilename() and len(self["filelist"].getFilename()) > len(self["filelist"].getCurrentDirectory()):
-                       self.filelist.descent()
-               self.close(self["filelist"].getCurrentDirectory())
+               if self["filelist"].getCurrentDirectory() is not None:
+                       if self.filelist.canDescent() and self["filelist"].getFilename() and len(self["filelist"].getFilename()) > len(self["filelist"].getCurrentDirectory()):
+                               self.filelist.descent()
+                               self.close(self["filelist"].getCurrentDirectory())
+               else:
+                               self.close(self["filelist"].getFilename())
 
        def exit(self):
                self.close(False)
 
 class MediaPlayerSettings(Screen,ConfigListScreen):
 
        def exit(self):
                self.close(False)
 
 class MediaPlayerSettings(Screen,ConfigListScreen):
-       skin = """
-               <screen name="MediaPlayerSettings" position="center,center" size="560,300" title="Edit settings">
-                       <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
-                       <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
-                       <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" />
-                       <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" />
-                       <widget name="config" position="5,50" size="550,250" />
-               </screen>"""
 
        def __init__(self, session, parent):
 
        def __init__(self, session, parent):
-               from Components.Sources.StaticText import StaticText
                Screen.__init__(self, session)
                Screen.__init__(self, session)
+               # for the skin: first try MediaPlayerSettings, then Setup, this allows individual skinning
+               self.skinName = ["MediaPlayerSettings", "Setup" ]
+               self.setup_title = _("Edit settings")
+               self.onChangedEntry = [ ]
+
                self["key_red"] = StaticText(_("Cancel"))
                self["key_green"] = StaticText(_("Save"))
 
                self["key_red"] = StaticText(_("Cancel"))
                self["key_green"] = StaticText(_("Save"))
 
-               ConfigListScreen.__init__(self, [])
+               ConfigListScreen.__init__(self, [], session = session, on_change = self.changedEntry)
                self.parent = parent
                self.initConfigList()
                config.mediaplayer.saveDirOnExit.addNotifier(self.initConfigList)
                self.parent = parent
                self.initConfigList()
                config.mediaplayer.saveDirOnExit.addNotifier(self.initConfigList)
@@ -82,6 +82,9 @@ class MediaPlayerSettings(Screen,ConfigListScreen):
                    "ok": self.ok,
                }, -2)
 
                    "ok": self.ok,
                }, -2)
 
+       def layoutFinished(self):
+               self.setTitle(self.setup_title)
+
        def initConfigList(self, element=None):
                print "[initConfigList]", element
                try:
        def initConfigList(self, element=None):
                print "[initConfigList]", element
                try:
@@ -115,3 +118,17 @@ class MediaPlayerSettings(Screen,ConfigListScreen):
        def cancel(self):
                self.close()
 
        def cancel(self):
                self.close()
 
+       # for summary:
+       def changedEntry(self):
+               for x in self.onChangedEntry:
+                       x()
+
+       def getCurrentEntry(self):
+               return self["config"].getCurrent()[0]
+
+       def getCurrentValue(self):
+               return str(self["config"].getCurrent()[1].getText())
+
+       def createSummary(self):
+               from Screens.Setup import SetupSummary
+               return SetupSummary