use 100 as the default volume-value
[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, iServiceInformation
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                 service = session.nav.getCurrentService()
50                 if service is not None:
51                         self.info = service.info()
52                 else:
53                         self.info = None
54                 
55                 Labels = ( ("Name",  ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName()),
56                                    ("Provider", self.getValue(iServiceInformation.sProvider)),
57                                    ("VideoPID", self.getValue(iServiceInformation.sVideoPID)),
58                                    ("AudioPID", self.getValue(iServiceInformation.sAudioPID)),
59                                    ("PCRPID", self.getValue(iServiceInformation.sPCRPID)),
60                                    ("PMTPID", self.getValue(iServiceInformation.sPMTPID)),
61                                    ("TXTPID", self.getValue(iServiceInformation.sTXTPID)),
62                                    ("Videoformat", self.getValue(iServiceInformation.sAspect)),
63                                    ("TSID", self.getValue(iServiceInformation.sTSID)),
64                                    ("ONID", self.getValue(iServiceInformation.sONID)),
65                                    ("SID", self.getValue(iServiceInformation.sSID)),
66                                    ("Namespace", self.getValue(iServiceInformation.sNamespace)))
67         
68                 tlist = [ ]
69
70                 for item in Labels:
71                         value = item[1]
72                         tlist.append(ServiceInfoListEntry(item[0]+":", value))          
73
74                 self["infolist"] = ServiceInfoList(tlist)
75
76         def getValue(self, what):
77                 if self.info is None:
78                         return ""
79                 
80                 v = self.info.getInfo(what)
81                 if v == -2:
82                         v = self.info.getInfoString(what)
83                 elif v != -1:
84                         if what in [iServiceInformation.sVideoPID, 
85                                         iServiceInformation.sAudioPID, iServiceInformation.sPCRPID, iServiceInformation.sPMTPID, 
86                                         iServiceInformation.sTXTPID, iServiceInformation.sTSID, iServiceInformation.sONID,
87                                         iServiceInformation.sSID]:
88                                 v = "0x%04x (%dd)" % (v, v)
89                         elif what in [iServiceInformation.sNamespace]:
90                                 v = "0x%08x" % (v)
91                         else:
92                                 v = str(v)
93                 else:
94                         v = "N/A"
95
96                 return v