Merge branch 'master' of git.opendreambox.org:/git/enigma2
[enigma2.git] / lib / python / Components / ParentalControlList.py
1 from MenuList import MenuList
2 from Components.ParentalControl import parentalControl
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 lockPicture = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock.png"))
9
10 def ParentalControlEntryComponent(service, name, locked = True):
11         res = [
12                 (service, name, locked),
13                 (eListboxPythonMultiContent.TYPE_TEXT, 80, 5, 300, 50, 0, RT_HALIGN_LEFT, name)
14         ]
15         if locked:
16                 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 32, 32, lockPicture))
17         return res
18
19 class ParentalControlList(MenuList):
20         def __init__(self, list, enableWrapAround = False):
21                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
22                 self.l.setFont(0, gFont("Regular", 20))
23                 self.l.setItemHeight(32)
24
25         def toggleSelectedLock(self):
26                 print "self.l.getCurrentSelection():", self.l.getCurrentSelection()
27                 print "self.l.getCurrentSelectionIndex():", self.l.getCurrentSelectionIndex()
28                 self.list[self.l.getCurrentSelectionIndex()] = ParentalControlEntryComponent(self.l.getCurrentSelection()[0][0], self.l.getCurrentSelection()[0][1], not self.l.getCurrentSelection()[0][2]);
29                 if self.l.getCurrentSelection()[0][2]:
30                         parentalControl.protectService(self.l.getCurrentSelection()[0][0])
31                 else:
32                         parentalControl.unProtectService(self.l.getCurrentSelection()[0][0])    
33                 self.l.setList(self.list)