diff options
Diffstat (limited to 'lib/python/Screens')
| -rw-r--r-- | lib/python/Screens/ChannelSelection.py | 23 | ||||
| -rw-r--r-- | lib/python/Screens/EpgSelection.py | 108 | ||||
| -rw-r--r-- | lib/python/Screens/EventView.py | 33 | ||||
| -rw-r--r-- | lib/python/Screens/InfoBarGenerics.py | 124 |
4 files changed, 186 insertions, 102 deletions
diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py index 4c8b2486..89bc2154 100644 --- a/lib/python/Screens/ChannelSelection.py +++ b/lib/python/Screens/ChannelSelection.py @@ -2,6 +2,7 @@ from Screen import Screen from Components.Button import Button from Components.ServiceList import ServiceList from Components.ActionMap import NumberActionMap, ActionMap +from Components.MenuList import MenuList from EpgSelection import EPGSelection from enigma import eServiceReference, eEPGCache, eEPGCachePtr, eServiceCenter, eServiceCenterPtr, iMutableServiceListPtr, iStaticServiceInformationPtr, eTimer, eDVBDB from Components.config import config, configElement, ConfigSubsection, configText, currentConfigSelectionElement @@ -17,17 +18,27 @@ from os import remove import xml.dom.minidom -class BouquetSelector(FixedMenu): +class BouquetSelector(Screen): def __init__(self, session, bouquets, selectedFunc): + Screen.__init__(self, session) + self.selectedFunc=selectedFunc + + self["actions"] = ActionMap(["OkCancelActions"], + { + "ok": self.okbuttonClick, + "cancel": self.cancelClick + }) entrys = [ ] for x in bouquets: - entrys.append((x[0], self.bouquetSelected, x[1])) - FixedMenu.__init__(self, session, "Bouquetlist", entrys) - self.skinName = "Menu" + entrys.append((x[0], x[1])) + self["menu"] = MenuList(entrys) + + def okbuttonClick(self): + self.selectedFunc(self["menu"].getCurrent()[1]) - def bouquetSelected(self): - self.selectedFunc(self["menu"].getCurrent()[2]) + def cancelClick(self): + self.close(False) class ChannelContextMenu(FixedMenu): def __init__(self, session, csel): diff --git a/lib/python/Screens/EpgSelection.py b/lib/python/Screens/EpgSelection.py index d6fee567..c8db81b3 100644 --- a/lib/python/Screens/EpgSelection.py +++ b/lib/python/Screens/EpgSelection.py @@ -1,8 +1,11 @@ from Screen import Screen from Components.Button import Button +from Components.Pixmap import Pixmap +from Components.Label import Label from Components.EpgList import * from Components.ActionMap import ActionMap -from Screens.EventView import EventView +from Components.ScrollLabel import ScrollLabel +from Screens.EventView import EventViewSimple from enigma import eServiceReference, eServiceEventPtr from Screens.FixedMenu import FixedMenu from RecordTimer import RecordTimerEntry, parseEvent @@ -10,28 +13,40 @@ from TimerEdit import TimerEditList from TimerEntry import TimerEntry from ServiceReference import ServiceReference from Components.config import config, currentConfigSelectionElement +from time import localtime import xml.dom.minidom class EPGSelection(Screen): - def __init__(self, session, service): + def __init__(self, session, service, zapFunc=None): Screen.__init__(self, session) - self["key_red"] = Button("") - self["key_green"] = Button(_("Add timer")) - + self.closeRecursive = False if isinstance(service, eServiceReference): self.type = EPG_TYPE_SINGLE self["key_yellow"] = Button() self["key_blue"] = Button() self.currentService=ServiceReference(service) else: + self.skinName = "EPGSelectionMulti" self.type = EPG_TYPE_MULTI self["key_yellow"] = Button(_("Prev")) self["key_blue"] = Button(_("Next")) + self["now_button"] = Pixmap() + self["next_button"] = Pixmap() + self["more_button"] = Pixmap() + self["now_button_sel"] = Pixmap() + self["next_button_sel"] = Pixmap() + self["more_button_sel"] = Pixmap() + self["now_text"] = Label() + self["next_text"] = Label() + self["more_text"] = Label() + self["date"] = Label() self.services = service + self.zapFunc = zapFunc - self["list"] = EPGList(self.type) + self["key_green"] = Button(_("Add timer")) + self["list"] = EPGList(self.type, self.onSelectionChanged) class ChannelActionMap(ActionMap): def action(self, contexts, action): @@ -44,21 +59,26 @@ class EPGSelection(Screen): "timerAdd": self.timerAdd, "yellow": self.yellowButtonPressed, "blue": self.blueButtonPressed, - "info": self.infoKeyPressed + "info": self.infoKeyPressed, + "zapTo": self.zapTo }) self["actions"].csel = self self.onLayoutFinish.append(self.onCreate) - def infoKeyPressed(self): - if currentConfigSelectionElement(config.usage.epgtoggle) == "yes": - self.close(True) - else: - self.close(False) - def closeScreen(self): - self.close(False) + self.close(self.closeRecursive or self.type == EPG_TYPE_SINGLE) + def infoKeyPressed(self): + if self.type == EPG_TYPE_MULTI: + cur = self["list"].getCurrent() + event = cur[0] + service = cur[1] + else: + event = self["list"].getCurrent() + service = self.currentService + if event is not None: + self.session.open(EventViewSimple, event, service, self.eventViewCallback) #just used in multipeg def onCreate(self): @@ -88,16 +108,17 @@ class EPGSelection(Screen): setEvent(cur[0]) setService(cur[1]) + def zapTo(self): # just used in multiepg + if self.zapFunc != None: + self.closeRecursive = True + ref = self["list"].getCurrent()[1] + self.zapFunc(ref.ref) + def eventSelected(self): if self.type == EPG_TYPE_SINGLE: - event = self["list"].getCurrent() - service = self.currentService + self.infoKeyPressed() else: # EPG_TYPE_MULTI - cur = self["list"].getCurrent() - event = cur[0] - service = cur[1] - if event is not None: - self.session.open(EventView, event, service, self.eventViewCallback) + self.zapTo() def yellowButtonPressed(self): if self.type == EPG_TYPE_MULTI: @@ -131,3 +152,48 @@ class EPGSelection(Screen): def moveDown(self): self["list"].moveDown() + + def applyButtonState(self, state): + if state == 1: + self["now_button_sel"].showWidget() + self["now_button"].hideWidget() + else: + self["now_button"].showWidget() + self["now_button_sel"].hideWidget() + + if state == 2: + self["next_button_sel"].showWidget() + self["next_button"].hideWidget() + else: + self["next_button"].showWidget() + self["next_button_sel"].hideWidget() + + if state == 3: + self["more_button_sel"].showWidget() + self["more_button"].hideWidget() + else: + self["more_button"].showWidget() + self["more_button_sel"].hideWidget() + + def onSelectionChanged(self): + if self.type == EPG_TYPE_MULTI: + count = self["list"].getCurrentChangeCount() + if count > 1: + self.applyButtonState(3) + elif count > 0: + self.applyButtonState(2) + else: + self.applyButtonState(1) + days = [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ] + datastr = "" + event = self["list"].getCurrent()[0] + if event is not None: + now = time() + beg = event.getBeginTime() + nowTime = localtime(now) + begTime = localtime(beg) + if nowTime[2] != begTime[2]: + datestr = '%s %d.%d.'%(days[begTime[6]], begTime[2], begTime[1]) + else: + datestr = '%s %d.%d.'%(_("Today"), begTime[2], begTime[1]) + self["date"].setText(datestr) diff --git a/lib/python/Screens/EventView.py b/lib/python/Screens/EventView.py index d96be6d6..95c875f5 100644 --- a/lib/python/Screens/EventView.py +++ b/lib/python/Screens/EventView.py @@ -1,5 +1,6 @@ from Screen import Screen from Components.ActionMap import ActionMap +from Components.Button import Button from Components.Label import Label from Components.ScrollLabel import ScrollLabel from enigma import eServiceEventPtr @@ -7,9 +8,8 @@ from ServiceReference import ServiceReference from RecordTimer import RecordTimerEntry, parseEvent from TimerEntry import TimerEntry -class EventView(Screen): - def __init__(self, session, Event, Ref, callback=None): - Screen.__init__(self, session) +class EventViewBase: + def __init__(self, Event, Ref, callback=None): self.cbFunc = callback self.currentService=Ref self.event = Event @@ -17,6 +17,10 @@ class EventView(Screen): self["datetime"] = Label() self["channel"] = Label() self["duration"] = Label() + self["key_red"] = Button(_("")) + self["key_green"] = Button(_("Add Timer")) + self["key_yellow"] = Button(_("")) + self["key_blue"] = Button(_("")) self["actions"] = ActionMap(["OkCancelActions", "EventViewActions"], { "cancel": self.close, @@ -49,7 +53,7 @@ class EventView(Screen): if (answer[0]): self.session.nav.RecordTimer.record(answer[1]) else: - print "Timeredit aborted" + print "Timeredit aborted" def setService(self, service): self.currentService=service @@ -77,6 +81,25 @@ class EventView(Screen): def pageUp(self): self["epg_description"].pageUp() - + def pageDown(self): self["epg_description"].pageDown() + +class EventViewSimple(Screen, EventViewBase): + def __init__(self, session, Event, Ref, callback=None): + Screen.__init__(self, session) + self.skinName = "EventView" + EventViewBase.__init__(self, Event, Ref, callback) + +class EventViewEPGSelect(Screen, EventViewBase): + def __init__(self, session, Event, Ref, callback=None, singleEPGCB=None, multiEPGCB=None): + Screen.__init__(self, session) + self.skinName = "EventView" + EventViewBase.__init__(self, Event, Ref, callback) + self["key_yellow"].setText(_("Single EPG")) + self["key_blue"].setText(_("Multi EPG")) + self["epgactions"] = ActionMap(["EventViewEPGActions"], + { + "openSingleServiceEPG": singleEPGCB, + "openMultiServiceEPG": multiEPGCB + }) diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 605a15fd..2da8a4bd 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -18,7 +18,7 @@ from EpgSelection import EPGSelection from Screens.MessageBox import MessageBox from Screens.Dish import Dish from Screens.Standby import Standby -from Screens.EventView import EventView +from Screens.EventView import EventViewEPGSelect from Screens.MinuteInput import MinuteInput from Components.Harddisk import harddiskmanager @@ -305,59 +305,18 @@ class InfoBarEPG: def __init__(self): self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions", { - "showEPGList": (self.showEPG, _("show EPG...")), + "showEventInfo": (self.openEventView, _("show EPG...")), }) - def showEPG(self): - if currentConfigSelectionElement(config.usage.epgtoggle) == "yes": - self.openSingleServiceEPG() - else: - self.showEPGList() - - def showEPGList(self): - bouquets = self.servicelist.getBouquetList() - if bouquets is None: - cnt = 0 - else: - cnt = len(bouquets) - if cnt > 1: # show bouquet list - self.session.open(BouquetSelector, bouquets, self.openBouquetEPG) - elif cnt == 1: # add to only one existing bouquet - self.openBouquetEPG(bouquets[0][1]) - else: #no bouquets so we open single epg - self.openSingleEPGSelector(self.session.nav.getCurrentlyPlayingServiceReference()) - - def bouquetEPGCallback(self, info): - if info: - self.openSingleServiceEPG() - - def singleEPGCallback(self, info): - if info: - self.showEPGList() - - def openEventView(self): - try: - self.epglist = [ ] - service = self.session.nav.getCurrentService() - info = service.info() - ptr=info.getEvent(0) - if ptr: - self.epglist.append(ptr) - ptr=info.getEvent(1) - if ptr: - self.epglist.append(ptr) - if len(self.epglist) > 0: - self.session.open(EventView, self.epglist[0], ServiceReference(ref), self.eventViewCallback) - except: - pass - - def openSingleServiceEPG(self): - ref=self.session.nav.getCurrentlyPlayingServiceReference() - ptr=eEPGCache.getInstance() - if ptr.startTimeQuery(ref) != -1: - self.session.openWithCallback(self.singleEPGCallback, EPGSelection, ref) - else: # try to show now/next - print 'no epg for service', ref.toString() + def zapToService(self, service): + if not service is None: + if self.servicelist.getRoot() != self.epg_bouquet: #already in correct bouquet? + self.servicelist.clearPath() + if self.servicelist.bouquet_root != self.epg_bouquet: + self.servicelist.enterPath(self.servicelist.bouquet_root) + self.servicelist.enterPath(self.epg_bouquet) + self.servicelist.setCurrentSelection(service) #select the service in servicelist + self.servicelist.zap() def openBouquetEPG(self, bouquet): ptr=eEPGCache.getInstance() @@ -372,28 +331,53 @@ class InfoBarEPG: continue services.append(ServiceReference(service)) if len(services): - self.session.openWithCallback(self.bouquetEPGCallback, EPGSelection, services) + self.epg_bouquet = bouquet + self.session.openWithCallback(self.closed, EPGSelection, services, self.zapToService) + + def closed(self, ret): + if ret: + self.close(ret) - def openSingleEPGSelector(self, ref): + def openMultiServiceEPG(self): + bouquets = self.servicelist.getBouquetList() + if bouquets is None: + cnt = 0 + else: + cnt = len(bouquets) + if cnt > 1: # show bouquet list + self.session.openWithCallback(self.closed, BouquetSelector, bouquets, self.openBouquetEPG) + elif cnt == 1: + self.openBouquetEPG(bouquets[0][1]) + + def openSingleServiceEPG(self): + ref=self.session.nav.getCurrentlyPlayingServiceReference() ptr=eEPGCache.getInstance() - if ptr.startTimeQuery(ref) != -1: - self.session.open(EPGSelection, ref) - else: # try to show now/next - print 'no epg for service', ref.toString() - try: - self.epglist = [ ] - service = self.session.nav.getCurrentService() - info = service.info() - ptr=info.getEvent(0) - if ptr: - self.epglist.append(ptr) - ptr=info.getEvent(1) + self.session.openWithCallback(self.closed, EPGSelection, ref) + + def openEventView(self): + self.epglist = [ ] + service = self.session.nav.getCurrentService() + ref = self.session.nav.getCurrentlyPlayingServiceReference() + info = service.info() + ptr=info.getEvent(0) + if ptr: + self.epglist.append(ptr) + ptr=info.getEvent(1) + if ptr: + self.epglist.append(ptr) + if len(self.epglist) == 0: + epg = eEPGCache.getInstance() + ptr = epg.lookupEventTime(ref, -1) + if ptr: + self.epglist.append(ptr) + ptr = epg.lookupEventTime(ref, ptr.getBeginTime(), +1) if ptr: self.epglist.append(ptr) - if len(self.epglist) > 0: - self.session.open(EventView, self.epglist[0], ServiceReference(ref), self.eventViewCallback) - except: - pass + if len(self.epglist) > 0: + self.session.open(EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG) + else: + print "no epg for the service avail.. so we show multiepg instead of eventinfo" + self.openMultiServiceEPG() def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying if len(self.epglist) > 1: |
