timezone selection works now. tzset doesn't exist, so we cannot activate the timezone...
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 17 Nov 2005 16:12:16 +0000 (16:12 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 17 Nov 2005 16:12:16 +0000 (16:12 +0000)
lib/python/Components/SetupDevices.py
lib/python/Components/Timezones.py

index 003bba5..612bb8c 100644 (file)
@@ -8,8 +8,13 @@ from config import configText
 from Components.Timezones import timezones
 
 def InitSetupDevices():
 from Components.Timezones import timezones
 
 def InitSetupDevices():
+       
+       def timezoneNotifier(configElement):
+               timezones.activateTimezone(configElement.value)
+               
        config.timezone = ConfigSubsection();
        config.timezone = ConfigSubsection();
-       config.timezone.val = configElement("config.timezone.val", configSelection, 1, ("GMT", "GMT+1", "GMT+2", "GMT+3", "GMT+4", "GMT+5", "GMT+6", "GMT+7", "GMT+8", "GMT+9") );
+       config.timezone.val = configElement("config.timezone.val", configSelection, timezones.getDefaultTimezone(), timezones.getTimezoneList());
+       config.timezone.val.addNotifier(timezoneNotifier)
 
        config.rc = ConfigSubsection();
        config.rc.map = configElement("config.rc.map", configSelection, 0, ("Default", "Classic") );
 
        config.rc = ConfigSubsection();
        config.rc.map = configElement("config.rc.map", configSelection, 0, ("Default", "Classic") );
index 90b227f..2eec17a 100644 (file)
@@ -1,6 +1,9 @@
 from xml.sax import make_parser
 from xml.sax.handler import ContentHandler
 
 from xml.sax import make_parser
 from xml.sax.handler import ContentHandler
 
+import os
+import time
+
 class Timezones:
        class parseTimezones(ContentHandler):
                def __init__(self, timezones):
 class Timezones:
        class parseTimezones(ContentHandler):
                def __init__(self, timezones):
@@ -8,18 +11,11 @@ class Timezones:
                        self.timezones = timezones
        
                def startElement(self, name, attrs):
                        self.timezones = timezones
        
                def startElement(self, name, attrs):
-                       print "Name: " + str(name)
                        if (name == "zone"):
                        if (name == "zone"):
-                               self.timezones[attrs.get('name',"")] = attrs.get('zone',"")
-                               #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
-                               #tpos = attrs.get('position',"")
-                               #tname = attrs.get('name',"")
-                               #self.satellites[tpos] = tname
-                               #self.satList.append( (tname, tpos) )
-                               #self.parsedSat = int(tpos)
+                               self.timezones.append((attrs.get('name',""), attrs.get('zone',"")))
        
        def __init__(self):
        
        def __init__(self):
-               self.timezones = {}
+               self.timezones = []
                
                self.readTimezonesFromFile()
 
                
                self.readTimezonesFromFile()
 
@@ -29,5 +25,19 @@ class Timezones:
                parser.setContentHandler(timezonesHandler)
                parser.parse('/etc/timezone.xml')
                
                parser.setContentHandler(timezonesHandler)
                parser.parse('/etc/timezone.xml')
                
+       def activateTimezone(self, index):
+               os.environ['TZ'] = self.timezones[index][1]
+               # FIXME we need a tzset
+               #time.tzset()
+               
+       def getTimezoneList(self):
+               list = []
+               for x in self.timezones:
+                       list.append(str(x[0]))
+               return list
+       
+       def getDefaultTimezone(self):
+               # TODO return something more useful - depending on country-settings?
+               return 27
 
 timezones = Timezones()
 
 timezones = Timezones()