favs only (as default)
[enigma2.git] / lib / python / Screens / ServiceInfo.py
1 from Components.HTMLComponent import *
2 from Components.GUIComponent import *
3 from Screen import Screen
4 from Components.ActionMap import ActionMap
5 from Components.Label import Label
6 from Components.MenuList import MenuList
7 from ServiceReference import ServiceReference
8 from enigma import eListboxPythonMultiContent, eListbox, gFont
9
10 RT_HALIGN_LEFT = 0
11
12 def ServiceInfoListEntry(a, b):
13         res = [ ]
14
15         #PyObject *px, *py, *pwidth, *pheight, *pfnt, *pstring, *pflags;
16         res.append((0, 0, 200, 30, 0, RT_HALIGN_LEFT, ""))
17         res.append((0, 0, 150, 25, 0, RT_HALIGN_LEFT, a))
18         res.append((170, 0, 150, 25, 0, RT_HALIGN_LEFT, b))
19
20         return res
21
22 class ServiceInfoList(HTMLComponent, GUIComponent):
23         def __init__(self, source):
24                 GUIComponent.__init__(self)
25                 self.l = eListboxPythonMultiContent()
26                 self.list = source
27                 self.l.setList(self.list)
28                 self.l.setFont(0, gFont("Arial", 23))
29
30         def GUIcreate(self, parent):
31                 self.instance = eListbox(parent)
32                 self.instance.setContent(self.l)
33                 self.instance.setItemHeight(25)
34
35         def GUIdelete(self):
36                 self.instance.setContent(None)
37                 self.instance = None
38
39 class ServiceInfo(Screen):
40         def __init__(self, session):
41                 Screen.__init__(self, session)
42
43                 self["actions"] = ActionMap(["OkCancelActions"],
44                 {
45                         "ok": self.close,
46                         "cancel": self.close
47                 }, -1)
48         
49                 Labels = ( ("Name",  "ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName()"),
50                                    ("Provider", ),
51                                    ("VideoPID",""),
52                                    ("AudioPID",""),
53                                    ("PCRPID",""),
54                                    ("PMTPID",""),
55                                    ("TXTPID",""),
56                                    ("Videoformat",""),
57                                    ("TSID",""),
58                                    ("ONID",""),
59                                    ("SID",""),
60                                    ("Namespace",""))
61         
62                 tlist = [ ]
63
64                 for item in Labels:
65                         try:
66                                 value = str(eval(item[1]))
67                         except:
68                                 value = "N/A"
69                         tlist.append(ServiceInfoListEntry(item[0]+":", value))          
70
71                 self["infolist"] = ServiceInfoList(tlist)