needed update for avahi stuff
[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 = [ (service, name, locked) ]
12         res.append((eListboxPythonMultiContent.TYPE_TEXT, 80, 5, 300, 50, 0, RT_HALIGN_LEFT, name))
13         if locked:
14                 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 32, 32, lockPicture))
15         return res
16
17 class ParentalControlList(MenuList):
18         def __init__(self, list, enableWrapAround = False):
19                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
20                 self.l.setFont(0, gFont("Regular", 20))
21                 self.l.setItemHeight(32)
22
23         def toggleSelectedLock(self):
24                 print "self.l.getCurrentSelection():", self.l.getCurrentSelection()
25                 print "self.l.getCurrentSelectionIndex():", self.l.getCurrentSelectionIndex()
26                 self.list[self.l.getCurrentSelectionIndex()] = ParentalControlEntryComponent(self.l.getCurrentSelection()[0][0], self.l.getCurrentSelection()[0][1], not self.l.getCurrentSelection()[0][2]);
27                 if self.l.getCurrentSelection()[0][2]:
28                         parentalControl.protectService(self.l.getCurrentSelection()[0][0])
29                 else:
30                         parentalControl.unProtectService(self.l.getCurrentSelection()[0][0])    
31                 self.l.setList(self.list)