copy lists, not list identities... should fix saving of non-default values
[enigma2.git] / lib / python / Components / config.py
index 5a4ed12e8c71845b009e567fc6d242c346bf7919..1645784b7c33e676b90b91677d81d4368762d3de 100644 (file)
@@ -260,8 +260,8 @@ class configSequence:
                        self.parent.value[blocknumber] = newvalue
                        self.markedPos += 1
                
                        self.parent.value[blocknumber] = newvalue
                        self.markedPos += 1
                
-               self.checkValues()                      
-               
+               self.checkValues()
+
                #FIXME: dont call when press left/right
                self.parent.change()    
 
                #FIXME: dont call when press left/right
                self.parent.change()    
 
@@ -479,16 +479,20 @@ class configElement:
                        return str(data.strip())
 
                elif control == configSequence:
                        return str(data.strip())
 
                elif control == configSequence:
+                       print self.vals
+                       print self.value
                        try:
                        try:
-                               value = ((len(data) * ("%d" + self.vals[0]))[0:-1]) % tuple(data)
+                               value = ""
+                               count = 0
+                               for i in data:
+                                       if value !="":
+                                               value += self.vals[0]
+                                       value += (("%0" + str(len(str(self.vals[1][count][1]))) + "d") % i)
+                                       count += 1
+                                       #value = ((len(data) * ("%d" + self.vals[0]))[0:-1]) % tuple(data)
                        except: 
                                value = str(data)       
                        except: 
                                value = str(data)       
-#                      just in case you don't understand the above, here an equivalent:
-#                      value = ""
-#                      for i in data:
-#                              if value !="":
-#                                      value += self.vals[0]
-#                              value += str(i)
+
                        return value
                elif control == configSatlist:
                        return str(self.vals[self.value][1]);
                        return value
                elif control == configSatlist:
                        return str(self.vals[self.value][1]);
@@ -504,10 +508,11 @@ class configElement:
 
                if value == "":
                        #print "value not found - using default"
 
                if value == "":
                        #print "value not found - using default"
-
                        if self.controlType == configSatlist:
                                self.value = self.getIndexbyEntry(self.defaultValue)
                        if self.controlType == configSatlist:
                                self.value = self.getIndexbyEntry(self.defaultValue)
-                       else:   
+                       elif self.controlType == configSequence:
+                               self.value = self.defaultValue[:]
+                       else:
                                self.value = self.defaultValue
 
                        self.save()             #add missing value to dict
                                self.value = self.defaultValue
 
                        self.save()             #add missing value to dict
@@ -540,7 +545,7 @@ class configElement:
        def reload(self):
                self.loadData()
        def save(self):
        def reload(self):
                self.loadData()
        def save(self):
-               if self.defaultValue != self.value or self.saveDefaults == True:
+               if (self.defaultValue != self.value) or (self.saveDefaults == True):
                        configfile.setKey(self.configPath, self.datatoFile(self.controlType,self.value))
 
 class configElement_nonSave(configElement):
                        configfile.setKey(self.configPath, self.datatoFile(self.controlType,self.value))
 
 class configElement_nonSave(configElement):