diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2005-02-25 01:46:44 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2005-02-25 01:46:44 +0000 |
| commit | 1cdf6cb021fcaa6548b90ba7b6765cf1e8b8b37b (patch) | |
| tree | 5bd4dbac6538cf499f641849d26193958b48a187 /components.py | |
| parent | e677ac4a7bf81391877c909a703e5918ce4a511b (diff) | |
| download | enigma2-1cdf6cb021fcaa6548b90ba7b6765cf1e8b8b37b.tar.gz enigma2-1cdf6cb021fcaa6548b90ba7b6765cf1e8b8b37b.zip | |
- work on actions
- changed time when screens are acutally constructed
- added service name (not working atm) and event info (now&next)
Diffstat (limited to 'components.py')
| -rw-r--r-- | components.py | 98 |
1 files changed, 97 insertions, 1 deletions
diff --git a/components.py b/components.py index 63e5669e..219e4f52 100644 --- a/components.py +++ b/components.py @@ -86,7 +86,13 @@ class GUIComponent: def __init__(self): pass + + def execBegin(self): + pass + def execEnd(self): + pass + class VariableText: """VariableText can be used for components which have a variable text, based on any widget with setText call""" @@ -322,4 +328,94 @@ class ServiceScan: def fix(self): self.scan.statusChanged.get().remove(self.scanStatusChanged) -
\ No newline at end of file + +class ActionMap: + def __init__(self, context, actions = { }, prio=0): + self.actions = actions + self.context = context + self.prio = prio + self.p = eActionMapPtr() + eActionMap.getInstance(self.p) + + def execBegin(self): + self.p.bindAction(self.context, self.prio, self.action) + + def execEnd(self): + self.p.unbindAction(self.context, self.action) + + def action(self, context, action): + try: + self.actions[action]() + except KeyError: + print "unknown action %s/%s! typo in keymap?" % (context, action) + +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 + navcore.m_event.get().append(self.event) + self.navcore = navcore + + # 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 + +class EventInfo(PerServiceDisplay): + Now = 0 + Next = 1 + def __init__(self, navcore, now_or_next): + # listen to evUpdatedEventInfo and evStopService + # note that evStopService will be called once to establish a known state + PerServiceDisplay.__init__(self, navcore, + { + pNavigation.evUpdatedEventInfo: self.ourEvent, + pNavigation.evStopService: self.stopEvent + }) + self.now_or_next = now_or_next + + def ourEvent(self): + info = iServiceInformationPtr() + service = iPlayableServicePtr() + + if not self.navcore.getCurrentService(service): + if not service.info(info): + print "got info !" + ev = eServiceEventPtr() + info.getEvent(ev, self.now_or_next) + self.setText(ev.m_event_name) + print "new event info in EventInfo! yeah!" + + def stopEvent(self): + self.setText("waiting for event data..."); + +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 = iPlayableServicePtr() + + if not self.navcore.getCurrentService(service): + if not service.info(info): + self.setText("no name known, but it should be here :)") + + def stopEvent(self): + self.setText(""); |
