Merge branch 'master' of /home/tmbinc/enigma2-git into tmbinc/FixTimingBugs
[enigma2.git] / lib / python / Components / UsageConfig.py
1 from Components.Harddisk import harddiskmanager
2 from config import ConfigSubsection, ConfigYesNo, config, ConfigSelection, ConfigText, ConfigNumber, ConfigSet, ConfigLocations
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 = "600", choices = [
21                 ("0", _("no standby")), ("10", "10 " + _("seconds")), ("30", "30 " + _("seconds")),
22                 ("60", "1 " + _("minute")), ("120", "2 " + _("minutes")),
23                 ("300", "5 " + _("minutes")), ("600", "10 " + _("minutes")), ("1200", "20 " + _("minutes")),
24                 ("1800", "30 " + _("minutes")), ("3600", "1 " + _("hour")), ("7200", "2 " + _("hours")),
25                 ("14400", "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.allowed_timeshift_paths = ConfigLocations(default = ["/media/hdd/"])
34         config.usage.timeshift_path = ConfigText(default = "/media/hdd")
35
36         config.usage.on_movie_start = ConfigSelection(default = "ask", choices = [
37                 ("ask", _("Ask user")), ("resume", _("Resume from last position")), ("beginning", _("Start from the beginning")) ])
38         config.usage.on_movie_stop = ConfigSelection(default = "ask", choices = [
39                 ("ask", _("Ask user")), ("movielist", _("Return to movie list")), ("quit", _("Return to previous service")) ])
40         config.usage.on_movie_eof = ConfigSelection(default = "ask", choices = [
41                 ("ask", _("Ask user")), ("movielist", _("Return to movie list")), ("quit", _("Return to previous service")), ("pause", _("Pause movie at end")) ])
42
43         config.usage.setup_level = ConfigSelection(default = "intermediate", choices = [
44                 ("simple", _("Simple")),
45                 ("intermediate", _("Intermediate")),
46                 ("expert", _("Expert")) ])
47
48         config.usage.on_long_powerpress = ConfigSelection(default = "show_menu", choices = [
49                 ("show_menu", _("show shutdown menu")),
50                 ("shutdown", _("immediate shutdown")) ] )
51
52         config.usage.alternatives_priority = ConfigSelection(default = "0", choices = [
53                 ("0", "DVB-S/-C/-T"),
54                 ("1", "DVB-S/-T/-C"),
55                 ("2", "DVB-C/-S/-T"),
56                 ("3", "DVB-C/-T/-S"),
57                 ("4", "DVB-T/-C/-S"),
58                 ("5", "DVB-T/-S/-C") ])
59
60         config.usage.blinking_display_clock_during_recording = ConfigYesNo(default = False)
61         config.usage.load_length_of_movies_in_moviellist = ConfigYesNo(default = True)
62         
63         def TunerTypePriorityOrderChanged(configElement):
64                 setTunerTypePriorityOrder(int(configElement.value))
65         config.usage.alternatives_priority.addNotifier(TunerTypePriorityOrderChanged)
66
67         def setHDDStandby(configElement):
68                 for hdd in harddiskmanager.HDDList():
69                         hdd[1].setIdleTime(int(configElement.value))
70         config.usage.hdd_standby.addNotifier(setHDDStandby)
71
72         def set12VOutput(configElement):
73                 if configElement.value == "on":
74                         Misc_Options.getInstance().set_12V_output(1)
75                 elif configElement.value == "off":
76                         Misc_Options.getInstance().set_12V_output(0)
77         config.usage.output_12V.addNotifier(set12VOutput)
78
79         SystemInfo["12V_Output"] = Misc_Options.getInstance().detected_12V_output()
80
81         config.usage.keymap = ConfigText(default = "/usr/share/enigma2/keymap.xml")
82
83         config.seek = ConfigSubsection()
84         config.seek.selfdefined_13 = ConfigNumber(default=15)
85         config.seek.selfdefined_46 = ConfigNumber(default=60)
86         config.seek.selfdefined_79 = ConfigNumber(default=300)
87
88         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])
89         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])
90         config.seek.speeds_slowmotion = ConfigSet(default=[2, 4, 8], choices=[2, 4, 6, 8, 12, 16, 25])
91
92         config.seek.enter_forward = ConfigSelection(default = "2", choices = ["2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
93         config.seek.enter_backward = ConfigSelection(default = "1", choices = ["1", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
94         config.seek.stepwise_minspeed = ConfigSelection(default = "16", choices = ["Never", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
95         config.seek.stepwise_repeat = ConfigSelection(default = "3", choices = ["2", "3", "4", "5", "6"])
96
97         config.seek.on_pause = ConfigSelection(default = "play", choices = [
98                 ("play", _("Play")),
99                 ("step", _("Singlestep (GOP)")),
100                 ("last", _("Last speed")) ])
101
102         def updateEnterForward(configElement):
103                 if not configElement.value:
104                         configElement.value = [2]
105                 updateChoices(config.seek.enter_forward, configElement.value)
106
107         config.seek.speeds_forward.addNotifier(updateEnterForward, immediate_feedback = False)
108
109         def updateEnterBackward(configElement):
110                 if not configElement.value:
111                         configElement.value = [2]
112                 updateChoices(config.seek.enter_backward, configElement.value)
113
114         config.seek.speeds_backward.addNotifier(updateEnterBackward, immediate_feedback = False)
115
116 def updateChoices(sel, choices):
117         if choices:
118                 defval = None
119                 val = int(sel.value)
120                 if not val in choices:
121                         tmp = choices[:]
122                         tmp.reverse()
123                         for x in tmp:
124                                 if x < val:
125                                         defval = str(x)
126                                         break
127                 sel.setChoices(map(str, choices), defval)