- add selectNext/selectPrevious to sources.List
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 24 Jan 2008 21:47:38 +0000 (21:47 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 24 Jan 2008 21:47:38 +0000 (21:47 +0000)
- fix wizard up/down for configList

lib/python/Components/Sources/List.py
lib/python/Screens/Wizard.py

index 71be080..0480dd6 100644 (file)
@@ -16,6 +16,7 @@ to generate HTML."""
                self.item_height = item_height
                self.fonts = fonts
                self.disable_callbacks = False
+               self.enableWrapAround = enableWrapAround
 
        def setList(self, list):
                self.__list = list
@@ -57,6 +58,20 @@ to generate HTML."""
        setCurrentIndex = setIndex
 
        index = property(getIndex, setIndex)
+       
+       def selectNext(self):
+               if self.getIndex() + 1 >= self.count():
+                       if self.enableWrapAround:
+                               self.index = 0
+               else:
+                       self.index += 1
+
+       def selectPrevious(self):
+               if self.getIndex() - 1 < 0:
+                       if self.enableWrapAround:
+                               self.index = self.count() - 1
+               else:
+                       self.index -= 1
 
        def updateList(self, list):
                """Changes the list without changing the selection or emitting changed Events"""
index 8b90e4c..2f76e3b 100644 (file)
@@ -183,8 +183,8 @@ class Wizard(Screen, HelpableScreen):
                        "back": self.back,
                        "left": self.left,
                        "right": self.right,
-                       #"up": self.up,
-                       #"down": self.down,
+                       "up": self.up,
+                       "down": self.down,
                        "1": self.keyNumberGlobal,
                        "2": self.keyNumberGlobal,
                        "3": self.keyNumberGlobal,
@@ -287,7 +287,7 @@ class Wizard(Screen, HelpableScreen):
                if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None):
                                self["config"].instance.moveSelection(self["config"].instance.moveUp)
                elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
-                       self["list"].instance.moveSelection(self["list"].instance.moveUp)
+                       self["list"].selectPrevious()
                        if self.wizard[self.currStep].has_key("onselect"):
                                self.selection = self.wizard[self.currStep]["evaluatedlist"][self["list"].l.getCurrentSelectionIndex()][1]
                                exec("self." + self.wizard[self.currStep]["onselect"] + "()")
@@ -299,10 +299,7 @@ class Wizard(Screen, HelpableScreen):
                        self["config"].instance.moveSelection(self["config"].instance.moveDown)
                elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
                        #self["list"].instance.moveSelection(self["list"].instance.moveDown)
-                       if self["list"].index + 1 >= self["list"].count():
-                               self["list"].index = 0
-                       else:
-                               self["list"].index += 1
+                       self["list"].selectNext()
                        if self.wizard[self.currStep].has_key("onselect"):
                                print "current:", self["list"].current
                                #self.selection = self.wizard[self.currStep]["evaluatedlist"][self["list"].l.getCurrentSelectionIndex()][1]
@@ -400,6 +397,8 @@ class Wizard(Screen, HelpableScreen):
                                self.wizard[self.currStep]["evaluatedlist"] = self.list
                                self["list"].list = self.list
                                self["list"].index = 0
+                       else:
+                               self["list"].hide()
        
                        if self.showConfig:
                                self["config"].instance.setZPosition(1)
@@ -419,6 +418,8 @@ class Wizard(Screen, HelpableScreen):
                                                self.configInstance["config"] = self["config"]
                                else:
                                        self["config"].l.setList([])
+                       else:
+                               self["config"].hide()
                else: # condition false
                                self.currStep += 1
                                self.updateValues()