Fix network test.
[vuplus_dvbapp] / lib / python / Components / ParentalControlList.py
1 from MenuList import MenuList
2 from Components.ParentalControl import IMG_WHITESERVICE, IMG_WHITEBOUQUET, IMG_BLACKSERVICE, IMG_BLACKBOUQUET
3 from Tools.Directories import SCOPE_SKIN_IMAGE, resolveFilename
4
5 from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT
6 from Tools.LoadPixmap import LoadPixmap
7 import skin
8
9 #Now there is a list of pictures instead of one...
10 entryPicture = {}
11
12 entryPicture[IMG_BLACKSERVICE] = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock.png"))
13 entryPicture[IMG_BLACKBOUQUET] = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lockBouquet.png"))
14 entryPicture[IMG_WHITESERVICE] = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/unlock.png"))
15 entryPicture[IMG_WHITEBOUQUET] = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/unlockBouquet.png"))
16
17 def ParentalControlEntryComponent(service, name, protectionType):
18         locked = protectionType[0]
19         sImage = protectionType[1]
20         res = [
21                 (service, name, locked),
22                 (eListboxPythonMultiContent.TYPE_TEXT, 80, 5, 300, 50, 0, RT_HALIGN_LEFT, name)
23         ]
24         #Changed logic: The image is defined by sImage, not by locked anymore
25         if sImage != "":
26                 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 32, 32, entryPicture[sImage]))
27         return res
28
29 class ParentalControlList(MenuList):
30         def __init__(self, list, enableWrapAround = False):
31                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
32                 font = skin.fonts.get("ParentalControlList", ("Regular", 20, 32))
33                 self.l.setFont(0, gFont(font[0], font[1]))
34                 self.l.setItemHeight(font[2])
35
36         def toggleSelectedLock(self):
37                 from Components.ParentalControl import parentalControl
38                 print "self.l.getCurrentSelection():", self.l.getCurrentSelection()
39                 print "self.l.getCurrentSelectionIndex():", self.l.getCurrentSelectionIndex()
40                 curSel = self.l.getCurrentSelection()
41                 if curSel[0][2]:
42                         parentalControl.unProtectService(self.l.getCurrentSelection()[0][0])
43                 else:
44                         parentalControl.protectService(self.l.getCurrentSelection()[0][0])
45                 #Instead of just negating the locked- flag, now I call the getProtectionType every time...
46                 self.list[self.l.getCurrentSelectionIndex()] = ParentalControlEntryComponent(curSel[0][0], curSel[0][1], parentalControl.getProtectionType(curSel[0][0]))
47                 self.l.setList(self.list)