X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/cedcadfd77539c39e928a6d5cc4fcd8d1cf48ac8..6eeefece35e4269e02fdb7abab4f79d8e7b8f98b:/lib/python/Components/ConfigList.py diff --git a/lib/python/Components/ConfigList.py b/lib/python/Components/ConfigList.py index 1341ac50..e586f39d 100644 --- a/lib/python/Components/ConfigList.py +++ b/lib/python/Components/ConfigList.py @@ -1,17 +1,27 @@ from HTMLComponent import * from GUIComponent import * -from config import * - -from enigma import eListbox, eListboxPythonConfigContent +from config import KEY_LEFT, KEY_RIGHT, KEY_0, KEY_DELETE, KEY_OK, KEY_TIMEOUT +from Components.ActionMap import NumberActionMap +from enigma import eListbox, eListboxPythonConfigContent, eTimer class ConfigList(HTMLComponent, GUIComponent, object): - def __init__(self, list): + def __init__(self, list, session = None): GUIComponent.__init__(self) self.l = eListboxPythonConfigContent() self.l.setSeperation(100) self.list = list self.onSelectionChanged = [ ] + self.current = None + self.help_window = None + self.setHelpWindowSession(session) + + self.timer = eTimer() + self.timer.timeout.get().append(self.timeout) + def setHelpWindowSession(self, session): + assert self.help_window is None, "you can't move a help window to another session" + self.session = session + def toggle(self): selection = self.getCurrent() selection[1].toggle() @@ -19,9 +29,13 @@ class ConfigList(HTMLComponent, GUIComponent, object): def handleKey(self, key): selection = self.getCurrent() - if selection[1].parent.enabled: + if selection[1].enabled: selection[1].handleKey(key) self.invalidateCurrent() + if self.help_window: + self.help_window.update(selection[1]) + if key not in [KEY_TIMEOUT, KEY_LEFT, KEY_RIGHT, KEY_DELETE, KEY_OK]: + self.timer.start(1000, 1) def getCurrent(self): return self.l.getCurrentSelection() @@ -30,15 +44,26 @@ class ConfigList(HTMLComponent, GUIComponent, object): self.l.invalidateEntry(self.l.getCurrentSelectionIndex()) def invalidate(self, entry): - i = 0 - for x in self.__list: - if (entry.getConfigPath() == x[1].parent.getConfigPath()): - self.l.invalidateEntry(i) - i += 1 + self.l.invalidateEntry(self.__list.index(entry)) GUI_WIDGET = eListbox def selectionChanged(self): + n = self.getCurrent() + + if self.help_window: + print "close old help window!" + self.session.deleteDialog(self.help_window) + + nh = n and n[1].helpWindow() + print "n, nh:", n, nh + if nh is not None and self.session is not None: + print "show new help window" + self.help_window = self.session.instantiateDialog(*nh) + self.help_window.show() + + print "config selection changed, from ", self.current, " to ", n + self.current = n for x in self.onSelectionChanged: x() @@ -57,3 +82,43 @@ class ConfigList(HTMLComponent, GUIComponent, object): return self.__list list = property(getList, setList) + + def timeout(self): + self.handleKey(KEY_TIMEOUT) + +class ConfigListScreen: + def __init__(self, list, session = None): + self["config_actions"] = NumberActionMap(["SetupActions", "TextInputActions"], + { + "ok": self.keyOK, + "left": self.keyLeft, + "right": self.keyRight, + "delete": self.keyDelete, + "1": self.keyNumberGlobal, + "2": self.keyNumberGlobal, + "3": self.keyNumberGlobal, + "4": self.keyNumberGlobal, + "5": self.keyNumberGlobal, + "6": self.keyNumberGlobal, + "7": self.keyNumberGlobal, + "8": self.keyNumberGlobal, + "9": self.keyNumberGlobal, + "0": self.keyNumberGlobal + }, -1) + + self["config"] = ConfigList(list, session = session) + + def keyOK(self): + self["config"].handleKey(KEY_OK) + + def keyLeft(self): + self["config"].handleKey(KEY_LEFT) + + def keyRight(self): + self["config"].handleKey(KEY_RIGHT) + + def keyDelete(self): + self["config"].handleKey(KEY_DELETE) + + def keyNumberGlobal(self, number): + self["config"].handleKey(KEY_0 + number)