loading and saving the cable transponders to lamedb works now
[enigma2.git] / lib / python / Screens / Menu.py
index 9c41c16595f6ce8762165c4243c8b3e62a5dab59..bba3628239c381f5f64c6bfe539533e8950ed549 100644 (file)
@@ -5,6 +5,7 @@ from Components.Header import Header
 from Components.Button import Button
 from Components.Label import Label
 from Components.ProgressBar import ProgressBar
+from Components.config import configfile
 
 from Tools.Directories import resolveFilename, SCOPE_SKIN
 
@@ -89,7 +90,6 @@ class Menu(Screen):
                #        string (as we want to reference 
                #        stuff which is just imported)
                # FIXME. somehow
-               print arg
                if arg[0] != "":
                        exec "from " + arg[0] + " import *"
                        
@@ -102,15 +102,27 @@ class Menu(Screen):
                self.session.open(*dialog)
 
        def openSetup(self, dialog):
-               self.session.open(Setup, dialog)
+               self.session.openWithCallback(self.menuClosed, Setup, dialog)
 
        def addMenu(self, destList, node):
                MenuTitle = _(getValbyAttr(node, "text"))
                if MenuTitle != "":                                                                                                                                     #check for title
-                       a = boundFunction(self.session.open, Menu, node, node.childNodes)
+                       x = getValbyAttr(node, "flushConfigOnClose")
+                       if x == "1":
+                               a = boundFunction(self.session.openWithCallback, self.menuClosedWithConfigFlush, Menu, node, node.childNodes)
+                       else:
+                               a = boundFunction(self.session.openWithCallback, self.menuClosed, Menu, node, node.childNodes)
                        #TODO add check if !empty(node.childNodes)
                        destList.append((MenuTitle, a))
-               
+
+       def menuClosedWithConfigFlush(self, *res):
+               configfile.save()
+               self.menuClosed(*res)
+
+       def menuClosed(self, *res):
+               if len(res) and res[0]:
+                       self.close(True)
+
        def addItem(self, destList, node):
                ItemText = _(getValbyAttr(node, "text"))
                if ItemText != "":                                                                                                                                      #check for name
@@ -177,8 +189,8 @@ class Menu(Screen):
                self["actions"] = ActionMap(["OkCancelActions", "MenuActions"], 
                        {
                                "ok": self.okbuttonClick,
-                               "cancel": self.close,
-                               "menu": self.close
+                               "cancel": self.closeNonRecursive,
+                               "menu": self.closeRecursive
                        })
                
                a = getValbyAttr(parent, "title")
@@ -186,6 +198,12 @@ class Menu(Screen):
                        a = _(getValbyAttr(parent, "text"))
                self["title"] = Header(a)
 
+       def closeNonRecursive(self):
+               self.close(False)
+
+       def closeRecursive(self):
+               self.close(True)
+
 class MainMenu(Menu):
        #add file load functions for the xml-file