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