[AudioSync] -do not call class AC3delay after every single standby-leave when plugin...
[enigma2-plugins.git] / audiosync / src / AC3setup.py
1 from AC3utils import PLUGIN_BASE, PLUGIN_VERSION
2 from Components.ActionMap import ActionMap, NumberActionMap
3 from Components.Button import Button
4 from Components.ConfigList import ConfigListScreen
5 from Components.Label import Label,MultiColorLabel
6 from Components.ProgressBar import ProgressBar
7 from Components.config import config, getConfigListEntry
8 from Screens.ChoiceBox import ChoiceBox
9 from Screens.MessageBox import MessageBox
10 from Screens.Screen import Screen
11 from __init__ import _
12 import os
13
14 class AC3LipSyncSetup(ConfigListScreen, Screen):
15     skin = """
16     <screen position="center,center" size="560,400" title="AC3 Lip Sync Setup">
17       <ePixmap pixmap="~/img/button-red.png" position="0,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
18       <ePixmap pixmap="~/img/button-green.png" position="140,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
19       <ePixmap pixmap="~/img/button-yellow.png" position="280,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
20       <ePixmap pixmap="~/img/button-blue.png" position="420,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
21       <widget name="key_red" position="0,0" zPosition="1" size="140,40"
22         font="Regular;20" valign="center" halign="center" backgroundColor="#9f1313" transparent="1"
23         shadowColor="#000000" shadowOffset="-1,-1" />
24       <widget name="key_green" position="140,0" zPosition="1" size="140,40"
25         font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1"
26         shadowColor="#000000" shadowOffset="-1,-1" />
27       <widget name="key_yellow" position="280,0" zPosition="1" size="140,40"
28         font="Regular;20" valign="center" halign="center" backgroundColor="#a08500" transparent="1"
29         shadowColor="#000000" shadowOffset="-1,-1" />
30       <widget name="key_blue" position="420,0" zPosition="1" size="140,40"
31         font="Regular;20" valign="center" halign="center" backgroundColor="#18188b" transparent="1"
32         shadowColor="#000000" shadowOffset="-1,-1" />
33       <widget name="config" position="10,40" size="540,320" scrollbarMode="showOnDemand" />
34       <widget name="PluginInfo" position="10,370" size="540,20" zPosition="4" font="Regular;18" foregroundColor="#cccccc" />
35     </screen>"""
36
37     def __init__(self, session, plugin_path):
38         Screen.__init__(self, session)
39
40         # Lets get a list of elements for the config list
41         self.list = [
42             getConfigListEntry(_("Outer Bound (+/-)"), config.plugins.AC3LipSync.outerBounds),
43             getConfigListEntry(_("Step in ms for arrow keys"), config.plugins.AC3LipSync.arrowStepSize),
44             getConfigListEntry(_("Wait time in ms before activation:"), config.plugins.AC3LipSync.activationDelay),
45             getConfigListEntry(_("Step in ms for keys '%s'") % ("1/3"), config.plugins.AC3LipSync.stepSize13),
46             getConfigListEntry(_("Step in ms for keys '%s'") % ("4/6"), config.plugins.AC3LipSync.stepSize46),
47             getConfigListEntry(_("Step in ms for keys '%s'") % ("7/9"), config.plugins.AC3LipSync.stepSize79),
48             getConfigListEntry(_("Step in ms for key %i") % (2), config.plugins.AC3LipSync.absoluteStep2),
49             getConfigListEntry(_("Step in ms for key %i") % (5), config.plugins.AC3LipSync.absoluteStep5),
50             getConfigListEntry(_("Step in ms for key %i") % (8), config.plugins.AC3LipSync.absoluteStep8),
51             getConfigListEntry(_("Restart audio after standby"), config.plugins.AC3LipSync.restartAudioAfterStandby),
52             getConfigListEntry(_("Restart audio after Enigma2 start"), config.plugins.AC3LipSync.restartAudioOnEnigma2Start),
53             getConfigListEntry(_("Restart audio delay (in sec)"), config.plugins.AC3LipSync.restartAudioDelay)
54         ]
55         
56         ConfigListScreen.__init__(self, self.list)
57
58         self["config"].list = self.list
59
60         self.skin_path = plugin_path
61
62         # Plugin Information
63         self["PluginInfo"] = Label(_("Plugin: %(plugin)s , Version: %(version)s") %dict(plugin=PLUGIN_BASE,version=PLUGIN_VERSION))
64
65         # BUTTONS
66         self["key_red"] = Button(_("Cancel"))
67         self["key_green"] = Button(_("Save"))
68         self["key_yellow"] = Button(_(" "))
69         self["key_blue"] = Button(" ")
70
71         self["setupActions"] = NumberActionMap(["SetupActions", "ColorActions"],
72         {
73             "save": self.save,
74             "cancel": self.cancel,
75             "green": self.save,
76             "red": self.cancel,
77             "ok": self.save,
78         }, -2)
79
80     def save(self):
81         for x in self.list:
82             x[1].save()
83         self.close()
84
85     def cancel(self):
86         for x in self["config"].list:
87             x[1].cancel()
88         self.close()