X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/da2832478f13de61ba213fe8fe8f20a21b442d4b..2e02d72e10207215592e4aeda8b1c5cf18f7115a:/lib/python/Components/Sources/List.py diff --git a/lib/python/Components/Sources/List.py b/lib/python/Components/Sources/List.py index 82504401..26c68ab5 100644 --- a/lib/python/Components/Sources/List.py +++ b/lib/python/Components/Sources/List.py @@ -16,6 +16,8 @@ to generate HTML.""" self.item_height = item_height self.fonts = fonts self.disable_callbacks = False + self.enableWrapAround = enableWrapAround + self.__style = "default" # style might be an optional string which can be used to define different visualisations in the skin def setList(self, list): self.__list = list @@ -26,6 +28,9 @@ to generate HTML.""" def entry_changed(self, index): if not self.disable_callbacks: self.downstream_elements.entry_changed(self, index) + + def count(self): + return len(self.__list) def selectionChanged(self, index): if self.disable_callbacks: @@ -43,6 +48,7 @@ to generate HTML.""" def setIndex(self, index): if self.master is not None: self.master.index = index + self.selectionChanged(index) @cached def getIndex(self): @@ -54,18 +60,38 @@ 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 + self.setIndex(self.index) + + def selectPrevious(self): + if self.getIndex() - 1 < 0: + if self.enableWrapAround: + self.index = self.count() - 1 + else: + self.index -= 1 + self.setIndex(self.index) + + @cached + def getStyle(self): + return self.__style + + def setStyle(self, style): + self.__style = style + self.changed((self.CHANGED_SPECIFIC, "style")) + + style = property(getStyle, setStyle) def updateList(self, list): """Changes the list without changing the selection or emitting changed Events""" assert len(list) == len(self.__list) - print "get old index" old_index = self.index - print "disable callback" self.disable_callbacks = True - print "set list" self.list = list - print "set index" self.index = old_index - print "reenable callbacks" self.disable_callbacks = False - print "done"