you can now delete characters in the timerentry description with the mute-key
[enigma2.git] / lib / python / Components / config.py
index 19fdefeee5a52311d0c8bbdd5f3ad11f548ff2e5..7137845f7feb9cab8f38c793c3550de8af59d8ef 100644 (file)
@@ -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()