Merge branch 'bug_736_fix_rotor_with_unicable_lnb'
[enigma2.git] / lib / python / Components / Renderer / Listbox.py
old mode 100644 (file)
new mode 100755 (executable)
index d784b61..716fe44
@@ -1,7 +1,4 @@
-from Components.VariableText import VariableText
 from Renderer import Renderer
 from Renderer import Renderer
-from Tools.Event import Event
-
 from enigma import eListbox
 
 # the listbox renderer is the listbox, but no listbox content.
 from enigma import eListbox
 
 # the listbox renderer is the listbox, but no listbox content.
@@ -22,6 +19,7 @@ class Listbox(Renderer, object):
                self.__content = None
                self.__wrap_around = False
                self.__selection_enabled = True
                self.__content = None
                self.__wrap_around = False
                self.__selection_enabled = True
+               self.__scrollbarMode = "showOnDemand"
 
        GUI_WIDGET = eListbox
 
 
        GUI_WIDGET = eListbox
 
@@ -41,12 +39,17 @@ class Listbox(Renderer, object):
                instance.selectionChanged.get().append(self.selectionChanged)
                self.wrap_around = self.wrap_around # trigger
                self.selection_enabled = self.selection_enabled # trigger
                instance.selectionChanged.get().append(self.selectionChanged)
                self.wrap_around = self.wrap_around # trigger
                self.selection_enabled = self.selection_enabled # trigger
+               self.scrollbarMode = self.scrollbarMode # trigger
+
+       def preWidgetRemove(self, instance):
+               instance.setContent(None)
+               instance.selectionChanged.get().remove(self.selectionChanged)
 
        def setWrapAround(self, wrap_around):
                self.__wrap_around = wrap_around
                if self.instance is not None:
                        self.instance.setWrapAround(self.__wrap_around)
 
        def setWrapAround(self, wrap_around):
                self.__wrap_around = wrap_around
                if self.instance is not None:
                        self.instance.setWrapAround(self.__wrap_around)
-       
+
        wrap_around = property(lambda self: self.__wrap_around, setWrapAround)
 
        def selectionChanged(self):
        wrap_around = property(lambda self: self.__wrap_around, setWrapAround)
 
        def selectionChanged(self):
@@ -54,16 +57,16 @@ class Listbox(Renderer, object):
 
        def getIndex(self):
                if self.instance is None:
 
        def getIndex(self):
                if self.instance is None:
-                       return None
+                       return 0
                return self.instance.getCurrentIndex()
                return self.instance.getCurrentIndex()
-               
+
        def moveToIndex(self, index):
                if self.instance is None:
                        return
                self.instance.moveSelectionTo(index)
 
        index = property(getIndex, moveToIndex)
        def moveToIndex(self, index):
                if self.instance is None:
                        return
                self.instance.moveSelectionTo(index)
 
        index = property(getIndex, moveToIndex)
-       
+
        def move(self, direction):
                if self.instance is not None:
                        self.instance.moveSelection(direction)
        def move(self, direction):
                if self.instance is not None:
                        self.instance.moveSelection(direction)
@@ -75,5 +78,26 @@ class Listbox(Renderer, object):
 
        selection_enabled = property(lambda self: self.__selection_enabled, setSelectionEnabled)
 
 
        selection_enabled = property(lambda self: self.__selection_enabled, setSelectionEnabled)
 
+       def setScrollbarMode(self, mode):
+               self.__scrollbarMode = mode
+               if self.instance is not None:
+                       self.instance.setScrollbarMode(int(
+                               { "showOnDemand": 0,
+                                 "showAlways": 1,
+                                 "showNever": 2,
+                               }[mode]))
+
+       scrollbarMode = property(lambda self: self.__scrollbarMode, setScrollbarMode)
+       
        def changed(self, what):
        def changed(self, what):
+               if hasattr(self.source, "selectionEnabled"):
+                       self.selection_enabled = self.source.selectionEnabled
+               if hasattr(self.source, "scrollbarMode"):
+                       self.scrollbarMode = self.source.scrollbarMode
+               if len(what) > 1 and isinstance(what[1], str) and what[1] == "style":
+                       return
                self.content = self.source.content
                self.content = self.source.content
+
+       def entry_changed(self, index):
+               if self.instance is not None:
+                       self.instance.entryChanged(index)