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