From 1109344c9409572f9829e46971b71a7fe1d3c8cc Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Sun, 22 Jul 2007 17:38:25 +0000 Subject: [PATCH] show event information of current selected event in channelselection --- data/skin_default.xml | 28 +++++++++++++++---- .../Components/Converter/ClockToText.py | 12 ++++++++ lib/python/Components/Converter/EventName.py | 2 +- lib/python/Components/ServiceList.py | 15 ++++++++++ lib/python/Components/Sources/Makefile.am | 2 +- lib/python/Screens/ChannelSelection.py | 20 ++++++++++++- 6 files changed, 70 insertions(+), 9 deletions(-) diff --git a/data/skin_default.xml b/data/skin_default.xml index d5d5a8d6..5bec0cfb 100644 --- a/data/skin_default.xml +++ b/data/skin_default.xml @@ -238,12 +238,28 @@ - - - - - - + + + + + + + + + + StartTime + + + + EndTime + Format:- %H:%M + + + Name + + + ExtendedDescription + diff --git a/lib/python/Components/Converter/ClockToText.py b/lib/python/Components/Converter/ClockToText.py index 5cc709f2..65e431bc 100644 --- a/lib/python/Components/Converter/ClockToText.py +++ b/lib/python/Components/Converter/ClockToText.py @@ -7,6 +7,7 @@ class ClockToText(Converter, object): WITH_SECONDS = 1 IN_MINUTES = 2 DATE = 3 + FORMAT = 4 # add: date, date as string, weekday, ... # (whatever you need!) @@ -19,6 +20,9 @@ class ClockToText(Converter, object): self.type = self.IN_MINUTES elif type == "Date": self.type = self.DATE + elif type.find("Format") != -1: + self.type = self.FORMAT + self.fmt_string = type[7:] else: self.type = self.DEFAULT @@ -40,6 +44,14 @@ class ClockToText(Converter, object): return "%02d:%02d" % (t.tm_hour, t.tm_min) elif self.type == self.DATE: return strftime("%A %B %d, %Y", t) + elif self.type == self.FORMAT: + spos = self.fmt_string.find('%') + if spos > 0: + s1 = self.fmt_string[:spos] + s2 = strftime(self.fmt_string[spos:], t) + return str(s1+s2) + else: + return strftime(self.fmt_string, t) else: return "???" diff --git a/lib/python/Components/Converter/EventName.py b/lib/python/Components/Converter/EventName.py index 051e1ea5..b1ec62d0 100644 --- a/lib/python/Components/Converter/EventName.py +++ b/lib/python/Components/Converter/EventName.py @@ -22,7 +22,7 @@ class EventName(Converter, object): def getText(self): event = self.source.event if event is None: - return "N/A" + return "" if self.type == self.NAME: return event.getEventName() diff --git a/lib/python/Components/ServiceList.py b/lib/python/Components/ServiceList.py index a113eb9b..4a27c768 100644 --- a/lib/python/Components/ServiceList.py +++ b/lib/python/Components/ServiceList.py @@ -41,6 +41,19 @@ class ServiceList(HTMLComponent, GUIComponent): self.root = None self.mode = self.MODE_NORMAL + self.onSelectionChanged = [ ] + + def connectSelChanged(self, fnc): + if not fnc in self.onSelectionChanged: + self.onSelectionChanged.append(fnc) + + def disconnectSelChanged(self, fnc): + if fnc in self.onSelectionChanged: + self.onSelectionChanged.remove(fnc) + + def selectionChanged(self): + for x in self.onSelectionChanged: + x() def setCurrent(self, ref): self.l.setCurrent(ref) @@ -93,6 +106,7 @@ class ServiceList(HTMLComponent, GUIComponent): def postWidgetCreate(self, instance): instance.setWrapAround(True) instance.setContent(self.l) + instance.selectionChanged.get().append(self.selectionChanged) self.setMode(self.mode) def getRoot(self): @@ -122,6 +136,7 @@ class ServiceList(HTMLComponent, GUIComponent): self.l.setRoot(root, justSet) if not justSet: self.l.sort() + self.selectionChanged() def removeCurrent(self): self.l.removeCurrent() diff --git a/lib/python/Components/Sources/Makefile.am b/lib/python/Components/Sources/Makefile.am index 2e0dd449..43efcf5c 100644 --- a/lib/python/Components/Sources/Makefile.am +++ b/lib/python/Components/Sources/Makefile.am @@ -3,4 +3,4 @@ installdir = $(LIBDIR)/enigma2/python/Components/Sources install_PYTHON = \ __init__.py Clock.py EventInfo.py Source.py List.py CurrentService.py \ FrontendStatus.py Boolean.py Config.py ServiceList.py RdsDecoder.py StreamService.py \ - StaticText.py CanvasSource.py + StaticText.py CanvasSource.py ServiceEvent.py diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py index 0fe625bb..94cf1ae2 100644 --- a/lib/python/Screens/ChannelSelection.py +++ b/lib/python/Screens/ChannelSelection.py @@ -11,6 +11,7 @@ from Tools.NumericalTextInput import NumericalTextInput from Components.NimManager import nimmanager from Components.Sources.Clock import Clock from Components.Sources.RdsDecoder import RdsDecoder +from Components.Sources.ServiceEvent import ServiceEvent from Components.Input import Input from Components.ParentalControl import parentalControl from Components.Pixmap import Pixmap @@ -269,6 +270,22 @@ class ChannelContextMenu(Screen): self.csel.startMarkedEdit(EDIT_ALTERNATIVES) self.close() +class SelectionEventInfo: + def __init__(self): + self["ServiceEvent"] = ServiceEvent() + self.servicelist.connectSelChanged(self.__selectionChanged) + self.timer = eTimer() + self.timer.timeout.get().append(self.updateEventInfo) + self.onShown.append(self.__selectionChanged) + + def __selectionChanged(self): + if self.execing: + self.timer.start(100, True) + + def updateEventInfo(self): + cur = self.getCurrentSelection() + self["ServiceEvent"].newService(cur) + class ChannelSelectionEPG: def __init__(self): self["ChannelSelectEPGActions"] = ActionMap(["ChannelSelectEPGActions"], @@ -1018,11 +1035,12 @@ config.radio.lastroot = ConfigText() config.servicelist = ConfigSubsection() config.servicelist.lastmode = ConfigText(default = "tv") -class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG): +class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG, SelectionEventInfo): def __init__(self, session): ChannelSelectionBase.__init__(self,session) ChannelSelectionEdit.__init__(self) ChannelSelectionEPG.__init__(self) + SelectionEventInfo.__init__(self) self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"], { -- 2.30.2