show servicename in eventview
[enigma2.git] / lib / python / Screens / EventView.py
1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.Label import Label
4 from Components.ScrollLabel import ScrollLabel
5 from enigma import eServiceEventPtr
6 from ServiceReference import ServiceReference
7
8 class EventView(Screen):
9         def __init__(self, session, Event, Ref, callback=None):
10                 Screen.__init__(self, session)
11                 self.cbFunc = callback
12                 self.currentService=None
13                 self["epg_description"] = ScrollLabel()
14                 self["datetime"] = Label()
15                 self["channel"] = Label()
16                 self["duration"] = Label()
17                 self["actions"] = ActionMap(["OkCancelActions", "EventViewActions"],
18                         {
19                                 "cancel": self.close,
20                                 "ok": self.close,
21                                 "pageUp": self.pageUp,
22                                 "pageDown": self.pageDown,
23                                 "prevEvent": self.prevEvent,
24                                 "nextEvent": self.nextEvent
25                         })
26                 self.setEvent(Event)
27                 self.setService(Ref)
28
29         def prevEvent(self):
30                 if self.cbFunc is not None:
31                         self.cbFunc(self.setEvent, -1)
32
33         def nextEvent(self):
34                 if self.cbFunc is not None:
35                         self.cbFunc(self.setEvent, +1)
36
37         def setService(self, service):
38                 self.currentService=service
39                 name = self.currentService.getServiceName()
40                 if name is not None:
41                         self["channel"].setText(name)
42                 else:
43                         self["channel"].setText("unknown service")
44
45         def setEvent(self, event):
46 #               FIXME .. how to set eWindow titlebar?
47 #               self.instance.setTitle(event.getEventName())
48                 text = event.getShortDescription()
49                 if len(text) > 0:
50                         text = text + '\n\n'
51                 text = text + event.getExtendedDescription()
52                 self["epg_description"].setText(text)
53                 self["datetime"].setText(event.getBeginTimeString())
54                 self["duration"].setText("%d min"%(event.getDuration()/60))
55
56         def pageUp(self):
57                 self["epg_description"].pageUp()
58         
59         def pageDown(self):
60                 self["epg_description"].pageDown()