show event information of current selected event in channelselection
[enigma2.git] / lib / python / Components / Converter / EventName.py
1 from Components.Converter.Converter import Converter
2 from Components.Element import cached
3
4 class EventName(Converter, object):
5         NAME = 0
6         SHORT_DESCRIPTION = 1
7         EXTENDED_DESCRIPTION = 2
8         ID = 3
9         
10         def __init__(self, type):
11                 Converter.__init__(self, type)
12                 if type == "Description":
13                         self.type = self.SHORT_DESCRIPTION
14                 elif type == "ExtendedDescription":
15                         self.type = self.EXTENDED_DESCRIPTION
16                 elif type == "ID":
17                         self.type = self.ID
18                 else:
19                         self.type = self.NAME
20
21         @cached
22         def getText(self):
23                 event = self.source.event
24                 if event is None:
25                         return ""
26                         
27                 if self.type == self.NAME:
28                         return event.getEventName()
29                 elif self.type == self.SHORT_DESCRIPTION:
30                         return event.getShortDescription()
31                 elif self.type == self.EXTENDED_DESCRIPTION:
32                         return event.getExtendedDescription()
33                 elif self.type == self.ID:
34                         return str(event.getEventId())
35                 
36         text = property(getText)