add space
[enigma2.git] / lib / python / Screens / Satconfig.py
index 40bf70463ec66e1bfce1ea5d5df3f29e3141ecf5..cf0365d710c1e084c7a440ef40180f83af7c3796 100644 (file)
@@ -6,6 +6,7 @@ from Components.ConfigList import ConfigListScreen
 from Components.MenuList import MenuList
 from Components.NimManager import nimmanager
 from Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection, updateConfigElement
 from Components.MenuList import MenuList
 from Components.NimManager import nimmanager
 from Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection, updateConfigElement
+from Components.Sources.List import List
 from Screens.MessageBox import MessageBox
 
 from time import mktime, localtime
 from Screens.MessageBox import MessageBox
 
 from time import mktime, localtime
@@ -48,20 +49,21 @@ class NimSetup(Screen, ConfigListScreen):
                                nim.powerMeasurement.save()
                
        def createConfigMode(self):
                                nim.powerMeasurement.save()
                
        def createConfigMode(self):
-               choices = { "nothing": _("nothing connected"),
-                                       "simple": _("simple"),
-                                       "advanced": _("advanced")}
-               #if len(nimmanager.getNimListOfType(nimmanager.getNimType(self.slotid), exception = x)) > 0:
-               #       choices["equal"] = _("equal to")
-               #       choices["satposdepends"] = _("second cable of motorized LNB")
-               if len(nimmanager.canEqualTo(self.slotid)) > 0:
-                       choices["equal"] = _("equal to")
-               if len(nimmanager.canDependOn(self.slotid)) > 0:
-                       choices["satposdepends"] = _("second cable of motorized LNB")
-               if len(nimmanager.canConnectTo(self.slotid)) > 0:
-                       choices["loopthrough"] = _("loopthrough to")
-               self.nimConfig.configMode = updateConfigElement(self.nimConfig.configMode, ConfigSelection(choices = choices, default = "simple"))
-                                       
+               if self.nim.isCompatible("DVB-S"):
+                       choices = { "nothing": _("nothing connected"),
+                                               "simple": _("simple"),
+                                               "advanced": _("advanced")}
+                       #if len(nimmanager.getNimListOfType(nimmanager.getNimType(self.slotid), exception = x)) > 0:
+                       #       choices["equal"] = _("equal to")
+                       #       choices["satposdepends"] = _("second cable of motorized LNB")
+                       if len(nimmanager.canEqualTo(self.slotid)) > 0:
+                               choices["equal"] = _("equal to")
+                       if len(nimmanager.canDependOn(self.slotid)) > 0:
+                               choices["satposdepends"] = _("second cable of motorized LNB")
+                       if len(nimmanager.canConnectTo(self.slotid)) > 0:
+                               choices["loopthrough"] = _("loopthrough to")
+                       self.nimConfig.configMode.setChoices(choices)
+                                                       
        def createSetup(self):
                print "Creating setup"
                self.list = [ ]
        def createSetup(self):
                print "Creating setup"
                self.list = [ ]
@@ -98,7 +100,8 @@ class NimSetup(Screen, ConfigListScreen):
                                for id in nimlist:
                                        #choices.append((str(id), str(chr(65 + id))))
                                        choices.append((str(id), nimmanager.getNimDescription(id)))
                                for id in nimlist:
                                        #choices.append((str(id), str(chr(65 + id))))
                                        choices.append((str(id), nimmanager.getNimDescription(id)))
-                               self.nimConfig.connectedTo = updateConfigElement(self.nimConfig.connectedTo, ConfigSelection(choices = choices))
+                               self.nimConfig.connectedTo.setChoices(choices)
+                               #self.nimConfig.connectedTo = updateConfigElement(self.nimConfig.connectedTo, ConfigSelection(choices = choices))
                                self.list.append(getConfigListEntry(_("Tuner"), self.nimConfig.connectedTo))
                        elif self.nimConfig.configMode.value == "satposdepends":
                                choices = []
                                self.list.append(getConfigListEntry(_("Tuner"), self.nimConfig.connectedTo))
                        elif self.nimConfig.configMode.value == "satposdepends":
                                choices = []
