4.3.0r13
[enigma2.git] / usr / lib / enigma2 / 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         FULL_DESCRIPTION = 3
9         ID = 4
10
11         def __init__(self, type):
12                 Converter.__init__(self, type)
13                 if type == "Description":
14                         self.type = self.SHORT_DESCRIPTION
15                 elif type == "ExtendedDescription":
16                         self.type = self.EXTENDED_DESCRIPTION
17                 elif type == "FullDescription":
18                         self.type = self.FULL_DESCRIPTION
19                 elif type == "ID":
20                         self.type = self.ID
21                 else:
22                         self.type = self.NAME
23
24         @cached
25         def getText(self):
26                 event = self.source.event
27                 if event is None:
28                         return ""
29                         
30                 if self.type == self.NAME:
31                         return event.getEventName()
32                 elif self.type == self.SHORT_DESCRIPTION:
33                         return event.getShortDescription()
34                 elif self.type == self.EXTENDED_DESCRIPTION:
35                         return event.getExtendedDescription()
36                 elif self.type == self.FULL_DESCRIPTION :
37                         desc = event.getShortDescription()
38                         if desc:
39                                 desc = "%s\n\n" %(desc,)
40                         desc = "%s%s" %(desc, event.getExtendedDescription())
41                         return desc
42                 elif self.type == self.ID:
43                         return str(event.getEventId())
44                 
45         text = property(getText)