[Ai.HD] Add dynamic Picons ServiceSelection-screens
[enigma2-plugins.git] / aihdcontroler / src / comp / valiRefString.py
1 #######################################################################
2 #
3 #
4 #    ReferenceToString for Dreambox/Enigma-2
5 #    Coded by Vali (c)2011
6 #    Support: www.dreambox-tools.info
7 #
8 #
9 #  This plugin is licensed under the Creative Commons 
10 #  Attribution-NonCommercial-ShareAlike 3.0 Unported License.
11 #  To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
12 #  or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
13 #
14 #  Alternatively, this plugin may be distributed and executed on hardware which
15 #  is licensed by Dream Multimedia GmbH.
16 #
17 #
18 #  This plugin is NOT free software. It is open source, you are allowed to
19 #  modify it (if you keep the license), but it may not be commercially 
20 #  distributed other than under the conditions noted above.
21 #
22 #
23 #######################################################################
24
25 from Components.Converter.Converter import Converter
26 from Components.Element import cached
27 from Screens.InfoBar import InfoBar
28
29 class valiRefString(Converter, object):
30         CURRENT = 0
31         EVENT = 1
32         def __init__(self, type):
33                 Converter.__init__(self, type)
34                 self.CHANSEL = None
35                 self.type = {
36                                 "CurrentRef": self.CURRENT,
37                                 "ServicelistRef": self.EVENT
38                         }[type]
39
40         @cached
41         def getText(self):
42                 if (self.type == self.EVENT):
43                         return str(self.source.service.toString())
44                 elif (self.type == self.CURRENT):
45                         if self.CHANSEL == None:
46                                 self.CHANSEL = InfoBar.instance.servicelist
47                         vSrv = self.CHANSEL.servicelist.getCurrent()
48                         return str(vSrv.toString())
49                 else:
50                         return "na"
51
52         text = property(getText)