X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/dd6b0a6724db3e2533c5858beb49523f713fe8a7..e7a77b87eee22c35e93cbd42b329dc5165e29144:/lib/python/Components/config.py diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index 19fdefee..7137845f 100644 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -44,9 +44,6 @@ class configFile: keys.sort() for x in keys: wstr = x + "=" + self.configElements[x] + "\n" - - if wstr[len(wstr) - 1] != '\n': - wstr = wstr + "\n" fileHandle.write(wstr) @@ -58,10 +55,9 @@ class configSelection: def checkValues(self): if self.parent.value < 0: - self.parent.value = 0 - - if(self.parent.value >= (len(self.parent.vals) - 1)): - self.parent.value = len(self.parent.vals) - 1 + self.parent.value = len(self.parent.vals) - 1 + elif(self.parent.value > (len(self.parent.vals) - 1)): + self.parent.value = 0 def cancel(self): self.parent.reload() @@ -81,7 +77,7 @@ class configSelection: def __call__(self, selected): #needed by configlist self.checkValues() - return ("text", self.parent.vals[self.parent.value]) + return ("text", _(self.parent.vals[self.parent.value])) class configDateTime: def __init__(self, parent): @@ -297,6 +293,8 @@ class configText: def handleKey(self, key): #this will no change anything on the value itself #so we can handle it here in gui element + if key == config.key["delete"]: + self.parent.value = self.parent.value[0:self.markedPos] + self.parent.value[self.markedPos + 1:] if key == config.key["prevElement"]: self.textInput.nextKey() self.markedPos -= 1 @@ -333,6 +331,7 @@ class Config: self.key = { "choseElement": 0, "prevElement": 1, "nextElement": 2, + "delete": 3, "0": 10, "1": 11, "2": 12, @@ -345,6 +344,7 @@ class Config: "9": 19 } config = Config(); + configfile = configFile() class ConfigSlider: @@ -501,3 +501,9 @@ def getConfigListEntry(description, element): b = element item = b.controlType(b) return ((description, item)) + + +def configElementBoolean(name, default, texts=(_("Enable"), _("Disable"))): + return configElement(name, configSelection, default, texts) + +config.misc = ConfigSubsection()