add support for up to 128 LNBs
[enigma2.git] / lib / python / Components / UsageConfig.py
1 from Components.Harddisk import harddiskmanager
2 from config import ConfigSubsection, ConfigYesNo, config, ConfigSelection, ConfigText, ConfigNumber, ConfigSet
3 from enigma import Misc_Options, setTunerTypePriorityOrder;
4 from SystemInfo import SystemInfo
5 import os
6
7 def InitUsageConfig():
8         config.usage = ConfigSubsection();
9         config.usage.showdish = ConfigYesNo(default = False)
10         config.usage.multibouquet = ConfigYesNo(default = False)
11         config.usage.quickzap_bouquet_change = ConfigYesNo(default = False)
12         config.usage.e1like_radio_mode = ConfigYesNo(default = False)
13         config.usage.infobar_timeout = ConfigSelection(default = "5", choices = [
14                 ("0", _("no timeout")), ("1", "1 " + _("second")), ("2", "2 " + _("seconds")), ("3", "3 " + _("seconds")),
15                 ("4", "4 " + _("seconds")), ("5", "5 " + _("seconds")), ("6", "6 " + _("seconds")), ("7", "7 " + _("seconds")),
16                 ("8", "8 " + _("seconds")), ("9", "9 " + _("seconds")), ("10", "10 " + _("seconds"))])
17         config.usage.show_infobar_on_zap = ConfigYesNo(default = True)
18         config.usage.show_infobar_on_skip = ConfigYesNo(default = True)
19         config.usage.show_infobar_on_event_change = ConfigYesNo(default = True)
20         config.usage.hdd_standby = ConfigSelection(default = "120", choices = [
21                 ("0", _("no standby")), ("2", "10 " + _("seconds")), ("6", "30 " + _("seconds")),
22                 ("12", "1 " + _("minute")), ("24", "2 " + _("minutes")),
23                 ("60", "5 " + _("minutes")), ("120", "10 " + _("minutes")), ("240", "20 " + _("minutes")),
24                 ("241", "30 " + _("minutes")), ("242", "1 " + _("hour")), ("244", "2 " + _("hours")),
25                 ("248", "4 " + _("hours")) ])
26         config.usage.output_12V = ConfigSelection(default = "do not change", choices = [
27                 ("do not change", _("do not change")), ("off", _("off")), ("on", _("on")) ])
28
29         config.usage.pip_zero_button = ConfigSelection(default = "standard", choices = [
30                 ("standard", _("standard")), ("swap", _("swap PiP and main picture")),
31                 ("swapstop", _("move PiP to main picture")), ("stop", _("stop PiP")) ])
32
33         config.usage.on_movie_start = ConfigSelection(default = "ask", choices = [
34                 ("ask", _("Ask user")), ("resume", _("Resume from last position")), ("beginning", _("Start from the beginning")) ])
35         config.usage.on_movie_stop = ConfigSelection(default = "ask", choices = [
36                 ("ask", _("Ask user")), ("movielist", _("Return to movie list")), ("quit", _("Return to previous service")) ])
37         config.usage.on_movie_eof = ConfigSelection(default = "ask", choices = [
38                 ("ask", _("Ask user")), ("movielist", _("Return to movie list")), ("quit", _("Return to previous service")), ("pause", _("Pause movie at end")) ])
39
40         config.usage.setup_level = ConfigSelection(default = "intermediate", choices = [
41                 ("simple", _("Simple")),
42                 ("intermediate", _("Intermediate")),
43                 ("expert", _("Expert")) ])
44
45         config.usage.on_long_powerpress = ConfigSelection(default = "show_menu", choices = [
46                 ("show_menu", _("show shutdown menu")),
47                 ("shutdown", _("immediate shutdown")) ] )
48
49         config.usage.alternatives_priority = ConfigSelection(default = "0", choices = [
50                 ("0", "DVB-S/-C/-T"),
51                 ("1", "DVB-S/-T/-C"),
52                 ("2", "DVB-C/-S/-T"),
53                 ("3", "DVB-C/-T/-S"),
54                 ("4", "DVB-T/-C/-S"),
55                 ("5", "DVB-T/-S/-C") ])
56
57         config.usage.blinking_display_clock_during_recording = ConfigYesNo(default = False)
58
59         def TunerTypePriorityOrderChanged(configElement):
60                 setTunerTypePriorityOrder(int(configElement.value))
61         config.usage.alternatives_priority.addNotifier(TunerTypePriorityOrderChanged)
62
63         def setHDDStandby(configElement):
64                 for hdd in harddiskmanager.HDDList():
65                         os.system("hdparm -S%s %s" % (configElement.value, hdd[1].getDeviceName()))
66         config.usage.hdd_standby.addNotifier(setHDDStandby)
67
68         def set12VOutput(configElement):
69                 if configElement.value == "on":
70                         Misc_Options.getInstance().set_12V_output(1)
71                 elif configElement.value == "off":
72                         Misc_Options.getInstance().set_12V_output(0)
73         config.usage.output_12V.addNotifier(set12VOutput)
74
75         SystemInfo["12V_Output"] = Misc_Options.getInstance().detected_12V_output()
76
77         config.usage.keymap = ConfigText(default = "/usr/share/enigma2/keymap.xml")
78
79         config.seek = ConfigSubsection()
80         config.seek.selfdefined_13 = ConfigNumber(default=15)
81         config.seek.selfdefined_46 = ConfigNumber(default=60)
82         config.seek.selfdefined_79 = ConfigNumber(default=300)
83
84         config.seek.speeds_forward = ConfigSet(default=[2, 4, 8, 16, 32, 64, 128], choices=[2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128])
85         config.seek.speeds_backward = ConfigSet(default=[8, 16, 32, 64, 128], choices=[1, 2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128])
86         config.seek.speeds_slowmotion = ConfigSet(default=[2, 4, 8], choices=[2, 4, 6, 8, 12, 16, 25])
87
88         config.seek.enter_forward = ConfigSelection(default = "2", choices = ["2"])
89         config.seek.enter_backward = ConfigSelection(default = "2", choices = ["2"])
90         config.seek.stepwise_minspeed = ConfigSelection(default = "16", choices = ["Never", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
91         config.seek.stepwise_repeat = ConfigSelection(default = "3", choices = ["2", "3", "4", "5", "6"])
92
93         config.seek.on_pause = ConfigSelection(default = "play", choices = [
94                 ("play", _("Play")),
95                 ("step", _("Singlestep (GOP)")),
96                 ("last", _("Last speed")) ])
97
98         def updateEnterForward(configElement):
99                 if not configElement.value:
100                         configElement.value = [2]
101                 updateChoices(config.seek.enter_forward, configElement.value)
102
103         config.seek.speeds_forward.addNotifier(updateEnterForward)
104
105         def updateEnterBackward(configElement):
106                 if not configElement.value:
107                         configElement.value = [2]
108                 updateChoices(config.seek.enter_backward, configElement.value)
109
110         config.seek.speeds_backward.addNotifier(updateEnterBackward)
111
112 def updateChoices(sel, choices):
113         if choices:
114                 defval = None
115                 val = int(sel.value)
116                 if not val in choices:
117                         tmp = choices+[]
118                         tmp.reverse()
119                         for x in tmp:
120                                 if x < val:
121                                         defval = str(x)
122                                         break
123                 sel.setChoices(map(str, choices), defval)