78f60f4f96427738fd87f4fa1f4e8d487506e22f
[enigma2.git] / lib / python / Screens / Satconfig.py
1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.ConfigList import ConfigList
4 from Components.config import *
5
6 class setupSelection:
7         def __init__(self, parent):
8                 self.parent = parent
9
10         def handleKey(self, key):
11                 if key == config.key["prevElement"]:
12                         self.parent.value = self.parent.value - 1
13                 if key == config.key["nextElement"]:
14                         self.parent.value = self.parent.value + 1
15
16         def __call__(self, selected):     #needed by configlist
17                 print "value" + self.parent.value
18                 return ("text", self.parent.vals[self.parent.value])
19
20 class setupElement:
21         def __init__(self, configPath, control, defaultValue, vals):
22                 self.configPath = configPath
23                 self.defaultValue = defaultValue
24                 self.controlType = control
25                 self.vals = vals
26                 self.notifierList = [ ]
27                 self.enabled = True
28                 self.value = self.defaultValue
29
30 class Satconfig(Screen):
31         def keyLeft(self):
32                 if (self["config"].getCurrent()[1].parent.enabled == True):
33                         self["config"].handleKey(config.key["prevElement"])
34         def keyRight(self):
35                 if (self["config"].getCurrent()[1].parent.enabled == True):
36                         self["config"].handleKey(config.key["nextElement"])
37
38         def __init__(self, session):
39                 Screen.__init__(self, session)
40
41                 self["actions"] = ActionMap(["SetupActions"],
42                         {
43                                 "cancel": self.close,
44                                 #"ok": self.close,
45                                 "left": self.keyLeft,
46                                 "right": self.keyRight,
47                         })
48
49                 blasel = setupElement("blub", setupSelection, 1, ("A", "B"))
50                 item = blasel.controlType(blasel)
51                 list = []
52                 list.append( ("Tuner-Slot",item) );
53                 self["config"] = ConfigList(list)