add some info to debug prints
[openblackhole/openblackhole-enigma2.git] / lib / python / Screens / SubserviceSelection.py
1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.MenuList import MenuList
4 from Components.Label import Label
5 from enigma import eServiceReferencePtr, eServiceReference, iSubserviceListPtr, eServiceEventPtrPtr
6
7 class SubserviceSelection(Screen):
8         def KeyOk(self):
9                 selection = self["subservices"].getCurrent()
10                 self.close(selection[1])
11         def Cancel(self):
12                 self.close(None)
13         def __init__(self, session, subservices, parent=None):
14                 Screen.__init__(self, session)
15
16                 self["actions"] = ActionMap(["OkCancelActions"], 
17                         {
18                                 "cancel": self.Cancel,
19                                 "ok": self.KeyOk,
20                         })
21
22                 self.subservices = subservices
23
24                 print "subservices", subservices
25                 tlist = []
26                 if isinstance(subservices, iSubserviceListPtr):
27                         n = subservices.getNumberOfSubservices()
28                         for x in range(n):
29                                 i = subservices.getSubservice(x)
30                                 tlist.append((i.getName(), i))
31                 elif isinstance(subservices, eServiceEventPtrPtr):
32                         n = subservices.getNumOfLinkageServices()
33                         for x in range(n):
34                                 i = subservices.getLinkageService(parent, x)
35                                 tlist.append((i.getName(), i))
36                 else:
37                         print "unknown type of subservices"
38
39                 self["subservices"] = MenuList(tlist)