Remove unused fields from control files.
[vuplus_dvbapp-plugin] / ac3lipsync / 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         ]
52         
53         ConfigListScreen.__init__(self, self.list)
54
55         self["config"].list = self.list
56
57         self.skin_path = plugin_path
58
59         # Plugin Information
60         self["PluginInfo"] = Label(_("Plugin: %(plugin)s , Version: %(version)s") %dict(plugin=PLUGIN_BASE,version=PLUGIN_VERSION))
61
62         # BUTTONS
63         self["key_red"] = Button(_("Cancel"))
64         self["key_green"] = Button(_("Save"))
65         self["key_yellow"] = Button(_(" "))
66         self["key_blue"] = Button(" ")
67
68         self["setupActions"] = NumberActionMap(["SetupActions", "ColorActions"],
69         {
70             "save": self.save,
71             "cancel": self.cancel,
72             "green": self.save,
73             "red": self.cancel,
74             "ok": self.save,
75         }, -2)
76
77     def save(self):
78         for x in self.list:
79             x[1].save()
80         self.close()
81
82     def cancel(self):
83         for x in self["config"].list:
84             x[1].cancel()
85         self.close()