show event information of current selected event in channelselection
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sun, 22 Jul 2007 17:38:25 +0000 (17:38 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sun, 22 Jul 2007 17:38:25 +0000 (17:38 +0000)
data/skin_default.xml
lib/python/Components/Converter/ClockToText.py
lib/python/Components/Converter/EventName.py
lib/python/Components/ServiceList.py
lib/python/Components/Sources/Makefile.am
lib/python/Screens/ChannelSelection.py

index d5d5a8d..5bec0cf 100644 (file)
                <widget name="transparent" zPosition="-1" position="0,0" size="100,107" backgroundColor="transparent" />
                <widget name="Dishpixmap" pixmap="dish.png" position="0,0" size="100,107" />
        </screen>
                <widget name="transparent" zPosition="-1" position="0,0" size="100,107" backgroundColor="transparent" />
                <widget name="Dishpixmap" pixmap="dish.png" position="0,0" size="100,107" />
        </screen>
-               <screen name="ChannelSelection" position="90,98" size="560,417" title="Channel Selection">
-               <widget name="list" position="0,45" size="560,364" scrollbarMode="showOnDemand" />
-               <widget name="key_red" position="0,0" size="140,40" backgroundColor="red" font="Regular;21" />
-               <widget name="key_green" position="140,0" size="140,40" backgroundColor="green" font="Regular;21" />
-               <widget name="key_yellow" position="280,0" size="140,40" backgroundColor="yellow" font="Regular;21" />
-               <widget name="key_blue" position="420,0" size="140,40" backgroundColor="blue" font="Regular;21" />
+       <screen name="ChannelSelection" position="90,98" size="560,417" title="Channel Selection">
+               <widget name="key_red" position="0,0" size="140,30" backgroundColor="red" font="Regular;21" />
+               <widget name="key_green" position="140,0" size="140,30" backgroundColor="green" font="Regular;21" />
+               <widget name="key_yellow" position="280,0" size="140,30" backgroundColor="yellow" font="Regular;21" />
+               <widget name="key_blue" position="420,0" size="140,30" backgroundColor="blue" font="Regular;21" />
+               <widget name="list" position="0,35" size="560,280" scrollbarMode="showOnDemand" />
+               <widget pixmap="key_green-fs8.png" position="10,90" zPosition="10" size="28,20" transparent="1" alphatest="on"/>
+               <ePixmap position="0,316" size="560,101" pixmap="border_eventinfo-fs8.png" zPosition="1" transparent="1" alphatest="on" />
+               <widget source="ServiceEvent" render="Label" position="4,322" size="55,22" font="Regular;19" >
+                       <convert type="EventTime">StartTime</convert>
+                       <convert type="ClockToText"></convert>
+               </widget>
+               <widget source="ServiceEvent" render="Label" position="62,322" size="65,22" font="Regular;19" >
+                       <convert type="EventTime">EndTime</convert>
+                       <convert type="ClockToText">Format:- %H:%M</convert>
+               </widget>
+               <widget source="ServiceEvent" render="Label" position="134,322" size="423,22" font="Regular;19" >
+                       <convert type="EventName">Name</convert>
+               </widget>
+               <widget source="ServiceEvent" render="Label" position="4,347" size="552,66" font="Regular;19" >
+                       <convert type="EventName">ExtendedDescription</convert>
+               </widget>
        </screen>
        <screen name="ChannelSelectionRadio" position="90,98" size="560,307" title="Channel Selection">
                <widget name="key_red" position="0,0" size="140,40" backgroundColor="red" font="Regular;21" />
        </screen>
        <screen name="ChannelSelectionRadio" position="90,98" size="560,307" title="Channel Selection">
                <widget name="key_red" position="0,0" size="140,40" backgroundColor="red" font="Regular;21" />
index 5cc709f..65e431b 100644 (file)
@@ -7,6 +7,7 @@ class ClockToText(Converter, object):
        WITH_SECONDS = 1
        IN_MINUTES = 2
        DATE = 3
        WITH_SECONDS = 1
        IN_MINUTES = 2
        DATE = 3
+       FORMAT = 4
        
        # add: date, date as string, weekday, ... 
        # (whatever you need!)
        
        # 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
                        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
 
                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)
                        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 "???"
 
                else:
                        return "???"
 
index 051e1ea..b1ec62d 100644 (file)
@@ -22,7 +22,7 @@ class EventName(Converter, object):
        def getText(self):
                event = self.source.event
                if event is None:
        def getText(self):
                event = self.source.event
                if event is None:
-                       return "N/A"
+                       return ""
                        
                if self.type == self.NAME:
                        return event.getEventName()
                        
                if self.type == self.NAME:
                        return event.getEventName()
index a113eb9..4a27c76 100644 (file)
@@ -41,6 +41,19 @@ class ServiceList(HTMLComponent, GUIComponent):
 
                self.root = None
                self.mode = self.MODE_NORMAL
 
                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)
 
        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)
        def postWidgetCreate(self, instance):
                instance.setWrapAround(True)
                instance.setContent(self.l)
+               instance.selectionChanged.get().append(self.selectionChanged)
                self.setMode(self.mode)
 
        def getRoot(self):
                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.l.setRoot(root, justSet)
                if not justSet:
                        self.l.sort()
+               self.selectionChanged()
 
        def removeCurrent(self):
                self.l.removeCurrent()
 
        def removeCurrent(self):
                self.l.removeCurrent()
index 2e0dd44..43efcf5 100644 (file)
@@ -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 \
 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
index 0fe625b..94cf1ae 100644 (file)
@@ -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.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
 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()
 
                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"],
 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")
 
 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)
        def __init__(self, session):
                ChannelSelectionBase.__init__(self,session)
                ChannelSelectionEdit.__init__(self)
                ChannelSelectionEPG.__init__(self)
+               SelectionEventInfo.__init__(self)
 
                self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
                        {
 
                self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
                        {