simplify GUIcreate/createWidget, fix base class order
[enigma2.git] / lib / python / Components / ConfigList.py
1 from HTMLComponent import *
2 from GUIComponent import *
3 from config import *
4
5 from enigma import eListbox, eListboxPythonConfigContent
6
7 class ConfigList(HTMLComponent, GUIComponent, object):
8         def __init__(self, list):
9                 GUIComponent.__init__(self)
10                 self.l = eListboxPythonConfigContent()
11                 self.l.setSeperation(100)
12                 self.list = list
13                 self.onSelectionChanged = [ ]
14         
15         def toggle(self):
16                 selection = self.getCurrent()
17                 selection[1].toggle()
18                 self.invalidateCurrent()
19
20         def handleKey(self, key):
21                 selection = self.getCurrent()
22                 if selection[1].parent.enabled:
23                         selection[1].handleKey(key)
24                         self.invalidateCurrent()
25
26         def getCurrent(self):
27                 return self.l.getCurrentSelection()
28         
29         def invalidateCurrent(self):
30                 self.l.invalidateEntry(self.l.getCurrentSelectionIndex())
31                 
32         def invalidate(self, entry):
33                 i = 0
34                 for x in self.__list:
35                         if (entry.getConfigPath() == x[1].parent.getConfigPath()):
36                                 self.l.invalidateEntry(i)
37                         i += 1
38
39         GUI_WIDGET = eListbox
40         
41         def selectionChanged(self):
42                 for x in self.onSelectionChanged:
43                         x()
44
45         def postWidgetCreate(self, instance):
46                 instance.setContent(self.l)
47                 instance.selectionChanged.get().append(self.selectionChanged)
48         
49         def setList(self, list):
50                 self.__list = list
51                 self.l.setList(self.__list)
52
53         def getList(self):
54                 return self.__list
55
56         list = property(getList, setList)