enigma2: 20120925 master -> 20121208 master
[enigma2.git] / usr / lib / enigma2 / python / Components / UsageConfig.py
1 from Components.Harddisk import harddiskmanager
2 from config import ConfigSubsection, ConfigYesNo, config, ConfigSelection, ConfigText, ConfigNumber, ConfigSet, ConfigLocations
3 from Tools.Directories import resolveFilename, SCOPE_HDD
4 from enigma import Misc_Options, setTunerTypePriorityOrder, eEnv;
5 from SystemInfo import SystemInfo
6
7 def InitUsageConfig():
8         config.usage = ConfigSubsection();
9         config.usage.showdish = ConfigYesNo(default = True)
10         config.usage.multibouquet = ConfigYesNo(default = False)
11         config.usage.multiepg_ask_bouquet = ConfigYesNo(default = False)
12
13         config.usage.quickzap_bouquet_change = ConfigYesNo(default = False)
14         config.usage.e1like_radio_mode = ConfigYesNo(default = False)
15         config.usage.infobar_timeout = ConfigSelection(default = "5", choices = [
16                 ("0", _("no timeout")), ("1", "1 " + _("second")), ("2", "2 " + _("seconds")), ("3", "3 " + _("seconds")),
17                 ("4", "4 " + _("seconds")), ("5", "5 " + _("seconds")), ("6", "6 " + _("seconds")), ("7", "7 " + _("seconds")),
18                 ("8", "8 " + _("seconds")), ("9", "9 " + _("seconds")), ("10", "10 " + _("seconds"))])
19         config.usage.show_infobar_on_zap = ConfigYesNo(default = True)
20         config.usage.show_infobar_on_skip = ConfigYesNo(default = True)
21         config.usage.show_infobar_on_event_change = ConfigYesNo(default = True)
22         config.usage.hdd_standby = ConfigSelection(default = "600", choices = [
23                 ("0", _("no standby")), ("10", "10 " + _("seconds")), ("30", "30 " + _("seconds")),
24                 ("60", "1 " + _("minute")), ("120", "2 " + _("minutes")),
25                 ("300", "5 " + _("minutes")), ("600", "10 " + _("minutes")), ("1200", "20 " + _("minutes")),
26                 ("1800", "30 " + _("minutes")), ("3600", "1 " + _("hour")), ("7200", "2 " + _("hours")),
27                 ("14400", "4 " + _("hours")) ])
28         config.usage.output_12V = ConfigSelection(default = "do not change", choices = [
29                 ("do not change", _("do not change")), ("off", _("off")), ("on", _("on")) ])
30
31         config.usage.pip_zero_button = ConfigSelection(default = "standard", choices = [
32                 ("standard", _("standard")), ("swap", _("swap PiP and main picture")),
33                 ("swapstop", _("move PiP to main picture")), ("stop", _("stop PiP")) ])
34
35         config.usage.default_path = ConfigText(default = resolveFilename(SCOPE_HDD))
36         config.usage.timer_path = ConfigText(default = "<default>")
37         config.usage.instantrec_path = ConfigText(default = "<default>")
38         config.usage.timeshift_path = ConfigText(default = "/media/hdd/")
39         config.usage.allowed_timeshift_paths = ConfigLocations(default = ["/media/hdd/"])
40
41         config.usage.on_movie_start = ConfigSelection(default = "ask", choices = [
42                 ("ask", _("Ask user")), ("resume", _("Resume from last position")), ("beginning", _("Start from the beginning")) ])
43         config.usage.on_movie_stop = ConfigSelection(default = "ask", choices = [
44                 ("ask", _("Ask user")), ("movielist", _("Return to movie list")), ("quit", _("Return to previous service")) ])
45         config.usage.on_movie_eof = ConfigSelection(default = "ask", choices = [
46                 ("ask", _("Ask user")), ("movielist", _("Return to movie list")), ("quit", _("Return to previous service")), ("pause", _("Pause movie at end")) ])
47
48         config.usage.setup_level = ConfigSelection(default = "intermediate", choices = [
49                 ("simple", _("Simple")),
50                 ("intermediate", _("Intermediate")),
51                 ("expert", _("Expert")) ])
52
53         config.usage.on_long_powerpress = ConfigSelection(default = "show_menu", choices = [
54                 ("show_menu", _("show shutdown menu")),
55                 ("shutdown", _("immediate shutdown")),
56                 ("standby", _("Standby")) ] )
57         
58         config.usage.on_short_powerpress = ConfigSelection(default = "standby", choices = [
59                 ("show_menu", _("show shutdown menu")),
60                 ("shutdown", _("immediate shutdown")),
61                 ("standby", _("Standby")) ] )
62
63         config.usage.alternatives_priority = ConfigSelection(default = "0", choices = [
64                 ("0", "DVB-S/-C/-T"),
65                 ("1", "DVB-S/-T/-C"),
66                 ("2", "DVB-C/-S/-T"),
67                 ("3", "DVB-C/-T/-S"),
68                 ("4", "DVB-T/-C/-S"),
69                 ("5", "DVB-T/-S/-C") ])
70
71         config.usage.show_event_progress_in_servicelist = ConfigYesNo(default = False)
72
73         config.usage.blinking_display_clock_during_recording = ConfigYesNo(default = False)
74
75         config.usage.show_message_when_recording_starts = ConfigYesNo(default = True)
76
77         config.usage.load_length_of_movies_in_moviellist = ConfigYesNo(default = True)
78         
79         def TunerTypePriorityOrderChanged(configElement):
80                 setTunerTypePriorityOrder(int(configElement.value))
81         config.usage.alternatives_priority.addNotifier(TunerTypePriorityOrderChanged, immediate_feedback=False)
82
83         def setHDDStandby(configElement):
84                 for hdd in harddiskmanager.HDDList():
85                         hdd[1].setIdleTime(int(configElement.value))
86         config.usage.hdd_standby.addNotifier(setHDDStandby, immediate_feedback=False)
87
88         def set12VOutput(configElement):
89                 if configElement.value == "on":
90                         Misc_Options.getInstance().set_12V_output(1)
91                 elif configElement.value == "off":
92                         Misc_Options.getInstance().set_12V_output(0)
93         config.usage.output_12V.addNotifier(set12VOutput, immediate_feedback=False)
94
95         SystemInfo["12V_Output"] = Misc_Options.getInstance().detected_12V_output()
96
97         config.usage.keymap = ConfigText(default = eEnv.resolve("${datadir}/enigma2/keymap.xml"))
98
99         config.seek = ConfigSubsection()
100         config.seek.selfdefined_13 = ConfigNumber(default=15)
101         config.seek.selfdefined_46 = ConfigNumber(default=60)
102         config.seek.selfdefined_79 = ConfigNumber(default=300)
103
104         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])
105         config.seek.speeds_backward = ConfigSet(default=[2, 4, 8, 16, 32, 64, 128], choices=[1, 2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128])
106         config.seek.speeds_slowmotion = ConfigSet(default=[2, 4, 8], choices=[2, 4, 6, 8, 12, 16, 25])
107
108         config.seek.enter_forward = ConfigSelection(default = "2", choices = ["2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
109         config.seek.enter_backward = ConfigSelection(default = "1", choices = ["1", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
110
111         config.seek.on_pause = ConfigSelection(default = "play", choices = [
112                 ("play", _("Play")),
113                 ("step", _("Singlestep (GOP)")),
114                 ("last", _("Last speed")) ])
115
116         config.usage.timerlist_finished_timer_position = ConfigSelection(default = "beginning", choices = [("beginning", _("at beginning")), ("end", _("at end"))])
117
118         def updateEnterForward(configElement):
119                 if not configElement.value:
120                         configElement.value = [2]
121                 updateChoices(config.seek.enter_forward, configElement.value)
122
123         config.seek.speeds_forward.addNotifier(updateEnterForward, immediate_feedback = False)
124
125         def updateEnterBackward(configElement):
126                 if not configElement.value:
127                         configElement.value = [2]
128                 updateChoices(config.seek.enter_backward, configElement.value)
129
130         config.seek.speeds_backward.addNotifier(updateEnterBackward, immediate_feedback = False)
131
132         config.usage.text_subtitle_presentation = ConfigSelection(default = "black box", choices = [("black box", _("black box")), ("drop-shadow", _("drop-shadow"))])
133
134
135 def updateChoices(sel, choices):
136         if choices:
137                 defval = None
138                 val = int(sel.value)
139                 if not val in choices:
140                         tmp = choices[:]
141                         tmp.reverse()
142                         for x in tmp:
143                                 if x < val:
144                                         defval = str(x)
145                                         break
146                 sel.setChoices(map(str, choices), defval)
147
148 def preferredPath(path):
149         if config.usage.setup_level.index < 2 or path == "<default>":
150                 return None  # config.usage.default_path.value, but delay lookup until usage
151         elif path == "<current>":
152                 return config.movielist.last_videodir.value
153         elif path == "<timer>":
154                 return config.movielist.last_timer_videodir.value
155         else:
156                 return path
157
158 def preferredTimerPath():
159         return preferredPath(config.usage.timer_path.value)
160
161 def preferredInstantRecordPath():
162         return preferredPath(config.usage.instantrec_path.value)
163
164 def defaultMoviePath():
165         return config.usage.default_path.value
166
167 def defaultStorageDevice():
168         return config.storage_options.default_device.value