add a 'priority' for wizard screens to define the run order
[enigma2.git] / lib / python / Plugins / SystemPlugins / Videomode / plugin.py
index 1d196de4417c4d5b2ede17d11184dc0976fcca3c..b5e12c2e27c2a321f10617ba8b7ac3b6b1c219f0 100644 (file)
@@ -9,12 +9,10 @@ from Components.Pixmap import Pixmap
 from Screens.MessageBox import MessageBox
 from Screens.Setup import SetupSummary
 from Components.ConfigList import ConfigListScreen
-from Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection, ConfigSubDict
+from Components.config import getConfigListEntry, config
 from VideoWizard import VideoWizard
 from Components.config import config
 
-from Tools.CList import CList
-
 from VideoHardware import video_hw
 
 class VideoSetup(Screen, ConfigListScreen):
@@ -38,7 +36,7 @@ class VideoSetup(Screen, ConfigListScreen):
                                "save": self.apply,
                        }, -2)
 
-               self["title"] = Label(_("Video-Setup"))
+               self["title"] = Label(_("A/V Settings"))
 
                self["oktext"] = Label(_("OK"))
                self["canceltext"] = Label(_("Cancel"))
@@ -55,14 +53,27 @@ class VideoSetup(Screen, ConfigListScreen):
                self.hw.on_hotplug.remove(self.createSetup)
 
        def createSetup(self):
+               level = config.usage.setup_level.index
+
                self.list = [ ]
-               self.list.append(getConfigListEntry(_("Output Type"), config.av.videoport))
+               self.list.append(getConfigListEntry(_("Video Output"), config.av.videoport))
 
                # if we have modes for this port:
                if config.av.videoport.value in config.av.videomode:
                        # add mode- and rate-selection:
                        self.list.append(getConfigListEntry(_("Mode"), config.av.videomode[config.av.videoport.value]))
-                       self.list.append(getConfigListEntry(_("Rate"), config.av.videorate[config.av.videomode[config.av.videoport.value].value]))
+                       self.list.append(getConfigListEntry(_("Refresh Rate"), config.av.videorate[config.av.videomode[config.av.videoport.value].value]))
+
+#              if config.av.videoport.value == "DVI":
+#                      self.list.append(getConfigListEntry(_("Allow Unsupported Modes"), config.av.edid_override))
+               if config.av.videoport.value == "Scart":
+                       self.list.append(getConfigListEntry(_("Color Format"), config.av.colorformat))
+                       self.list.append(getConfigListEntry(_("Aspect Ratio"), config.av.aspectratio))
+                       if level >= 1:
+                               self.list.append(getConfigListEntry(_("WSS on 4:3"), config.av.wss))
+
+               if level >= 1:
+                       self.list.append(getConfigListEntry(_("AC3 default"), config.av.defaultac3))
 
                self["config"].list = self.list
                self["config"].l.setList(self.list)
@@ -91,9 +102,9 @@ class VideoSetup(Screen, ConfigListScreen):
                port = config.av.videoport.value
                mode = config.av.videomode[port].value
                rate = config.av.videorate[mode].value
-               if (port, mode, rate) != self.last_good or True:
+               if (port, mode, rate) != self.last_good:
                        self.hw.setMode(port, mode, rate)
-                       self.session.openWithCallback(self.confirm, MessageBox, "Is this videomode ok?", MessageBox.TYPE_YESNO, timeout = 5, default = False)
+                       self.session.openWithCallback(self.confirm, MessageBox, "Is this videomode ok?", MessageBox.TYPE_YESNO, timeout = 20, default = False)
                else:
                        self.keySave()
 
@@ -111,37 +122,55 @@ class VideoSetup(Screen, ConfigListScreen):
        def createSummary(self):
                return SetupSummary
 
-#class VideomodeHotplug:
-#      def __init__(self, hw):
-#              self.hw = hw
-#              self.hw.on_hotplug.append(self.hotplug)
-#
-#      def hotplug(self, what):
-#              print "hotplug detected on port '%s'" % (what)
-# ...
-#
-#hotplug = None
-#
-#def startHotplug(self):
-#      global hotplug
-#      hotplug = VideomodeHotplug()
-#      hotplug.start()
-#
-#def stopHotplug(self):
-#      global hotplug
-#      hotplug.stop()
-#
-#
-#def autostart(reason, session = None, **kwargs):
-#      if session is not None:
-#              global my_global_session
-#              my_global_session = session
-#              return
-#
-#      if reason == 0:
-#              startHotplug()
-#      elif reason == 1:
-#              stopHotplug()
+class VideomodeHotplug:
+       def __init__(self, hw):
+               self.hw = hw
+
+       def start(self):
+               self.hw.on_hotplug.append(self.hotplug)
+
+       def stop(self):
+               self.hw.on_hotplug.remove(self.hotplug)
+
+       def hotplug(self, what):
+               print "hotplug detected on port '%s'" % (what)
+               port = config.av.videoport.value
+               mode = config.av.videomode[port].value
+               rate = config.av.videorate[mode].value
+
+               if not self.hw.isModeAvailable(port, mode, rate):
+                       print "mode %s/%s/%s went away!" % (port, mode, rate)
+                       modelist = self.hw.getModeList(port)
+                       if not len(modelist):
+                               print "sorry, no other mode is available (unplug?). Doing nothing."
+                               return
+                       mode = modelist[0][0]
+                       rate = modelist[0][1]
+                       print "setting %s/%s/%s" % (port, mode, rate)
+                       self.hw.setMode(port, mode, rate)
+
+hotplug = None
+
+def startHotplug():
+       global hotplug, video_hw
+       hotplug = VideomodeHotplug(video_hw)
+       hotplug.start()
+
+def stopHotplug():
+       global hotplug
+       hotplug.stop()
+
+
+def autostart(reason, session = None, **kwargs):
+       if session is not None:
+               global my_global_session
+               my_global_session = session
+               return
+
+       if reason == 0:
+               startHotplug()
+       elif reason == 1:
+               stopHotplug()
 
 def videoSetupMain(session, **kwargs):
        session.open(VideoSetup, video_hw)
@@ -150,11 +179,13 @@ def startSetup(menuid):
        if menuid != "system": 
                return [ ]
 
-       return [(_("Video Setup"), videoSetupMain, "video_setup", None)]
+       return [(_("A/V Settings") + "...", videoSetupMain, "av_setup", 40)]
 
 def Plugins(**kwargs):
-       list = []
-       list.append(PluginDescriptor(name=_("Video Setup"), description=_("Advanced Video Setup"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup))
+       list = [
+#              PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart),
+               PluginDescriptor(name=_("Video Setup"), description=_("Advanced Video Setup"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup) 
+       ]
        if config.misc.firstrun.value:
-               list.append(PluginDescriptor(name=_("Video Wizard"), where = PluginDescriptor.WHERE_WIZARD, fnc=VideoWizard))
+               list.append(PluginDescriptor(name=_("Video Wizard"), where = PluginDescriptor.WHERE_WIZARD, fnc=(0, VideoWizard)))
        return list