aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/ConfigList.py
blob: 0181ef02873e38a51ba7288387802515427ca420 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from HTMLComponent import *
from GUIComponent import *
from config import *

from enigma import eListbox, eListboxPythonConfigContent

class ConfigList(HTMLComponent, GUIComponent, object):
	def __init__(self, list):
		GUIComponent.__init__(self)
		self.l = eListboxPythonConfigContent()
		self.l.setSeperation(100)
		self.list = list
		self.onSelectionChanged = [ ]
	
	def toggle(self):
		selection = self.getCurrent()
		selection[1].toggle()
		self.invalidateCurrent()

	def handleKey(self, key):
		selection = self.getCurrent()
		if selection[1].parent.enabled:
			selection[1].handleKey(key)
			self.invalidateCurrent()

	def getCurrent(self):
		return self.l.getCurrentSelection()
	
	def invalidateCurrent(self):
		self.l.invalidateEntry(self.l.getCurrentSelectionIndex())
		
	def invalidate(self, entry):
		i = 0
		for x in self.__list:
			if (entry.getConfigPath() == x[1].parent.getConfigPath()):
				self.l.invalidateEntry(i)
			i += 1

	GUI_WIDGET = eListbox
	
	def selectionChanged(self):
		for x in self.onSelectionChanged:
			x()

	def postWidgetCreate(self, instance):
		instance.setContent(self.l)
		instance.selectionChanged.get().append(self.selectionChanged)
	
	def setList(self, list):
		self.__list = list
		self.l.setList(self.__list)

	def getList(self):
		return self.__list

	list = property(getList, setList)