add nimsetup
[enigma2.git] / lib / python / Screens / Satconfig.py
index 75e5e89..02473af 100644 (file)
@@ -2,52 +2,98 @@ from Screen import Screen
 from Components.ActionMap import ActionMap
 from Components.ConfigList import ConfigList
 from Components.config import *
+from Components.MenuList import MenuList
+from Components.NimManager import nimmanager
 
-class setupSelection:
-       def __init__(self, parent):
-               self.parent = parent
-
-       def handleKey(self, key):
-               if key == config.key["prevElement"]:
-                       self.parent.value = self.parent.value - 1
-               if key == config.key["nextElement"]:
-                       self.parent.value = self.parent.value + 1
-
-       def __call__(self, selected):     #needed by configlist
-               print "value" + str(self.parent.value)
-               return ("text", self.parent.vals[self.parent.value])
-
-class setupElement:
-       def __init__(self, configPath, control, defaultValue, vals):
-               self.configPath = configPath
-               self.defaultValue = defaultValue
-               self.controlType = control
-               self.vals = vals
-               self.notifierList = [ ]
-               self.enabled = True
-               self.value = self.defaultValue
-
-class Satconfig(Screen):
+class NimSetup(Screen):
+       def createSimpleSetup(self, nim, list, mode):
+               print "request for diseqcmode:" + str(mode)
+               
+               b = config.Nims[nim.slotid].diseqcA
+               item = b.controlType(b)
+               if mode == 0:
+                       list.append( ("Satellite", item) )
+               else:
+                       list.append( ("Port A", item) )
+               
+               if mode >= 1:
+                       b = config.Nims[nim.slotid].diseqcB
+                       item = b.controlType(b)
+                       list.append( ("Port B", item) )
+                       if mode >= 3:
+                               b = config.Nims[nim.slotid].diseqcC
+                               item = b.controlType(b)
+                               list.append( ("Port C", item) )
+
+                               b = config.Nims[nim.slotid].diseqcD
+                               item = b.controlType(b)
+                               list.append( ("Port D", item) )
+                               
+       def createSetup(self):
+               print "createSetup"
+               self.list = [ ]
+               
+               b = config.Nims[self.nim.slotid].configMode
+               item = b.controlType(b)
+               self.list.append( ("Configmode", item) )
+               
+               if b.value == 0:                        #simple setup
+                       b = config.Nims[self.nim.slotid].diseqcMode
+                       item = b.controlType(b)
+                       self.list.append( ("Diseqcmode", item) )
+               
+                       self.createSimpleSetup(self.nim, self.list, b.value)
+               else:   
+                       print "FIXME: implement advanced mode"
+
+               #???
+               self["config"].list = self.list
+               self["config"].l.setList(self.list)
+               
+       def newConfig(self):    
+               if self["config"].getCurrent()[0] == "Diseqcmode":
+                       self.createSetup()
+               if self["config"].getCurrent()[0] == "Configmode":
+                       self.createSetup()
+               
        def keyLeft(self):
-               if (self["config"].getCurrent()[1].parent.enabled == True):
-                       self["config"].handleKey(config.key["prevElement"])
+               self["config"].handleKey(config.key["prevElement"])
+               self.newConfig()
+
        def keyRight(self):
-               if (self["config"].getCurrent()[1].parent.enabled == True):
-                       self["config"].handleKey(config.key["nextElement"])
+               self["config"].handleKey(config.key["nextElement"])
+               self.newConfig()
 
-       def __init__(self, session):
+       def __init__(self, session, nim):
                Screen.__init__(self, session)
+               self.nim = nim
 
                self["actions"] = ActionMap(["SetupActions"],
-                       {
-                               "cancel": self.close,
-                               #"ok": self.close,
-                               "left": self.keyLeft,
-                               "right": self.keyRight,
-                       })
-
-               blasel = setupElement("blub", setupSelection, 1, ("A", "B"))
-               item = blasel.controlType(blasel)
-               list = []
-               list.append( ("Tuner-Slot",item) );
-               self["config"] = ConfigList(list)
+               {
+                       "ok": self.close,
+                       "cancel": self.close,
+                       "left": self.keyLeft,
+                       "right": self.keyRight
+               }, -1)
+
+               self.list = [ ]
+               self["config"] = ConfigList(self.list)
+               
+               self.createSetup()
+
+class NimSelection(Screen):
+       def __init__(self, session):
+               Screen.__init__(self, session)
+
+               self["nimlist"] = MenuList(nimmanager.nimList())
+
+               self["actions"] = ActionMap(["OkCancelActions"],
+               {
+                       "ok": self.okbuttonClick ,
+                       "cancel": self.close
+               }, -1)
+
+       def okbuttonClick(self):
+               selection = self["nimlist"].getCurrent()
+               self.session.open(NimSetup, selection[1])
+               pass