@@ -106,15 +109,17 @@ class NimSetup(Screen, ConfigListScreen):
                                for id in nimlist:
                                        #choices.append((str(id), str(chr(65 + id))))
                                        choices.append((str(id), nimmanager.getNimDescription(id)))
                                for id in nimlist:
                                        #choices.append((str(id), str(chr(65 + id))))
                                        choices.append((str(id), nimmanager.getNimDescription(id)))
-                               self.nimConfig.connectedTo = updateConfigElement(self.nimConfig.connectedTo, ConfigSelection(choices = choices))
+                               self.nimConfig.connectedTo.setChoices(choices)
+                               #self.nimConfig.connectedTo = updateConfigElement(self.nimConfig.connectedTo, ConfigSelection(choices = choices))
                                self.list.append(getConfigListEntry(_("Tuner"), self.nimConfig.connectedTo))
                        elif self.nimConfig.configMode.value == "loopthrough":
                                choices = []
                                print "connectable to:", nimmanager.canConnectTo(self.slotid)
                                self.list.append(getConfigListEntry(_("Tuner"), self.nimConfig.connectedTo))
                        elif self.nimConfig.configMode.value == "loopthrough":
                                choices = []
                                print "connectable to:", nimmanager.canConnectTo(self.slotid)
-                               connectable = nimmanager.canConnectTo(self.slotid) 
+                               connectable = nimmanager.canConnectTo(self.slotid)
                                for id in connectable:
                                        choices.append((str(id), nimmanager.getNimDescription(id)))
                                for id in connectable:
                                        choices.append((str(id), nimmanager.getNimDescription(id)))
-                               self.nimConfig.connectedTo = updateConfigElement(self.nimConfig.connectedTo, ConfigSelection(choices = choices))
+                               self.nimConfig.connectedTo.setChoices(choices)
+                               #self.nimConfig.connectedTo = updateConfigElement(self.nimConfig.connectedTo, ConfigSelection(choices = choices))
                                self.list.append(getConfigListEntry(_("Connected to"), self.nimConfig.connectedTo))
                        elif self.nimConfig.configMode.value == "nothing":
                                pass
                                self.list.append(getConfigListEntry(_("Connected to"), self.nimConfig.connectedTo))
                        elif self.nimConfig.configMode.value == "nothing":
                                pass
@@ -197,6 +202,7 @@ class NimSetup(Screen, ConfigListScreen):
                                x[1].value = int(mktime(dt.timetuple()))
                        x[1].save()
                nimmanager.sec.update()
                                x[1].value = int(mktime(dt.timetuple()))
                        x[1].save()
                nimmanager.sec.update()
+               self.saveAll()
 
        def fillListWithAdvancedSatEntrys(self, Sat):
                currLnb = self.nimConfig.advanced.lnb[int(Sat.lnb.value)]
 
        def fillListWithAdvancedSatEntrys(self, Sat):
                currLnb = self.nimConfig.advanced.lnb[int(Sat.lnb.value)]
@@ -332,8 +338,6 @@ class NimSetup(Screen, ConfigListScreen):
                self.nimConfig = self.nim.config
                self.createConfigMode()
                self.createSetup()
                self.nimConfig = self.nim.config
                self.createConfigMode()
                self.createSetup()
-               # safeAll is needed, so that keyCancel works properly
-               self.saveAll()
 
        def keyLeft(self):
                ConfigListScreen.keyLeft(self)
 
        def keyLeft(self):
                ConfigListScreen.keyLeft(self)
@@ -342,16 +346,35 @@ class NimSetup(Screen, ConfigListScreen):
        def keyRight(self):
                ConfigListScreen.keyRight(self)
                self.newConfig()
        def keyRight(self):
                ConfigListScreen.keyRight(self)
                self.newConfig()
