remove onSelectionChanged callbacks before deleting the configInstance["config"]...
[enigma2.git] / lib / python / Screens / Wizard.py
index ab1f188b21430b2da4056623b261bb7e2840835a..9f87ee31d4591fb28ef0c19718d8fc62edcf422d 100644 (file)
@@ -3,7 +3,7 @@ from Screen import Screen
 import string
 
 from Screens.HelpMenu import HelpableScreen
 import string
 
 from Screens.HelpMenu import HelpableScreen
-from Components.config import config, KEY_LEFT, KEY_RIGHT
+from Components.config import config, KEY_LEFT, KEY_RIGHT, KEY_DELETE, KEY_BACKSPACE
 from Components.Label import Label
 from Components.Slider import Slider
 from Components.ActionMap import NumberActionMap
 from Components.Label import Label
 from Components.Slider import Slider
 from Components.ActionMap import NumberActionMap
@@ -45,7 +45,7 @@ class WizardSummary(Screen):
        def setText(self, text):
                self["text"].setText(text)
 
        def setText(self, text):
                self["text"].setText(text)
 
-class Wizard(Screen, HelpableScreen):
+class Wizard(Screen):
        def createSummary(self):
                        print "WizardCreateSummary"
                        return WizardSummary
        def createSummary(self):
                        print "WizardCreateSummary"
                        return WizardSummary
@@ -150,7 +150,6 @@ class Wizard(Screen, HelpableScreen):
 
        def __init__(self, session, showSteps = True, showStepSlider = True, showList = True, showConfig = True):
                Screen.__init__(self, session)
 
        def __init__(self, session, showSteps = True, showStepSlider = True, showList = True, showConfig = True):
                Screen.__init__(self, session)
-               HelpableScreen.__init__(self)
 
                self.stepHistory = []
 
 
                self.stepHistory = []
 
@@ -181,7 +180,7 @@ class Wizard(Screen, HelpableScreen):
                self["text"] = Label()
 
                if showConfig:
                self["text"] = Label()
 
                if showConfig:
-                       self["config"] = ConfigList([])
+                       self["config"] = ConfigList([], session = session)
 
                if self.showSteps:
                        self["step"] = Label()
 
                if self.showSteps:
                        self["step"] = Label()
@@ -203,7 +202,7 @@ class Wizard(Screen, HelpableScreen):
                
                self.disableKeys = False
                
                
                self.disableKeys = False
                
-               self["actions"] = NumberActionMap(["WizardActions", "NumberActions", "ColorActions"],
+               self["actions"] = NumberActionMap(["WizardActions", "NumberActions", "ColorActions", "SetupActions"],
                {
                        "ok": self.ok,
                        "back": self.back,
                {
                        "ok": self.ok,
                        "back": self.back,
@@ -215,6 +214,8 @@ class Wizard(Screen, HelpableScreen):
                        "green": self.green,
                        "yellow": self.yellow,
                        "blue":self.blue,
                        "green": self.green,
                        "yellow": self.yellow,
                        "blue":self.blue,
+                       "deleteBackward": self.deleteBackward,
+                       "deleteForward": self.deleteForward,
                        "1": self.keyNumberGlobal,
                        "2": self.keyNumberGlobal,
                        "3": self.keyNumberGlobal,
                        "1": self.keyNumberGlobal,
                        "2": self.keyNumberGlobal,
                        "3": self.keyNumberGlobal,
@@ -243,6 +244,22 @@ class Wizard(Screen, HelpableScreen):
                print "blue"
                pass
        
                print "blue"
                pass
        
+       def deleteForward(self):
+               self.resetCounter()
+               if (self.wizard[self.currStep]["config"]["screen"] != None):
+                       self.configInstance.keyDelete()
+               elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
+                       self["config"].handleKey(KEY_DELETE)
+               print "deleteForward"
+
+       def deleteBackward(self):
+               self.resetCounter()
+               if (self.wizard[self.currStep]["config"]["screen"] != None):
+                       self.configInstance.keyBackspace()
+               elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
+                       self["config"].handleKey(KEY_BACKSPACE)
+               print "deleteBackward"
+       
        def setLCDTextCallback(self, callback):
                self.lcdCallbacks.append(callback)
 
        def setLCDTextCallback(self, callback):
                self.lcdCallbacks.append(callback)
 
@@ -285,7 +302,7 @@ class Wizard(Screen, HelpableScreen):
                if self.showConfig:
                        if self.wizard[currStep]["config"]["type"] == "dynamic":
                                eval("self." + self.wizard[currStep]["config"]["evaluation"])()
                if self.showConfig:
                        if self.wizard[currStep]["config"]["type"] == "dynamic":
                                eval("self." + self.wizard[currStep]["config"]["evaluation"])()
-                       
+
                if self.showList:
                        if (len(self.wizard[currStep]["evaluatedlist"]) > 0):
                                print "current:", self["list"].current
                if self.showList:
                        if (len(self.wizard[currStep]["evaluatedlist"]) > 0):
                                print "current:", self["list"].current
@@ -384,7 +401,7 @@ class Wizard(Screen, HelpableScreen):
                self.resetCounter()
                
                if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None):
                self.resetCounter()
                
                if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None):
-                               self["config"].instance.moveSelection(self["config"].instance.moveUp)
+                       self["config"].instance.moveSelection(self["config"].instance.moveUp)
                elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
                        if self.wizard[self.currStep].has_key("onselect"):
                                self.selection = self["list"].current[-1]
                elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
                        if self.wizard[self.currStep].has_key("onselect"):
                                self.selection = self["list"].current[-1]
@@ -423,6 +440,8 @@ class Wizard(Screen, HelpableScreen):
                self.timeoutTimer.stop()
                
                if self.configInstance is not None:
                self.timeoutTimer.stop()
                
                if self.configInstance is not None:
+                       # remove callbacks
+                       self.configInstance["config"].onSelectionChanged = []
                        del self.configInstance["config"]
                        self.configInstance.doClose()
                        self.configInstance = None
                        del self.configInstance["config"]
                        self.configInstance.doClose()
                        self.configInstance = None
@@ -504,7 +523,9 @@ class Wizard(Screen, HelpableScreen):
                                                        self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"], eval(self.wizard[self.currStep]["config"]["args"]))
                                                self["config"].l.setList(self.configInstance["config"].list)
                                                self.configInstance["config"].destroy()
                                                        self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"], eval(self.wizard[self.currStep]["config"]["args"]))
                                                self["config"].l.setList(self.configInstance["config"].list)
                                                self.configInstance["config"].destroy()
+                                               print "clearConfigList", self.configInstance["config"], self["config"] 
                                                self.configInstance["config"] = self["config"]
                                                self.configInstance["config"] = self["config"]
+                                               print "clearConfigList", self.configInstance["config"], self["config"]
                                else:
                                        self["config"].l.setList([])
                        else:
                                else:
                                        self["config"].l.setList([])
                        else: