X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/7466abeda3437afb71ce9ab8c0917cd8ea14482c..130b79ffa9b07ab07e5c5dd0dd293fd983dbbc9d:/lib/python/Screens/EpgSelection.py diff --git a/lib/python/Screens/EpgSelection.py b/lib/python/Screens/EpgSelection.py index 3284e641..a2c31d26 100644 --- a/lib/python/Screens/EpgSelection.py +++ b/lib/python/Screens/EpgSelection.py @@ -1,27 +1,25 @@ from Screen import Screen +from Components.config import config, ConfigClock from Components.Button import Button from Components.Pixmap import Pixmap from Components.Label import Label -from Components.EpgList import * +from Components.EpgList import EPGList, EPG_TYPE_SINGLE, EPG_TYPE_SIMILAR, EPG_TYPE_MULTI from Components.ActionMap import ActionMap -from Components.ScrollLabel import ScrollLabel from Screens.EventView import EventViewSimple from TimeDateInput import TimeDateInput -from enigma import eServiceReference, eServiceEventPtr -from Screens.FixedMenu import FixedMenu +from enigma import eServiceReference from RecordTimer import RecordTimerEntry, parseEvent -from TimerEdit import TimerEditList from TimerEntry import TimerEntry from ServiceReference import ServiceReference -from Components.config import config, currentConfigSelectionElement -from time import localtime +from time import localtime, time -import xml.dom.minidom +mepg_config_initialized = False class EPGSelection(Screen): - def __init__(self, session, service, zapFunc=None, eventid=None): + def __init__(self, session, service, zapFunc=None, eventid=None, bouquetChangeCB=None): Screen.__init__(self, session) - self.asked_specific_time = False + self.bouquetChangeCB = bouquetChangeCB + self.ask_time = -1 #now self["key_red"] = Button("") self.closeRecursive = False if isinstance(service, str) and eventid != None: @@ -31,11 +29,15 @@ class EPGSelection(Screen): self["key_red"] = Button() self.currentService=service self.eventid = eventid + self.zapFunc = None elif isinstance(service, eServiceReference) or isinstance(service, str): self.type = EPG_TYPE_SINGLE self["key_yellow"] = Button() self["key_blue"] = Button() self.currentService=ServiceReference(service) + self.zapFunc = None + self.sort_type = 0 + self.setSortDescription() else: self.skinName = "EPGSelectionMulti" self.type = EPG_TYPE_MULTI @@ -57,11 +59,7 @@ class EPGSelection(Screen): self["key_green"] = Button(_("Add timer")) self["list"] = EPGList(type = self.type, selChangedCB = self.onSelectionChanged, timer = self.session.nav.RecordTimer) - class ChannelActionMap(ActionMap): - def action(self, contexts, action): - return ActionMap.action(self, contexts, action) - - self["actions"] = ChannelActionMap(["EPGSelectActions", "OkCancelActions"], + self["actions"] = ActionMap(["EPGSelectActions", "OkCancelActions"], { "cancel": self.closeScreen, "ok": self.eventSelected, @@ -69,33 +67,44 @@ class EPGSelection(Screen): "yellow": self.yellowButtonPressed, "blue": self.blueButtonPressed, "info": self.infoKeyPressed, - "zapTo": self.zapTo, - "input_date_time": self.enterDateTime + "red": self.zapTo, + "input_date_time": self.enterDateTime, + "nextBouquet": self.nextBouquet, + "prevBouquet": self.prevBouquet }) self["actions"].csel = self self.onLayoutFinish.append(self.onCreate) + def nextBouquet(self): + if self.bouquetChangeCB: + self.bouquetChangeCB(1, self) + + def prevBouquet(self): + if self.bouquetChangeCB: + self.bouquetChangeCB(-1, self) + def enterDateTime(self): - self.session.openWithCallback(self.onDateTimeInputClosed, TimeDateInput) + if self.type == EPG_TYPE_MULTI: + global mepg_config_initialized + if not mepg_config_initialized: + config.misc.prev_mepg_time=ConfigClock(default = time()) + mepg_config_initialized = True + self.session.openWithCallback(self.onDateTimeInputClosed, TimeDateInput, config.misc.prev_mepg_time ) def onDateTimeInputClosed(self, ret): if len(ret) > 1: if ret[0]: - self.asked_specific_time=True + self.ask_time=ret[1] self["list"].fillMultiEPG(self.services, ret[1]) def closeScreen(self): self.close(self.closeRecursive) def infoKeyPressed(self): - if self.type == EPG_TYPE_MULTI or self.type == EPG_TYPE_SIMILAR: - cur = self["list"].getCurrent() - event = cur[0] - service = cur[1] - else: - event = self["list"].getCurrent() - service = self.currentService + cur = self["list"].getCurrent() + event = cur[0] + service = cur[1] if event is not None: if self.type != EPG_TYPE_SIMILAR: self.session.open(EventViewSimple, event, service, self.eventViewCallback, self.openSimilarList) @@ -105,18 +114,19 @@ class EPGSelection(Screen): def openSimilarList(self, eventid, refstr): self.session.open(EPGSelection, refstr, None, eventid) + def setServices(self, services): + self.services = services + self.onCreate() + #just used in multipeg def onCreate(self): l = self["list"] + l.recalcEntrySize() if self.type == EPG_TYPE_MULTI: - l.recalcEntrySize() - l.fillMultiEPG(self.services) + l.fillMultiEPG(self.services, self.ask_time) elif self.type == EPG_TYPE_SINGLE: - if SINGLE_CPP == 0: - l.recalcEntrySize() l.fillSingleEPG(self.currentService) else: - l.recalcEntrySize() l.fillSimilarList(self.currentService, self.eventid) def eventViewCallback(self, setEvent, setService, val): @@ -127,46 +137,54 @@ class EPGSelection(Screen): elif val == +1: self.moveDown() cur = l.getCurrent() - if self.type == EPG_TYPE_SINGLE: - setEvent(cur) + if self.type == EPG_TYPE_MULTI and cur[0] is None and cur[1].ref != old[1].ref: + self.eventViewCallback(setEvent, setService, val) else: - if self.type == EPG_TYPE_MULTI and cur[0] is None and cur[1].ref != old[1].ref: - self.eventViewCallback(setEvent, setService, val) - else: - setService(cur[1]) - setEvent(cur[0]) + setService(cur[1]) + setEvent(cur[0]) def zapTo(self): # just used in multiepg - if self.zapFunc != None: - self.closeRecursive = True - ref = self["list"].getCurrent()[1] - self.zapFunc(ref.ref) + if self.zapFunc and self["key_red"].getText() == "Zap": + lst = self["list"] + count = lst.getCurrentChangeCount() + if count == 0: + self.closeRecursive = True + ref = lst.getCurrent()[1] + self.zapFunc(ref.ref) def eventSelected(self): - if self.type == EPG_TYPE_MULTI: - self.zapTo() - else: - self.infoKeyPressed() + self.infoKeyPressed() def yellowButtonPressed(self): if self.type == EPG_TYPE_MULTI: self["list"].updateMultiEPG(-1) + elif self.type == EPG_TYPE_SINGLE: + if self.sort_type == 0: + self.sort_type = 1 + else: + self.sort_type = 0 + self["list"].sortSingleEPG(self.sort_type) + self.setSortDescription() + + def setSortDescription(self): + if self.sort_type == 1: + # TRANSLATORS: This must fit into the header button in the EPG-List + self["key_yellow"].setText(_("Sort Time")) + else: + # TRANSLATORS: This must fit into the header button in the EPG-List + self["key_yellow"].setText(_("Sort A-Z")) def blueButtonPressed(self): if self.type == EPG_TYPE_MULTI: self["list"].updateMultiEPG(1) def timerAdd(self): - if self.type == EPG_TYPE_SINGLE: - event = self["list"].getCurrent() - serviceref = self.currentService - else: - cur = self["list"].getCurrent() - event = cur[0] - serviceref = cur[1] + cur = self["list"].getCurrent() + event = cur[0] + serviceref = cur[1] if event is None: return - newEntry = RecordTimerEntry(serviceref, *parseEvent(event)) + newEntry = RecordTimerEntry(serviceref, checkOldTimers = True, *parseEvent(event)) self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry) def timerEditFinished(self, answer): @@ -192,13 +210,16 @@ class EPGSelection(Screen): self["now_text"].hide() self["next_text"].hide() self["more_text"].hide() + self["key_red"].setText("") else: if state == 1: + self["key_red"].setText("Zap") self["now_button_sel"].show() self["now_button"].hide() else: self["now_button"].show() self["now_button_sel"].hide() + self["key_red"].setText("") if state == 2: self["next_button_sel"].show() @@ -217,7 +238,7 @@ class EPGSelection(Screen): def onSelectionChanged(self): if self.type == EPG_TYPE_MULTI: count = self["list"].getCurrentChangeCount() - if self.asked_specific_time: + if self.ask_time != -1: self.applyButtonState(0) elif count > 1: self.applyButtonState(3)