4574e0fd086e0c1a7590ef2485d7eea7b4a066fe
[vuplus_dvbapp] / lib / python / Plugins / SystemPlugins / ManualFancontrol / plugin.py
1 from Screens.Screen import Screen
2 from Components.ConfigList import ConfigListScreen
3 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigInteger
4 from Components.ActionMap import ActionMap,NumberActionMap
5 from Screens.MessageBox import MessageBox
6 from Components.Sources.StaticText import StaticText
7 from Plugins.Plugin import PluginDescriptor
8 from Plugins.SystemPlugins.ManualFancontrol.InstandbyOn import instandbyon
9
10 class ManualFancontrol(Screen,ConfigListScreen):
11         skin = """
12                         <screen name="ManualFancontrol" position="center,center" size="560,300" title="Fancontrol Settings in Standby mode" >
13                         <ePixmap pixmap="Vu_HD/buttons/red.png" position="10,10" size="25,25" alphatest="on" />
14                         <ePixmap pixmap="Vu_HD/buttons/green.png" position="290,10" size="25,25" alphatest="on" />
15                         <widget source="key_red" render="Label" position="40,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
16                         <widget source="key_green" render="Label" position="320,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
17                         <widget name="config" zPosition="2" position="5,50" size="550,200" scrollbarMode="showOnDemand" transparent="1" />
18                         <widget source="current" render="Label" position="150,270" zPosition="1" size="280,30" font="Regular;20" halign="center" valign="center" transparent="1" />
19                         </screen>"""
20
21         def __init__(self,session):
22                 Screen.__init__(self,session)
23                 print "init"
24                 self.setup_title="TestSetupTitle"
25                 self.session = session
26                 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
27                 {
28                         "ok": self.keySave,
29                         "cancel": self.keyCancel,
30                         "red": self.keyCancel,
31                         "green": self.keySave,
32                 }, -2)
33                 self.list = []
34                 ConfigListScreen.__init__(self, self.list,session = self.session)
35                 self["key_red"] = StaticText(_("Cancel"))
36                 self["key_green"] = StaticText(_("Save"))
37                 self["current"] = StaticText(_(" "))
38                 self.createSetup()
39
40         def displayCurrentValue(self):
41                 cur = self["config"].getCurrent()[0]
42                 val = self["config"].getCurrent()[1].value
43                 currrent_val = cur+" : "+str(val)
44                 self["current"].setText(_(currrent_val))
45                 print currrent_val
46
47         def selectionChanged(self):
48                 self.displayCurrentValue()
49                 if self["config"].getCurrent() == self.pwmEntry:
50                         instandbyon.setPWM(self["config"].getCurrent()[1].value)
51
52         def keyLeft(self):
53                 ConfigListScreen.keyLeft(self)
54                 self.newConfig()
55                 self.selectionChanged()
56
57         def keyRight(self):
58                 ConfigListScreen.keyRight(self)
59                 self.newConfig()
60                 self.selectionChanged()
61
62         def createSetup(self):
63                 self.list = []
64                 self.standbyEntry = getConfigListEntry(_("FanOFF InStanby"), config.plugins.simplefancontrols.standbymode)
65                 self.pwmEntry = getConfigListEntry(_("PWM value"), config.plugins.simplefancontrols.pwmvalue)
66                 self.list.append( self.standbyEntry )
67                 self.list.append( self.pwmEntry )
68                 self["config"].list = self.list
69                 self["config"].l.setList(self.list)
70                 if not self.displayCurrentValue in self["config"].onSelectionChanged:
71                         self["config"].onSelectionChanged.append(self.displayCurrentValue)
72
73         def newConfig(self):
74                 if self["config"].getCurrent() == self.standbyEntry:
75                         self.createSetup()
76
77         def keySave(self):
78                 ConfigListScreen.keySave(self)
79
80         def keyCancel(self):
81                 ConfigListScreen.keyCancel(self)
82
83 def main(session, **kwargs):
84         session.open(ManualFancontrol)
85
86 def Plugins(**kwargs):
87         return [PluginDescriptor(name=_("Manual Fan control"), description="setup Fancontol inStandby mode", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = True, fnc=main)]