+               
+       def saveAll(self):
+               if self.nim.isCompatible("DVB-S"):
+                       # reset connectedTo to all choices to properly store the default value
+                       choices = []
+                       nimlist = nimmanager.getNimListOfType("DVB-S", self.slotid)
+                       for id in nimlist:
+                               choices.append((str(id), nimmanager.getNimDescription(id)))
+                       self.nimConfig.connectedTo.setChoices(choices)
+               for x in self["config"].list:
+                       x[1].save()
+                       
+       def cancelConfirm(self, result):
+               if not result:
+                       return
 
 
+               for x in self["config"].list:
+                       x[1].cancel()
+               # we need to call saveAll to reset the connectedTo choices
+               self.saveAll()
+               self.close()
+                       
 class NimSelection(Screen):
        def __init__(self, session):
                Screen.__init__(self, session)
                
 class NimSelection(Screen):
        def __init__(self, session):
                Screen.__init__(self, session)
                
-               menu = [ ]
-               for x in nimmanager.nim_slots:
-                       menu.append((x.friendly_full_description, x))
-
-               self["nimlist"] = MenuList(menu)
+               self.list = [None] * nimmanager.getSlotCount()
+               self["nimlist"] = List(self.list)
+               self.updateList()
 
                self["actions"] = ActionMap(["OkCancelActions"],
                {
 
                self["actions"] = ActionMap(["OkCancelActions"],
                {
@@ -361,6 +384,47 @@ class NimSelection(Screen):
 
        def okbuttonClick(self):
                nim = self["nimlist"].getCurrent()
 
        def okbuttonClick(self):
                nim = self["nimlist"].getCurrent()
-               nim = nim and nim[1]
+               nim = nim and nim[3]
                if nim is not None and not nim.empty:
                if nim is not None and not nim.empty:
-                       self.session.open(NimSetup, nim.slot)
+                       self.session.openWithCallback(self.updateList, NimSetup, nim.slot)
+
+       def updateList(self):
+               self.list = [ ]
+               for x in nimmanager.nim_slots:
+                       slotid = x.slot
+                       nimConfig = nimmanager.getNimConfig(x.slot)
+                       text = nimConfig.configMode.value
+                       if x.isCompatible("DVB-S"):
+                               if nimConfig.configMode.value in ["loopthrough", "equal", "satposdepends"]:
+                                       text = { "loopthrough": _("loopthrough to"),
+                                                        "equal": _("equal to"),
+                                                        "satposdepends": _("second cable of motorized LNB") } [nimConfig.configMode.value]
+                                       text += + " " + _("Tuner") + " " + ["A", "B", "C", "D"][int(nimConfig.connectedTo.value)]
+                               elif nimConfig.configMode.value == "nothing":
+                                       text = _("nothing connected")
+                               elif nimConfig.configMode.value == "simple":
+                                       if nimConfig.diseqcMode.value in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
+                                               text = _("Sats") + ": " + nimmanager.getSatName(int(nimConfig.diseqcA.value))
+                                               if nimConfig.diseqcMode.value in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
+                                                       text += "," + nimmanager.getSatName(int(nimConfig.diseqcB.value))
+                                               if nimConfig.diseqcMode.value == "diseqc_a_b_c_d":
+                                                       text += "," + nimmanager.getSatName(int(nimConfig.diseqcC.value))
+                                                       text += "," + nimmanager.getSatName(int(nimConfig.diseqcD.value))
+                                       elif nimConfig.diseqcMode.value == "positioner":
+                                               text = _("Positioner") + ":"
+                                               if nimConfig.positionerMode.value == "usals":
+                                                       text += _("USALS")
+                                               elif nimConfig.positionerMode.value == "manual":
+                                                       text += _("manual")
+                                       else:   
+                                               text = _("simple")
+                               elif nimConfig.configMode.value == "advanced":
+                                       text = _("advanced")
+                       elif x.isCompatible("DVB-T") or x.isCompatible("DVB-C"):
+                               if nimConfig.configMode.value == "nothing":
+                                       text = _("nothing connected")
+                               elif nimConfig.configMode.value == "enabled":
+                                       text = _("enabled")
+                               
+                       self.list.append((slotid, x.friendly_full_description, text, x))
+               self["nimlist"].updateList(self.list)
\ No newline at end of file