-from Tools.Event import Event
+from Components.Element import Element
-class Converter:
- def __init__(self):
- self.changed = Event(start = self.start, stop = self.stop)
-
- def connect(self, source):
- source.changed.listen(self.changed)
- self.source = source
-
- def disconnect(self):
- self.source.changed.unlisten(self.changed)
-
- def start(self):
- pass
-
- def stop(self):
- pass
+class Converter(Element):
+ pass
install_PYTHON = \
__init__.py ClockToText.py Converter.py EventName.py StaticText.py EventTime.py \
- Poll.py RemainingToText.py
+ Poll.py RemainingToText.py StringList.py
+
--- /dev/null
+from Converter import Converter
+from enigma import eListboxPythonStringContent
+
+
+class StringList(Converter):
+ """Turns a simple python list into a list which can be used in a listbox."""
+ def __init__(self, *args, **kwargs):
+ Converter.__init__(self)
+
+ def changed(self):
+ self.content = eListboxPythonStringContent()
+ if self.source:
+ self.content.setList(self.source.list)
+ self.downstream_elements.changed()
+
+ def selectionChanged(self, index):
+ self.upstream_elements.selectionChanged(index)
+ # update all non-master targets
+ for x in self.downstream_elements:
+ if x is not self.master:
+ x.index = index
+
+ def getCurrent(self):
+ if self.source is None:
+ return None
+ return self.source.list[self.index]
+
+ current = property(getCurrent)
+
+ # pass through: getIndex / setIndex to master
+ def getIndex(self):
+ if self.master is None:
+ return None
+ return self.master.index
+
+ def setIndex(self, index):
+ if self.master is not None:
+ self.master.index = index
+
+ index = property(getIndex, setIndex)
--- /dev/null
+from Tools.CList import CList
+
+# down up
+# Render Converter Converter Source
+
+# a bidirectional connection
+class Element:
+ def __init__(self):
+ self.downstream_elements = CList()
+ self.upstream_elements = CList()
+ self.master = None
+ self.source = None
+
+ def connectDownstream(self, downstream):
+ self.downstream_elements.append(downstream)
+ if self.master is None:
+ self.master = downstream
+
+ def connectUpstream(self, upstream):
+ self.upstream_elements.append(upstream)
+ self.source = upstream # for single-source elements (i.e., most of them.)
+ self.changed()
+
+ def connect(self, upstream):
+ self.connectUpstream(upstream)
+ upstream.connectDownstream(self)
+
+ # default action: push downstream
+ def changed(self):
+ self.downstream_elements.changed()
BlinkingPixmap.py Pixmap.py ConditionalWidget.py Slider.py LanguageList.py \
PluginList.py PluginComponent.py RecordingConfig.py About.py UsageConfig.py \
FIFOList.py ServiceEventTracker.py Input.py TimerSanityCheck.py FileList.py \
- MultiContent.py MediaPlayer.py TunerInfo.py VideoWindow.py ChoiceList.py
+ MultiContent.py MediaPlayer.py TunerInfo.py VideoWindow.py ChoiceList.py \
+ Element.py
+
from Components.VariableText import VariableText
-from Components.GUIComponent import GUIComponent
+from Renderer import Renderer
from enigma import eLabel
-class Label(VariableText, GUIComponent):
+class Label(VariableText, Renderer):
def __init__(self):
- GUIComponent.__init__(self)
+ Renderer.__init__(self)
VariableText.__init__(self)
GUI_WIDGET = eLabel
def connect(self, source):
- source.changed.listen(self.changed)
- self.source = source
+ Renderer.connect(self, source)
self.changed()
def changed(self):
--- /dev/null
+from Components.VariableText import VariableText
+from Renderer import Renderer
+from Tools.Event import Event
+
+from enigma import eListbox
+
+# the listbox renderer is the listbox, but no listbox content
+# the content will be provided by the source (or converter).
+
+# the source should emit the 'changed' signal whenever
+# it has a new listbox content.
+
+# the source needs to have the 'content' property for the
+# used listbox content
+
+# it should expose exactly the non-content related functions
+# of the eListbox class. more or less.
+
+class Listbox(Renderer, object):
+ def __init__(self):
+ Renderer.__init__(self)
+ self.__content = None
+ self.__wrap_around = False
+ self.__selection_enabled = True
+
+ GUI_WIDGET = eListbox
+
+ def contentChanged(self):
+ self.content = self.source.content
+
+ def setContent(self, content):
+ self.__content = content
+ if self.instance is not None:
+ self.instance.setContent(self.__content)
+
+ content = property(lambda self: self.__content, setContent)
+
+ def postWidgetCreate(self, instance):
+ if self.__content is not None:
+ instance.setContent(self.__content)
+ instance.selectionChanged.get().append(self.selectionChanged)
+ self.wrap_around = self.wrap_around # trigger
+ self.selection_enabled = self.selection_enabled # trigger
+
+ 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):
+ self.upstream_elements.selectionChanged(self.index)
+
+ def getIndex(self):
+ if self.instance is None:
+ return None
+ return self.instance.getCurrentIndex()
+
+ 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 setSelectionEnabled(self, enabled):
+ self.__selection_enabled = enabled
+ if self.instance is not None:
+ self.instance.setSelectionEnable(enabled)
+
+ selection_enabled = property(lambda self: self.__selection_enabled, setSelectionEnabled)
+
+ def changed(self):
+ self.content = self.source.content
installdir = $(LIBDIR)/enigma2/python/Components/Renderer
install_PYTHON = \
- __init__.py Label.py Progress.py
+ __init__.py Label.py Progress.py Listbox.py Renderer.py
+
+
from Components.VariableValue import VariableValue
-from Components.GUIComponent import GUIComponent
+from Renderer import Renderer
from enigma import eSlider
-class Progress(VariableValue, GUIComponent):
+class Progress(VariableValue, Renderer):
def __init__(self):
- GUIComponent.__init__(self)
+ Renderer.__init__(self)
VariableValue.__init__(self)
self.__start = 0
self.__end = 100
GUI_WIDGET = eSlider
- def connect(self, source):
- source.changed.listen(self.changed)
- self.source = source
- self.changed()
-
def changed(self):
range = self.source.range or 100
value = self.source.value
--- /dev/null
+from Components.GUIComponent import GUIComponent
+from Components.Element import Element
+
+class Renderer(GUIComponent, Element):
+ def __init__(self):
+ Element.__init__(self)
+ GUIComponent.__init__(self)
class Clock(Source):
def __init__(self):
- self.changed = Event(start=self.start, stop=self.stop)
+ Source.__init__(self)
self.clock_timer = eTimer()
self.clock_timer.timeout.get().append(self.changed)
-
- def start(self):
self.clock_timer.start(1000)
- def stop(self):
- self.clock_timer.stop()
-
def getClock(self):
return time.time()
NEXT = 1
def __init__(self, navcore, now_or_next):
- self.changed = Event()
+ Source.__init__(self)
PerServiceBase.__init__(self, navcore,
{
iPlayableService.evUpdatedEventInfo: self.ourEvent,
installdir = $(LIBDIR)/enigma2/python/Components/Sources
install_PYTHON = \
- __init__.py Clock.py EventInfo.py Source.py
+ __init__.py Clock.py EventInfo.py Source.py MenuList.py
+
--- /dev/null
+from Source import Source
+from Tools.Event import Event
+
+class MenuList(Source, object):
+ def __init__(self, list = [ ], enableWrapAround = False):
+ Source.__init__(self)
+ self.__list = list
+ self.onSelectionChanged = [ ]
+
+ def setList(self, list):
+ self.__list = list
+ self.changed()
+
+ list = property(lambda self: self.__list, setList)
+
+ def entry_changed(self, index):
+ self.downstream_elements.entry_changed(self, index)
+
+ def selectionChanged(self, index):
+ for x in self.onSelectionChanged:
+ x()
+
+ def getCurrent(self):
+ return self.master and self.master.current
+
+ current = property(getCurrent)
+
+ def setIndex(self, index):
+ if self.master is not None:
+ self.master = index
+
+ def getIndex(self, index):
+ if self.master is not None:
+ return self.master.index
+ else:
+ return -1
+
+ setCurrentIndex = setIndex
+
+ index = property(getIndex, setIndex)
-class Source(object):
+from Components.Element import Element
+class Source(Element):
def execBegin(self):
pass
--- /dev/null
+class CList(list):
+ def __getattr__(self, attr):
+ return CList([getattr(a, attr) for a in self])
+
+ def __call__(self, *args, **kwargs):
+ for x in self:
+ x(*args, **kwargs)
install_DATA = \
FuzzyDate.py XMLTools.py Directories.py NumericalTextInput.py \
KeyBindings.py BoundFunction.py ISO639.py Notifications.py __init__.py \
- RedirectOutput.py DreamboxHardware.py Import.py Event.py
+ RedirectOutput.py DreamboxHardware.py Import.py Event.py CList.py
+