From c06f79c0451ca844f89809058a2767a1a319b137 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Fri, 30 Dec 2005 07:22:59 +0000 Subject: [PATCH] configSelection is now saved to config file in a human readable style --- lib/python/Components/AVSwitch.py | 12 ++++----- lib/python/Components/Lcd.py | 10 +++---- lib/python/Components/Network.py | 2 +- lib/python/Components/NimManager.py | 10 +++---- lib/python/Components/RFmod.py | 6 ++--- lib/python/Components/RecordingConfig.py | 2 +- lib/python/Components/config.py | 34 ++++++++++++++++++++++-- 7 files changed, 53 insertions(+), 23 deletions(-) diff --git a/lib/python/Components/AVSwitch.py b/lib/python/Components/AVSwitch.py index 33ea6600..22d24dfc 100644 --- a/lib/python/Components/AVSwitch.py +++ b/lib/python/Components/AVSwitch.py @@ -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() diff --git a/lib/python/Components/Lcd.py b/lib/python/Components/Lcd.py index b9ba5606..77975f4d 100644 --- a/lib/python/Components/Lcd.py +++ b/lib/python/Components/Lcd.py @@ -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() diff --git a/lib/python/Components/Network.py b/lib/python/Components/Network.py index 365e15f0..590edefd 100644 --- a/lib/python/Components/Network.py +++ b/lib/python/Components/Network.py @@ -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")) diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 0452adbe..3e9b0427 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -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? diff --git a/lib/python/Components/RFmod.py b/lib/python/Components/RFmod.py index e061a170..98571819 100644 --- a/lib/python/Components/RFmod.py +++ b/lib/python/Components/RFmod.py @@ -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, ""); diff --git a/lib/python/Components/RecordingConfig.py b/lib/python/Components/RecordingConfig.py index cf65f747..99c15a66 100644 --- a/lib/python/Components/RecordingConfig.py +++ b/lib/python/Components/RecordingConfig.py @@ -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"))) ); diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index 3bbdde10..2b51d169 100644 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -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) -- 2.30.2