reload setuplist on usage level change
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 24 Oct 2007 13:34:01 +0000 (13:34 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 24 Oct 2007 13:34:01 +0000 (13:34 +0000)
lib/python/Screens/Setup.py

index 2452eef90bb3cfd53ad93893160a77103a561ac1..1f262e32139ae207f1c380e102df2cce84f523a5 100644 (file)
@@ -55,28 +55,36 @@ class Setup(ConfigListScreen, Screen):
 
        ALLOW_SUSPEND = True
 
-       def __init__(self, session, setup):
-               Screen.__init__(self, session)
+       def removeNotifier(self):
+               config.usage.setup_level.notifiers.remove(self.levelChanged)
 
+       def levelChanged(self, configElement):
+               list = []
+               self.refill(list)
+               self["config"].setList(list)
+
+       def refill(self, list):
                xmldata = setupdom.childNodes[0]
-               
                entries = xmldata.childNodes
-
-               self.onChangedEntry = [ ]
-               list = []
-                               
                for x in entries:             #walk through the actual nodelist
                        if x.nodeType != xml.dom.minidom.Element.nodeType:
                                continue
                        elif x.tagName == 'setup':
-                               if x.getAttribute("key") != setup:
+                               if x.getAttribute("key") != self.setup:
                                        continue
                                self.addItems(list, x.childNodes);
-                               myTitle = x.getAttribute("title").encode("UTF-8")
+                               self.setup_title = x.getAttribute("title").encode("UTF-8")
+
+       def __init__(self, session, setup):
+               Screen.__init__(self, session)
+
+               self.onChangedEntry = [ ]
+
+               self.setup = setup
+               list = []
+               self.refill(list)
 
                #check for list.entries > 0 else self.close
-               
-               self.setup_title = myTitle
                self["title"] = Label(_(self.setup_title))
 
                self["oktext"] = Label(_("OK"))
@@ -115,6 +123,10 @@ class Setup(ConfigListScreen, Screen):
                        elif x.tagName == 'item':
                                item_level = int(x.getAttribute("level") or "0")
 
+                               if not self.levelChanged in config.usage.setup_level.notifiers:
+                                       config.usage.setup_level.notifiers.append(self.levelChanged)
+                                       self.onClose.append(self.removeNotifier)
+
                                if item_level > config.usage.setup_level.index:
                                        continue