configSelection is now saved to config file in a human readable style
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Fri, 30 Dec 2005 07:22:59 +0000 (07:22 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Fri, 30 Dec 2005 07:22:59 +0000 (07:22 +0000)
lib/python/Components/AVSwitch.py
lib/python/Components/Lcd.py
lib/python/Components/Network.py
lib/python/Components/NimManager.py
lib/python/Components/RFmod.py
lib/python/Components/RecordingConfig.py
lib/python/Components/config.py

index 33ea660..22d24df 100644 (file)
@@ -26,13 +26,13 @@ class AVSwitch:
 
 def InitAVSwitch():
        config.av = ConfigSubsection();
-       config.av.colorformat = configElement("config.av.colorformat", configSelection, 1, ("CVBS", "RGB", "S-Video") );
-       config.av.aspectratio = configElement("config.av.aspectratio", configSelection, 0, ("4:3 Letterbox", "4:3 PanScan", "16:9", "16:9 always") );
+       config.av.colorformat = configElement("config.av.colorformat", configSelection, 1, (("cvbs", _("CVBS")), ("rgb", _("RGB")), ("svideo", _("S-Video")) ));
+       config.av.aspectratio = configElement("config.av.aspectratio", configSelection, 0, (("4_3_letterbox", _("4:3 Letterbox")), ("4_3_panscan", _("4:3 PanScan")), ("16_9", _("16:9")), ("16_9_always", _("16:9 always"))) );
        #config.av.tvsystem = configElement("config.av.tvsystem", configSelection, 0, ("PAL", "PAL + PAL60", "Multi", "NTSC") );
-       config.av.tvsystem = configElement("config.av.tvsystem", configSelection, 0, ("PAL", "NTSC") );
-       config.av.wss = configElement("config.av.wss", configSelection, 0, ("Enable", "Disable") );
-       config.av.defaultac3 = configElement("config.av.defaultac3", configSelection, 1, ("Enable", "Disable") );
-       config.av.vcrswitch = configElement("config.av.vcrswitch", configSelection, 1, ("Enable", "Disable") );
+       config.av.tvsystem = configElement("config.av.tvsystem", configSelection, 0, (("pal", _("PAL")), ("ntsc", _("NTSC"))) );
+       config.av.wss = configElement("config.av.wss", configSelection, 0, (("enable", _("Enable")), ("disable", _("Disable"))) );
+       config.av.defaultac3 = configElement("config.av.defaultac3", configSelection, 1, (("enable", _("Enable")), ("disable", _("Disable"))));
+       config.av.vcrswitch = configElement("config.av.vcrswitch", configSelection, 1, (("enable", _("Enable")), ("disable", _("Disable"))));
 
        iAVSwitch = AVSwitch()
 
index b9ba560..77975f4 100644 (file)
@@ -21,15 +21,15 @@ class LCD:
        def setInverted(self, value):
                if value:
                        value = 255
-               eDBoxLCD.getInstance().setInverted(value)
+               eDBoxLCD.getInstance().setInverted(1 - value)
                pass
 
 def InitLcd():
        config.lcd = ConfigSubsection();
-       config.lcd.bright = configElement("config.lcd.bright", ConfigSlider, 10, "");
-       config.lcd.contrast = configElement("config.lcd.contrast", ConfigSlider, 10, "");
-       config.lcd.standby = configElement("config.lcd.standby", ConfigSlider, 0, "");
-       config.lcd.invert = configElement("config.lcd.invert", configSelection, 0, (_("Disable"), _("Enable")) );
+       config.lcd.bright = configElement("config.lcd.bright", ConfigSlider, 10, "")
+       config.lcd.contrast = configElement("config.lcd.contrast", ConfigSlider, 10, "")
+       config.lcd.standby = configElement("config.lcd.standby", ConfigSlider, 0, "")
+       config.lcd.invert = configElement("config.lcd.invert", configSelection, 0, (("enable", _("Enable")), ("disable", _("Disable"))))
 
        ilcd = LCD()
 
index 365e15f..590edef 100644 (file)
@@ -143,7 +143,7 @@ def InitNetwork():
 
                
        config.network = ConfigSubsection()
-       config.network.dhcp = configElement_nonSave("config.network.dhcp", configSelection, 1, (_("no"), _("yes")))
+       config.network.dhcp = configElement_nonSave("config.network.dhcp", configSelection, 1, (("no", _("no")), ("yes", _("yes"))))
        config.network.ip = configElement_nonSave("config.network.ip", configSequence, ip, configsequencearg.get("IP"))
        config.network.netmask = configElement_nonSave("config.network.netmask", configSequence, [255,255,255,0], configsequencearg.get("IP"))
        config.network.gateway = configElement_nonSave("config.network.gateway", configSequence, [192,168,1,3], configsequencearg.get("IP"))
index 0452adb..3e9b042 100644 (file)
@@ -408,7 +408,7 @@ def InitNimManager(nimmgr):
                nim = config.Nims[x]
                
                if slot.nimType == nimmgr.nimType["DVB-S"]:
-                       nim.configMode = configElement(cname + "configMode", configSelection, 0, (_("Simple"), _("Nothing connected"), _("Loopthrough to Socket A"))) # "Advanced"));
+                       nim.configMode = configElement(cname + "configMode", configSelection, 0, (("simple", _("Simple")), ("nothing", _("Nothing connected")), ("loopthrough", _("Loopthrough to Socket A")))) # "Advanced"));
                        
                        #important - check if just the 2nd one is LT only and the first one is DVB-S
                        if nim.configMode.value == 2: #linked
@@ -423,20 +423,20 @@ def InitNimManager(nimmgr):
                                                                nim.configMode.value = 0                #reset to simple
                                                                nim.configMode.save()
 
-                       nim.diseqcMode = configElement(cname + "diseqcMode", configSelection, 2, (_("Single"), _("Toneburst A/B"), _("DiSEqC A/B"), _("DiSEqC A/B/C/D"), _("Positioner")));
+                       nim.diseqcMode = configElement(cname + "diseqcMode", configSelection, 2, (("single", _("Single")), ("toneburst_a_b", _("Toneburst A/B")), ("diseqc_a_b", _("DiSEqC A/B")), ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")), ("positioner", _("Positioner"))));
                        nim.diseqcA = configElement(cname + "diseqcA", configSatlist, 192, nimmgr.satList);
                        nim.diseqcB = configElement(cname + "diseqcB", configSatlist, 130, nimmgr.satList);
                        nim.diseqcC = configElement(cname + "diseqcC", configSatlist, 0, nimmgr.satList);
                        nim.diseqcD = configElement(cname + "diseqcD", configSatlist, 0, nimmgr.satList);
-                       nim.positionerMode = configElement(cname + "positionerMode", configSelection, 0, (_("USALS"), _("manual")));
+                       nim.positionerMode = configElement(cname + "positionerMode", configSelection, 0, (("usals", _("USALS")), ("manual", _("manual"))));
                        nim.longitude = configElement(cname + "longitude", configSequence, [5,100], configsequencearg.get("FLOAT", [(0,90),(0,999)]));
                        nim.longitudeOrientation = configElement(cname + "longitudeOrientation", configSelection, 0, (_("East"), _("West")))
                        nim.latitude = configElement(cname + "latitude", configSequence, [50,767], configsequencearg.get("FLOAT", [(0,90),(0,999)]));
-                       nim.latitudeOrientation = configElement(cname + "latitudeOrientation", configSelection, 0, (_("North"), _("South")))
+                       nim.latitudeOrientation = configElement(cname + "latitudeOrientation", configSelection, 0, (("north", _("North")), ("south", _("South"))))
                        satNimList = nimmgr.getNimListOfType(nimmgr.nimType["DVB-S"], slot.slotid)
                        satNimListNames = []
                        for x in satNimList:
-                               satNimListNames.append(_("Slot ") + ("A", "B", "C", "D")[x] + ": " + nimmgr.getNimName(x))
+                               satNimListNames.append((("Slot_" + ("A", "B", "C", "D")[x] + "_" + nimmgr.getNimName(x)), _("Slot ") + ("A", "B", "C", "D")[x] + ": " + nimmgr.getNimName(x)))
                        nim.linkedTo = configElement(cname + "linkedTo", configSelection, 0, satNimListNames);
                        
                        #perhaps the instance of the slot is more useful?
index e061a17..9857181 100644 (file)
@@ -21,9 +21,9 @@ class RFmod:
 def InitRFmod():
 
        config.rfmod = ConfigSubsection();
-       config.rfmod.enable = configElement("config.rfmod.enable", configSelection, 1, ("Enable", "Disable") );
-       config.rfmod.test = configElement("config.rfmod.test", configSelection, 1, ("Enable", "Disable") );
-       config.rfmod.sound = configElement("config.rfmod.sound", configSelection, 0, ("Enable", "Disable") );
+       config.rfmod.enable = configElement("config.rfmod.enable", configSelection, 1, (("enable", _("Enable")), ("disable", _("Disable"))) );
+       config.rfmod.test = configElement("config.rfmod.test", configSelection, 1, (("enable", _("Enable")), ("disable", _("Disable"))) );
+       config.rfmod.sound = configElement("config.rfmod.sound", configSelection, 0, (("enable", _("Enable")), ("disable", _("Disable"))) );
        config.rfmod.soundcarrier = configElement("config.rfmod.soundcarrier", configSelection, 1, ("4.5 MHz", "5.5 MHz", "6.0 MHz", "6.5 MHz") );
        config.rfmod.channel = configElement("config.rfmod.channel", configSelection, 6, ("30", "31", "32", "33", "34", "35", "36", "37", "38", "39") );
        config.rfmod.finetune = configElement("config.rfmod.finetune", ConfigSlider, 5, "");
index cf65f74..99c15a6 100644 (file)
@@ -4,6 +4,6 @@ from enigma import *
 
 def InitRecordingConfig():
        config.recording = ConfigSubsection();
-       config.recording.asktozap = configElement("config.recording.asktozap", configSelection, 1, (_("yes"), _("no")) );
+       config.recording.asktozap = configElement("config.recording.asktozap", configSelection, 1, (("yes", _("yes")), ("no", _("no"))) );
 
 
index 3bbdde1..2b51d16 100644 (file)
@@ -78,8 +78,16 @@ class configSelection:
 
        def __call__(self, selected):                   #needed by configlist
                self.checkValues()
-               return ("text", _(self.parent.vals[self.parent.value]))
+               if isinstance(self.parent.vals[self.parent.value], str):
+                       returnValue = _(self.parent.vals[self.parent.value])
+               else:
+                       returnValue = _(self.parent.vals[self.parent.value][1])
 
+                       
+               print self.parent.vals[self.parent.value]
+               
+               return ("text", returnValue)
+               
 class configDateTime:
        def __init__(self, parent):
                self.parent = parent
@@ -417,7 +425,17 @@ class configElement:
                if control == ConfigSlider:
                        return int(data)
                elif control == configSelection:
-                       return int(data)
+                       try:
+                               return int(data)
+                       except:
+                               for x in data.split(":"):
+                                       if x[0] == "*":
+                                               count = 0
+                                               for y in self.vals:
+                                                       if y[0] == x[1:-1]:
+                                                               return count
+                                                       count += 1
+                               return self.defaultValue
                elif control == configDateTime:
                        return int(data)
                elif control == configText:
@@ -437,6 +455,18 @@ class configElement:
                if control == ConfigSlider:
                        return str(data)
                elif control == configSelection:
+                       if isinstance(self.vals[data], str):
+                               return str(data)
+                       else:
+                               confList = []
+                               count = 0
+                               for x in self.vals:
+                                       if count == data:
+                                               confList.append("*" + str(x[0] + "*"))
+                                       else:
+                                               confList.append(x[0])
+                                       count += 1
+                               return ":".join(confList)
                        return str(data)
                elif control == configDateTime:
                        return str(data)