fix for default ac3
[enigma2.git] / lib / python / Components / config.py
index b16b93e343fb65596a52606640eb9b0fa58331aa..0fd6e7327aaaafdc5951ee6936bd1988e8ed6752 100644 (file)
@@ -165,6 +165,13 @@ class ConfigSelection(ConfigElement):
        def getValue(self):
                return self._value
 
+       def setCurrentText(self, text):
+               i = self.choices.index(self.value)
+               del self.description[self.choices[i]]
+               self.choices[i] = text
+               self.description[text] = text
+               self._value = text
+
        value = property(getValue, setValue)
        
        def getIndex(self):
@@ -421,7 +428,7 @@ class ConfigClock(ConfigSequence):
                ConfigSequence.__init__(self, seperator = ":", limits = [(0,23),(0,59)], default = [t.tm_hour, t.tm_min])
 
 class ConfigInteger(ConfigSequence):
-       def __init__(self, default, limits):
+       def __init__(self, default, limits = (0, 10000000000)):
                ConfigSequence.__init__(self, seperator = ":", limits = [limits], default = default)
        
        # you need to override this to do input validation
@@ -796,7 +803,8 @@ class Config(ConfigSubsection):
 
                # we inherit from ConfigSubsection, so ...
                #object.__setattr__(self, "saved_value", tree["config"])
-               self.setSavedValue(tree["config"])
+               if "config" in tree:
+                       self.setSavedValue(tree["config"])
 
        def saveToFile(self, filename):
                f = open(filename, "w")
@@ -812,7 +820,7 @@ config = Config()
 config.misc = ConfigSubsection()
 
 class ConfigFile:
-       CONFIG_FILE = resolveFilename(SCOPE_CONFIG, "config2")
+       CONFIG_FILE = resolveFilename(SCOPE_CONFIG, "settings")
 
        def load(self):
                try:
@@ -824,8 +832,23 @@ class ConfigFile:
                config.save()
                config.saveToFile(self.CONFIG_FILE)
        
+       def __resolveValue(self, pickles, cmap):
+               if cmap.has_key(pickles[0]):
+                       if len(pickles) > 1:
+                               return self.__resolveValue(pickles[1:], cmap[pickles[0]].content.items)
+                       else:
+                               return str(cmap[pickles[0]].value)
+               return None
+       
        def getResolvedKey(self, key):
-               return None # FIXME
+               names = key.split('.')
+               if len(names) > 1:
+                       if names[0] == "config":
+                               ret=self.__resolveValue(names[1:], config.content.items)
+                               if ret and len(ret):
+                                       return ret
+               print "getResolvedKey", key, "failed !! (Typo??)"
+               return ""
 
 def NoSave(element):
        element.disableSave()