--- /dev/null
+from enigma import *
+
+class ActionMap:
+ def __init__(self, contexts = [ ], actions = { }, prio=0):
+ self.actions = actions
+ self.contexts = contexts
+ self.prio = prio
+ self.p = eActionMapPtr()
+ eActionMap.getInstance(self.p)
+
+ def execBegin(self):
+ for ctx in self.contexts:
+ self.p.bindAction(ctx, self.prio, self.action)
+
+ def execEnd(self):
+ for ctx in self.contexts:
+ self.p.unbindAction(ctx, self.action)
+
+ def action(self, context, action):
+ print " ".join(("action -> ", context, action))
+ if self.actions.has_key(action):
+ self.actions[action]()
+ else:
+ print "unknown action %s/%s! typo in keymap?" % (context, action)
+
--- /dev/null
+from HTMLComponent import *
+from GUIComponent import *
+from VariableText import *
+
+from enigma import eButton
+
+class Button(HTMLComponent, GUIComponent, VariableText):
+ def __init__(self, text="", onClick = [ ]):
+ GUIComponent.__init__(self)
+ VariableText.__init__(self)
+ self.setText(text)
+ self.onClick = onClick
+
+ def push(self):
+ for x in self.onClick:
+ x()
+ return 0
+
+ def disable(self):
+# self.instance.hide()
+ pass
+
+ def enable(self):
+# self.instance.show()
+ pass
+
+# html:
+ def produceHTML(self):
+ return "<input type=\"submit\" text=\"" + self.getText() + "\">\n"
+
+# GUI:
+ def createWidget(self, parent, skindata):
+ g = eButton(parent)
+ g.selected.get().append(self.push)
+ return g
+
+ def removeWidget(self, w):
+ w.selected.get().remove(self.push)
+
--- /dev/null
+from HTMLComponent import *
+from GUIComponent import *
+from VariableText import *
+
+from enigma import eTimer
+from enigma import eLabel
+
+import time
+# now some "real" components:
+
+class Clock(HTMLComponent, GUIComponent, VariableText):
+ def __init__(self):
+ VariableText.__init__(self)
+ GUIComponent.__init__(self)
+ self.doClock()
+
+ self.clockTimer = eTimer()
+ self.clockTimer.timeout.get().append(self.doClock)
+ self.clockTimer.start(1000)
+
+# "funktionalitaet"
+ def doClock(self):
+ t = time.localtime()
+ self.setText("%2d:%02d:%02d" % (t[3], t[4], t[5]))
+
+# realisierung als GUI
+ def createWidget(self, parent, skindata):
+ return eLabel(parent)
+
+ def removeWidget(self, w):
+ del self.clockTimer
+
+# ...und als HTML:
+ def produceHTML(self):
+ return self.getText()
+
--- /dev/null
+from HTMLComponent import *
+from GUIComponent import *
+from config import *
+
+from enigma import eListbox, eListboxPythonConfigContent
+
+class ConfigList(HTMLComponent, GUIComponent):
+ def __init__(self, list):
+ GUIComponent.__init__(self)
+ self.l = eListboxPythonConfigContent()
+ self.l.setList(list)
+ self.l.setSeperation(100)
+
+ def toggle(self):
+ selection = self.getCurrent()
+ selection[1].toggle()
+ self.invalidateCurrent()
+
+ def getCurrent(self):
+ return self.l.getCurrentSelection()
+
+ def invalidateCurrent(self):
+ self.l.invalidateEntry(self.l.getCurrentSelectionIndex())
+
+ def GUIcreate(self, parent, skindata):
+ self.instance = eListbox(parent)
+ self.instance.setContent(self.l)
+
+ def GUIdelete(self):
+ self.instance.setContent(None)
+ self.instance = None
+
--- /dev/null
+from PerServiceDisplay import *
+
+class EventInfo(PerServiceDisplay):
+ Now = 0
+ Next = 1
+ Now_Duration = 2
+ Next_Duration = 3
+
+ def __init__(self, navcore, now_or_next):
+ # listen to evUpdatedEventInfo and evStopService
+ # note that evStopService will be called once to establish a known state
+ self.now_or_next = now_or_next
+ PerServiceDisplay.__init__(self, navcore,
+ {
+ pNavigation.evUpdatedEventInfo: self.ourEvent,
+ pNavigation.evStopService: self.stopEvent
+ })
+
+ def ourEvent(self):
+ info = iServiceInformationPtr()
+ service = self.navcore.getCurrentService()
+
+ if service != None:
+ if not service.info(info):
+ ev = eServiceEventPtr()
+ if info.getEvent(ev, self.now_or_next & 1) == 0:
+ if self.now_or_next & 2:
+ self.setText("%d min" % (ev.m_duration / 60))
+ else:
+ self.setText(ev.m_event_name)
+ print "new event info in EventInfo! yeah!"
+
+ def stopEvent(self):
+ self.setText(
+ ("waiting for event data...", "", "--:--", "--:--")[self.now_or_next]);
+
--- /dev/null
+class GUIComponent:
+ """ GUI component """
+
+ def __init__(self):
+ pass
+
+ def execBegin(self):
+ pass
+
+ def execEnd(self):
+ pass
+
--- /dev/null
+from GUIComponent import *
+
+class GUISkin:
+ def __init__(self):
+ pass
+
+ def createGUIScreen(self, parent):
+ for (name, val) in self.items():
+ if isinstance(val, GUIComponent):
+ val.GUIcreate(parent, None)
+
+ def deleteGUIScreen(self):
+ for (name, val) in self.items():
+ if isinstance(val, GUIComponent):
+ val.GUIdelete()
+ try:
+ val.fix()
+ except:
+ pass
+
+ # DIESER KOMMENTAR IST NUTZLOS UND MITTLERWEILE VERALTET! (glaub ich)
+ # BITTE NICHT LESEN!
+ # note: you'll probably run into this assert. if this happens, don't panic!
+ # yes, it's evil. I told you that programming in python is just fun, and
+ # suddently, you have to care about things you don't even know.
+ #
+ # but calm down, the solution is easy, at least on paper:
+ #
+ # Each Component, which is a GUIComponent, owns references to each
+ # instantiated eWidget (namely in screen.data[name]["instance"], in case
+ # you care.)
+ # on deleteGUIscreen, all eWidget *must* (!) be deleted (otherwise,
+ # well, problems appear. I don't want to go into details too much,
+ # but this would be a memory leak anyway.)
+ # The assert beyond checks for that. It asserts that the corresponding
+ # eWidget is about to be removed (i.e., that the refcount becomes 0 after
+ # running deleteGUIscreen).
+ # (You might wonder why the refcount is checked for 2 and not for 1 or 0 -
+ # one reference is still hold by the local variable 'w', another one is
+ # hold be the function argument to sys.getrefcount itself. So only if it's
+ # 2 at this point, the object will be destroyed after leaving deleteGUIscreen.)
+ #
+ # Now, how to fix this problem? You're holding a reference somewhere. (References
+ # can only be hold from Python, as eWidget itself isn't related to the c++
+ # way of having refcounted objects. So it must be in python.)
+ #
+ # It could be possible that you're calling deleteGUIscreen trough a call of
+ # a PSignal. For example, you could try to call screen.doClose() in response
+ # to a Button::click. This will fail. (It wouldn't work anyway, as you would
+ # remove a dialog while running it. It never worked - enigma1 just set a
+ # per-mainloop variable on eWidget::close() to leave the exec()...)
+ # That's why Session supports delayed closes. Just call Session.close() and
+ # it will work.
+ #
+ # Another reason is that you just stored the data["instance"] somewhere. or
+ # added it into a notifier list and didn't removed it.
+ #
+ # If you can't help yourself, just ask me. I'll be glad to help you out.
+ # Sorry for not keeping this code foolproof. I really wanted to archive
+ # that, but here I failed miserably. All I could do was to add this assert.
+# assert sys.getrefcount(w) == 2, "too many refs hold to " + str(w)
+
+ def close(self):
+ self.deleteGUIScreen()
+
--- /dev/null
+# some helper classes first:
+class HTMLComponent:
+ def produceHTML(self):
+ return ""
+
--- /dev/null
+class HTMLSkin:
+ order = ()
+
+ def __init__(self, order):
+ self.order = order
+
+ def produceHTML(self):
+ res = "<html>\n"
+ for name in self.order:
+ res += self[name].produceHTML()
+ res += "</html>\n";
+ return res
+
--- /dev/null
+from HTMLComponent import *
+from GUIComponent import *
+from VariableText import *
+
+from enigma import eLabel
+
+class Header(HTMLComponent, GUIComponent, VariableText):
+
+ def __init__(self, message):
+ GUIComponent.__init__(self)
+ VariableText.__init__(self)
+ self.setText(message)
+
+ def produceHTML(self):
+ return "<h2>" + self.getText() + "</h2>\n"
+
+ def createWidget(self, parent, skindata):
+ g = eLabel(parent)
+ return g
+
--- /dev/null
+from HTMLComponent import *
+from GUIComponent import *
+from VariableText import *
+
+from enigma import eLabel
+
+class Label(HTMLComponent, GUIComponent, VariableText):
+ def __init__(self, text=""):
+ GUIComponent.__init__(self)
+ VariableText.__init__(self)
+ self.setText(text)
+
+# html:
+ def produceHTML(self):
+ return self.getText()
+
+# GUI:
+ def createWidget(self, parent, skindata):
+ return eLabel(parent)
+
--- /dev/null
+from HTMLComponent import *
+from GUIComponent import *
+
+from enigma import eListboxPythonStringContent, eListbox
+
+class MenuList(HTMLComponent, GUIComponent):
+ def __init__(self, list):
+ GUIComponent.__init__(self)
+ self.l = eListboxPythonStringContent()
+ self.l.setList(list)
+
+ def getCurrent(self):
+ return self.l.getCurrentSelection()
+
+ def GUIcreate(self, parent, skindata):
+ self.instance = eListbox(parent)
+ self.instance.setContent(self.l)
+
+ def GUIdelete(self):
+ self.instance.setContent(None)
+ self.instance = None
+
+
--- /dev/null
+from GUIComponent import *
+from VariableText import *
+
+from enigma import pNavigation
+from enigma import eLabel
+
+class PerServiceDisplay(GUIComponent, VariableText):
+ """Mixin for building components which display something which changes on navigation events, for example "service name" """
+
+ def __init__(self, navcore, eventmap):
+ GUIComponent.__init__(self)
+ VariableText.__init__(self)
+ self.eventmap = eventmap
+ self.navcore = navcore
+ self.navcore.event.append(self.event)
+
+ # start with stopped state, so simulate that
+ self.event(pNavigation.evStopService)
+
+ def event(self, ev):
+ # loop up if we need to handle this event
+ if self.eventmap.has_key(ev):
+ # call handler
+ self.eventmap[ev]()
+
+ def createWidget(self, parent, skindata):
+ # by default, we use a label to display our data.
+ g = eLabel(parent)
+ return g
+
--- /dev/null
+from HTMLComponent import *
+from GUIComponent import *
+from VariableValue import *
+
+from enigma import eSlider
+
+# a general purpose progress bar
+class ProgressBar(HTMLComponent, GUIComponent, VariableValue):
+ def __init__(self):
+ GUIComponent.__init__(self)
+ VariableValue.__init__(self)
+
+ def createWidget(self, parent, skindata):
+ g = eSlider(parent)
+ g.setRange(0, 100)
+ return g
+
--- /dev/null
+from HTMLComponent import *
+from GUIComponent import *
+
+from enigma import *
+
+class ServiceList(HTMLComponent, GUIComponent):
+ def __init__(self):
+ GUIComponent.__init__(self)
+ self.l = eListboxServiceContent()
+
+ def getCurrent(self):
+ r = eServiceReference()
+ self.l.getCurrent(r)
+ return r
+
+ def moveUp(self):
+ self.instance.moveSelection(self.instance.moveUp)
+
+ def moveDown(self):
+ self.instance.moveSelection(self.instance.moveDown)
+
+ def GUIcreate(self, parent, skindata):
+ self.instance = eListbox(parent)
+ self.instance.setContent(self.l)
+
+ def GUIdelete(self):
+ self.instance = None
+
+ def setRoot(self, root):
+ self.l.setRoot(root)
+
+ # mark stuff
+ def clearMarked(self):
+ self.l.clearMarked()
+
+ def isMarked(self, ref):
+ return self.l.isMarked(ref)
+
+ def addMarked(self, ref):
+ self.l.addMarked(ref)
+
+ def removeMarked(self, ref):
+ self.l.removeMarked(ref)
+
--- /dev/null
+from PerServiceDisplay import *
+from enigma import pNavigation
+
+class ServiceName(PerServiceDisplay):
+ def __init__(self, navcore):
+ PerServiceDisplay.__init__(self, navcore,
+ {
+ pNavigation.evNewService: self.newService,
+ pNavigation.evStopService: self.stopEvent
+ })
+
+ def newService(self):
+ info = iServiceInformationPtr()
+ service = self.navcore.getCurrentService(service)
+
+ if service != None:
+ if not service.info(info):
+ self.setText("no name known, but it should be here :)")
+
+ def stopEvent(self):
+ self.setText("");
+
--- /dev/null
+from enigma import eComponentScan
+
+class ServiceScan:
+
+ Idle = 1
+ Running = 2
+ Done = 3
+ Error = 4
+
+ Errors = {
+ 0: "error starting scanning",
+ 1: "error while scanning",
+ 2: "no resource manager",
+ 3: "no channel list"
+ }
+
+ def scanStatusChanged(self):
+ if self.state == self.Running:
+ self.progressbar.setValue(self.scan.getProgress())
+ if self.scan.isDone():
+ errcode = self.scan.getError()
+
+ if errcode == 0:
+ self.state = self.Done
+ else:
+ self.state = self.Error
+ self.errorcode = errcode
+ else:
+ self.text.setText("scan in progress - %d %% done!\n%d services found!" % (self.scan.getProgress(), self.scan.getNumServices()))
+
+ if self.state == self.Done:
+ self.text.setText("scan done!")
+
+ if self.state == self.Error:
+ self.text.setText("ERROR - failed to scan (%s)!" % (self.Errors[self.errorcode]) )
+
+ def __init__(self, progressbar, text):
+ self.progressbar = progressbar
+ self.text = text
+ self.scan = eComponentScan()
+ self.state = self.Idle
+ self.scanStatusChanged()
+
+ def execBegin(self):
+ self.scan.statusChanged.get().append(self.scanStatusChanged)
+ self.state = self.Running
+ err = self.scan.start()
+ if err:
+ self.state = self.Error
+ self.errorcode = 0
+
+ self.scanStatusChanged()
+
+ def execEnd(self):
+ self.scan.statusChanged.get().remove(self.scanStatusChanged)
+ if not self.isDone():
+ print "*** warning *** scan was not finished!"
+
+ def isDone(self):
+ print "state is %d " % (self.state)
+ return self.state == self.Done or self.state == self.Error
+
--- /dev/null
+class VariableText:
+ """VariableText can be used for components which have a variable text, based on any widget with setText call"""
+
+ def __init__(self):
+ self.message = ""
+ self.instance = None
+
+ def setText(self, text):
+ self.message = text
+ if self.instance:
+ self.instance.setText(self.message)
+
+ def getText(self):
+ return self.message
+
+ def GUIcreate(self, parent, skindata):
+ self.instance = self.createWidget(parent, skindata)
+ self.instance.setText(self.message)
+
+ def GUIdelete(self):
+ self.removeWidget(self.instance)
+ self.instance = None
+
+ def removeWidget(self, instance):
+ pass
+
--- /dev/null
+class VariableValue:
+ """VariableValue can be used for components which have a variable value (like eSlider), based on any widget with setValue call"""
+
+ def __init__(self):
+ self.value = 0
+ self.instance = None
+
+ def setValue(self, value):
+ self.value = value
+ if self.instance:
+ self.instance.setValue(self.value)
+
+ def getValue(self):
+ return self.value
+
+ def GUIcreate(self, parent, skindata):
+ self.instance = self.createWidget(parent, skindata)
+ self.instance.setValue(self.value)
+
+ def GUIdelete(self):
+ self.removeWidget(self.instance)
+ self.instance = None
+
+ def removeWidget(self, instance):
+ pass
--- /dev/null
+from HTMLComponent import *
+from GUIComponent import *
+from VariableValue import *
+
+class VolumeBar(HTMLComponent, GUIComponent, VariableValue):
+
+ def __init__(self):
+ GUIComponent.__init__(self)
+ VariableValue.__init__(self)
+
+ def createWidget(self, parent, skindata):
+ g = eSlider(parent)
+ g.setRange(0, 100)
+ return g
+
--- /dev/null
+
+__all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo",
+ "GUIComponent", "GUISkin", "HTMLComponent", "HTMLSkin", "Header",
+ "Label", "MenuList", "PerServiceDisplay", "ProgressBar", "ServiceList",
+ "ServiceName", "ServiceScan", "VariableText", "VariableValue", "VolumeBar",
+ "components", "config"]
+
--- /dev/null
+from enigma import *
+import time
+import sys
+
+import HTMLComponent
+import HTMLSkin
+import GUISkin
+import GUIComponent
+import VariableValue
+import Clock
+import Button
+import Label
+import Header
+import VolumeBar
+import ProgressBar
+import MenuList
+import config
+import ConfigList
+import ServiceList
+import ServiceScan
+import ActionMap
+import PerServiceDisplay
+import EventInfo
+import ServiceName
--- /dev/null
+# temp stuff :)
+class configBoolean:
+ def __init__(self, reg):
+ self.reg = reg
+ self.val = 0
+
+ def toggle(self):
+ self.val += 1
+ self.val %= 3
+
+ def __str__(self):
+ return ("NO", "YES", "MAYBE")[self.val]
+
+class configValue:
+ def __init__(self, obj):
+ self.obj = obj
+
+ def __str__(self):
+ return self.obj
+
+def configEntry(obj):
+ # das hier ist ein zugriff auf die registry...
+ if obj == "HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/SDTV/FLASHES/GREEN":
+ return ("SDTV green flashes", configBoolean(obj))
+ elif obj == "HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/HDTV/FLASHES/GREEN":
+ return ("HDTV reen flashes", configBoolean(obj))
+ else:
+ return ("invalid", "")
+
-from components import *
-import sys
-from enigma import quitMainloop
-
-import xml.dom.minidom
-from xml.dom import EMPTY_NAMESPACE
-from skin import elementsWithTag
-
-import time
-
-# some screens
-def doGlobal(screen):
- screen["clock"] = Clock()
-
-class Screen(dict, HTMLSkin, GUISkin):
- """ bla """
-
- def __init__(self, session):
- self.skinName = self.__class__.__name__
- self.session = session
- GUISkin.__init__(self)
-
- def execBegin(self):
-# assert self.session == None, "a screen can only exec one per time"
-# self.session = session
- for (name, val) in self.items():
- val.execBegin()
-
- def execEnd(self):
- for (name, val) in self.items():
- val.execEnd()
-# assert self.session != None, "execEnd on non-execing screen!"
-# self.session = None
-
- # never call this directly - it will be called from the session!
- def doClose(self):
- GUISkin.close(self)
-
- del self.session
- for (name, val) in self.items():
- print "%s -> %d" % (name, sys.getrefcount(val))
- del self[name]
-
- def close(self, retval=None):
- self.session.close()
-
-
-mdom = xml.dom.minidom.parseString(
- """
- <menu text="Mainmenu" title="the real Mainmenu">
- <item text="Standby debug">quitMainloop()</item>
- <item text="Automatic Scan">self.openDialog(serviceScan)</item>
-
- <item text="TV-Mode">self.setModeTV()</item>
- <item text="Radio-Mode">self.setModeRadio()</item>
- <item text="File-Mode">self.setModeFile()</item>
- <item text="Scart">self.openDialog(ScartLoopThrough)</item>
- <item text="Timer"></item>
- <menu text="Setup">
- <menu text="Service Organising">
- <item text="New Bouquets"></item>
- <item text="Add to Bouquets"></item>
- <item text="Edit Bouquets"></item>
- </menu>
- <menu text="Service Searching">
- <item text="Satelliteconfig"></item>
- <item text="Satfinder"></item>
- <item text="Rotor Control"></item>
- <item text="Edit Transponder"></item>
- <item text="Automatic Scan">self.openDialog(serviceScan)</item>
- <item text="Automatic 'Multisat' Scan"></item>
- <item text="Manual Scan"></item>
- </menu>
- <menu text="System">
- <item text="Time Date"></item>
- <item text="Video Audio"></item>
- <item text="UHF Modulator"></item>
- <item text="Harddisk"></item>
- <item text="Keyboard"></item>
- <item text="OSD">self.openDialog(configOSD)</item>
- <item text="Language"></item>
- <item text="LCD"></item>
- </menu>
- <item text="Common Interface"></item>
- <item text="Parental Control"></item>
- <item text="Expert"></item>
- </menu>
- <item text="Games"></item>
- <item text="Information"></item>
- <menu text="Standby">
- <item text="PowerOff"></item>
- <item text="Restart"></item>
- <item text="Standby"></item>
- <item text="Sleep Timer">self.goSetup()</item>
- </menu>
- </menu>""")
-
-def getText(nodelist):
- rc = ""
- for node in nodelist:
- if node.nodeType == node.TEXT_NODE:
- rc = rc + node.data
- return rc
-
-def getValbyAttr(x, attr):
- for p in range(x.attributes.length):
- a = x.attributes.item(p)
- attrib = str(a.name)
- value = str(a.value)
- if attrib == attr:
- return value
-
- return ""
-
-class boundFunction:
- def __init__(self, fnc, *args):
- self.fnc = fnc
- self.args = args
- def __call__(self):
- self.fnc(*self.args)
-
-class configOSD(Screen):
- #this needs focus handling - so not useable
-
- def okbuttonClick(self):
- self.close
-
- def __init__(self, session):
- Screen.__init__(self, session)
-
- self["actions"] = ActionMap(["OkCancelActions"],
- {
- "ok": self.okbuttonClick,
- "cancel": self.close
- })
-
- self["okbutton"] = Button("Save")
-
- self["txt_alpha"] = Label("Alpha:")
- self["sld_alpha"] = ProgressBar()
- self["sld_alpha"].setValue(50)
-
- self["txt_brightness"] = Label("Brightness:")
- self["sld_brightness"] = ProgressBar()
- self["sld_brightness"].setValue(50)
-
- self["txt_gamma"] = Label("Contrast:")
- self["sld_gamma"] = ProgressBar()
- self["sld_gamma"].setValue(50)
-
-
-class ScartLoopThrough(Screen):
- def __init__(self, session):
- Screen.__init__(self, session)
-
- self["actions"] = ActionMap(["OkCancelActions"],
- {
- "cancel": self.close
- })
-
-class ConfigMenu(Screen):
- #create a generic class for view/edit settings
- #all stuff come from xml file
- #configtype / datasource / validate-call / ...
-
- def __init__(self, session):
- Screen.__init__(self, session)
-
- self["actions"] = ActionMap(["OkCancelActions"],
- {
- #"ok": self.okbuttonClick,
- "cancel": self.close
- })
-
-class configTest(Screen):
-
- def __init__(self, session):
- Screen.__init__(self, session)
-
-
- self["config"] = ConfigList(
- [
- configEntry("HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/SDTV/FLASHES/GREEN"),
- configEntry("HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/HDTV/FLASHES/GREEN"),
- ])
-
- self["actions"] = ActionMap(["OkCancelActions"],
- {
- "ok": self["config"].toggle,
- "cancel": self.close
- })
-
-
-class Menu(Screen):
- #add file load functions for the xml-file
- #remove old code (i.e. goScan / goClock...)
-
- def openDialog(self, dialog):
- self.session.open(dialog)
-
- def goSetup(self):
- self.session.open(configTest)
-
- def setModeTV(self):
- print "set Mode to TV"
- pass
-
- def setModeRadio(self):
- print "set Mode to Radio"
- pass
-
- def setModeFile(self):
- print "set Mode to File"
- pass
-
- def goScan(self):
- self.session.open(serviceScan)
-
- def goClock(self):
- self.session.open(clockDisplay, Clock())
-
- def okbuttonClick(self):
- selection = self["menu"].getCurrent()
- selection[1]()
-
- def evalText(self, text):
- eval(text)
-
- def nothing(self): #dummy
- pass
-
- def addMenu(self, destList, node):
- MenuTitle = getValbyAttr(node, "text")
- if MenuTitle != "": #check for title
- a = boundFunction(self.session.open, Menu, node, node.childNodes)
- #TODO add check if !empty(node.childNodes)
- destList.append((MenuTitle, a))
-
- def addItem(self, destList, node):
- ItemText = getValbyAttr(node, "text")
- if ItemText != "": #check for name
- b = getText(node.childNodes)
- if b != "": #check for function
- destList.append((ItemText,boundFunction(self.evalText,b)))
- else:
- destList.append((ItemText,self.nothing)) #use dummy as function
-
- def __init__(self, session, parent, childNode):
- Screen.__init__(self, session)
-
- list = []
-
- for x in childNode: #walk through the actual nodelist
- if x.nodeType != xml.dom.minidom.Element.nodeType:
- continue
- elif x.tagName == 'item':
- self.addItem(list, x)
- elif x.tagName == 'menu':
- self.addMenu(list, x)
-
- self["menu"] = MenuList(list)
-
- self["actions"] = ActionMap(["OkCancelActions"],
- {
- "ok": self.okbuttonClick,
- "cancel": self.close
- })
-
- a = getValbyAttr(parent, "title")
- if a == "": #if empty use name
- a = getValbyAttr(parent, "text")
- self["title"] = Header(a)
-
-class channelSelection(Screen):
- def __init__(self, session):
- Screen.__init__(self, session)
-
- self["key_red"] = Button("red")
- self["key_green"] = Button("green")
- self["key_yellow"] = Button("yellow")
- self["key_blue"] = Button("blue")
-
- self["list"] = ServiceList()
- self["list"].setRoot(eServiceReference("""1:0:1:0:0:0:0:0:0:0:(provider=="ARD") && (type == 1)"""))
-
- #self["okbutton"] = Button("ok", [self.channelSelected])
-
- class ChannelActionMap(ActionMap):
- def action(self, contexts, action):
- if action[:7] == "bouquet":
- print "setting root to " + action[8:]
- self.csel["list"].setRoot(eServiceReference("1:0:1:0:0:0:0:0:0:0:" + action[8:]))
- else:
- ActionMap.action(self, contexts, action)
-
- self["actions"] = ChannelActionMap(["ChannelSelectActions", "OkCancelActions"],
- {
- "cancel": self.close,
- "ok": self.channelSelected,
- "mark": self.doMark
- })
- self["actions"].csel = self
-
- def doMark(self):
- ref = self["list"].getCurrent()
- if self["list"].isMarked(ref):
- self["list"].removeMarked(ref)
- else:
- self["list"].addMarked(ref)
-
- def channelSelected(self):
- self.session.nav.playService(self["list"].getCurrent())
- self.close()
-
- #called from infoBar
- def zapUp(self):
- self["list"].moveUp()
- self.session.nav.playService(self["list"].getCurrent())
-
- def zapDown(self):
- self["list"].moveDown()
- self.session.nav.playService(self["list"].getCurrent())
-
-class infoBar(Screen):
- def __init__(self, session):
- Screen.__init__(self, session)
-
- #instantiate forever
- self.servicelist = self.session.instantiateDialog(channelSelection)
-
- self["actions"] = ActionMap( [ "InfobarActions" ],
- {
- "switchChannel": self.switchChannel,
- "mainMenu": self.mainMenu,
- "zapUp": self.zapUp,
- "zapDown": self.zapDown,
- "instantRecord": self.instantRecord
- })
- self["okbutton"] = Button("mainMenu", [self.mainMenu])
-
- self["CurrentTime"] = Clock()
-
- self["ServiceName"] = ServiceName(self.session.nav)
-
- self["Event_Now"] = EventInfo(self.session.nav, EventInfo.Now)
- self["Event_Next"] = EventInfo(self.session.nav, EventInfo.Next)
-
- self["Event_Now_Duration"] = EventInfo(self.session.nav, EventInfo.Now_Duration)
- self["Event_Next_Duration"] = EventInfo(self.session.nav, EventInfo.Next_Duration)
-
- self.recording = None
-
- def mainMenu(self):
- print "loading mainmenu XML..."
- menu = mdom.childNodes[0]
- assert menu.tagName == "menu", "root element in menu must be 'menu'!"
- self.session.open(Menu, menu, menu.childNodes)
-
- def switchChannel(self):
- self.session.execDialog(self.servicelist)
-
- def zapUp(self):
- self.servicelist.zapUp()
-
- def zapDown(self):
- self.servicelist.zapDown()
-
- def instantRecord(self):
- if self.recording != None:
- print "remove entry"
- self.session.nav.RecordTimer.removeEntry(self.recording)
- self.recording = None
- else:
- serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
-
- # try to get event info
- epg = None
- service = self.session.nav.getCurrentService()
- if service != None:
- info = iServiceInformationPtr()
- if not service.info(info):
- ev = eServiceEventPtr()
- if info.getEvent(ev, 0) == 0:
- epg = ev
-
- self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 30, serviceref, epg)
- print "got entry: %s" % (str(self.recording))
-
-# a clock display dialog
-class clockDisplay(Screen):
- def okbutton(self):
- self.session.close()
-
- def __init__(self, session, clock):
- Screen.__init__(self, session)
- self["theClock"] = clock
- b = Button("bye")
- b.onClick = [ self.okbutton ]
- self["okbutton"] = b
- self["title"] = Header("clock dialog: here you see the current uhrzeit!")
-
-class serviceScan(Screen):
- def ok(self):
- print "ok"
- if self["scan"].isDone():
- self.close()
-
- def cancel(self):
- print "cancel not yet implemented ;)"
-
- def __init__(self, session):
- Screen.__init__(self, session)
-
- self["scan_progress"] = ProgressBar()
- self["scan_state"] = Label("scan state")
- self["scan"] = ServiceScan(self["scan_progress"], self["scan_state"])
-
- self["actions"] = ActionMap(["OkCancelActions"],
- {
- "ok": self.ok,
- "cancel": self.cancel
- })