Add config option to startup enigma2 in standby mode
[openblackhole/openblackhole-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, ConfigSelectionNumber, ConfigClock, ConfigSlider
3 from Tools.Directories import resolveFilename, SCOPE_HDD, defaultRecordingLocation
4 from enigma import setTunerTypePriorityOrder, setPreferredTuner, setSpinnerOnOff, setEnableTtCachingOnOff;
5 from enigma import Misc_Options, eEnv;
6 from Components.NimManager import nimmanager
7 from Components.Harddisk import harddiskmanager
8 from Components.ServiceList import refreshServiceList
9 from SystemInfo import SystemInfo
10 import os
11 import enigma
12 import time
13
14 def InitUsageConfig():
15         config.usage = ConfigSubsection();
16         config.usage.showdish = ConfigYesNo(default = True)
17         config.usage.multibouquet = ConfigYesNo(default = True)
18
19         config.usage.alternative_number_mode = ConfigYesNo(default = False)
20         def alternativeNumberModeChange(configElement):
21                 enigma.eDVBDB.getInstance().setNumberingMode(configElement.value)
22                 refreshServiceList()
23         config.usage.alternative_number_mode.addNotifier(alternativeNumberModeChange)
24
25         config.usage.hide_number_markers = ConfigYesNo(default = False)
26         config.usage.hide_number_markers.addNotifier(refreshServiceList)
27
28         config.usage.servicetype_icon_mode = ConfigSelection(default = "0", choices = [("0", _("None")), ("1", _("Left from servicename")), ("2", _("Right from servicename"))])  
29         config.usage.servicetype_icon_mode.addNotifier(refreshServiceList)
30
31         config.usage.service_icon_enable = ConfigYesNo(default = False)
32         config.usage.service_icon_enable.addNotifier(refreshServiceList)
33         config.usage.servicelist_cursor_behavior = ConfigSelection(default = "standard", choices = [
34                 ("standard", _("Standard")),
35                 ("keep", _("Keep service")),
36                 ("reverseB", _("Reverse bouquet buttons")),
37                 ("keep reverseB", _("Keep service") + " + " + _("Reverse bouquet buttons"))])
38
39         config.usage.multiepg_ask_bouquet = ConfigYesNo(default = False)
40         
41         config.usage.quickzap_bouquet_change = ConfigYesNo(default = False)
42         config.usage.e1like_radio_mode = ConfigYesNo(default = True)
43         choicelist = []
44         for i in range(1, 12):
45                 choicelist.append(("%d" % i, ngettext("%d second", "%d seconds", i) % i))
46         config.usage.infobar_timeout = ConfigSelection(default = "5", choices = [("0", _("No timeout"))] + choicelist)
47         config.usage.show_infobar_on_zap = ConfigYesNo(default = True)
48         config.usage.show_infobar_on_skip = ConfigYesNo(default = True)
49         config.usage.show_infobar_on_event_change = ConfigYesNo(default = False)
50         config.usage.show_second_infobar = ConfigSelection(default = None, choices = [(None, _("None")), ("0", _("No timeout"))] + choicelist + [("EPG",_("EPG"))]) 
51         config.usage.show_spinner = ConfigYesNo(default = True)
52         config.usage.enable_tt_caching = ConfigYesNo(default = True)
53         choicelist = []
54         for i in (10, 30):
55                 choicelist.append(("%d" % i, ngettext("%d second", "%d seconds", i) % i))
56         for i in (60, 120, 300, 600, 1200, 1800):
57                 m = i / 60
58                 choicelist.append(("%d" % i, ngettext("%d minute", "%d minutes", m) % m))
59         for i in (3600, 7200, 14400):
60                 h = i / 3600
61                 choicelist.append(("%d" % i, ngettext("%d hour", "%d hours", h) % h))
62         config.usage.hdd_standby = ConfigSelection(default = "300", choices = [("0", _("No standby"))] + choicelist)
63         config.usage.output_12V = ConfigSelection(default = "do not change", choices = [
64                 ("do not change", _("Do not change")), ("off", _("Off")), ("on", _("On")) ])
65
66         config.usage.pip_zero_button = ConfigSelection(default = "standard", choices = [
67                 ("standard", _("Standard")), ("swap", _("Swap PiP and main picture")),
68                 ("swapstop", _("Move PiP to main picture")), ("stop", _("Stop PiP")) ])
69         config.usage.pip_hideOnExit = ConfigSelection(default = "without popup", choices = [
70                 ("no", _("No")), ("popup", _("With popup")), ("without popup", _("Without popup")) ])
71
72         config.usage.default_path = ConfigText(default = resolveFilename(SCOPE_HDD))
73         config.usage.timer_path = ConfigText(default = "<default>")
74         config.usage.instantrec_path = ConfigText(default = "<default>")
75         config.usage.timeshift_path = ConfigText(default = "/media/hdd/")
76         config.usage.allowed_timeshift_paths = ConfigLocations(default = ["/media/hdd/"])
77
78         config.usage.movielist_trashcan = ConfigYesNo(default=True)
79         config.usage.movielist_trashcan_days = ConfigNumber(default=8)
80         config.usage.movielist_trashcan_reserve = ConfigNumber(default=40)
81         config.usage.on_movie_start = ConfigSelection(default = "resume", choices = [
82                 ("ask", _("Ask user")), ("resume", _("Resume from last position")), ("beginning", _("Start from the beginning")) ])
83         config.usage.on_movie_stop = ConfigSelection(default = "movielist", choices = [
84                 ("ask", _("Ask user")), ("movielist", _("Return to movie list")), ("quit", _("Return to previous service")) ])
85         config.usage.on_movie_eof = ConfigSelection(default = "movielist", choices = [
86                 ("ask", _("Ask user")), ("movielist", _("Return to movie list")), ("quit", _("Return to previous service")), ("pause", _("Pause movie at end")), ("playlist", _("Play next (return to movie list)")),
87                 ("playlistquit", _("Play next (return to previous service)")), ("loop", _("Continues play (loop)")), ("repeatcurrent", _("Repeat"))])
88         config.usage.next_movie_msg = ConfigYesNo(default = True)
89         config.usage.leave_movieplayer_onExit = ConfigSelection(default = "popup", choices = [
90                 ("no", _("No")), ("popup", _("With popup")), ("without popup", _("Without popup")) ])
91
92         config.usage.setup_level = ConfigSelection(default = "expert", choices = [
93                 ("simple", _("Simple")),
94                 ("intermediate", _("Intermediate")),
95                 ("expert", _("Expert")) ])
96
97         config.usage.startup_to_standby = ConfigYesNo(default = False)
98
99         config.usage.on_long_powerpress = ConfigSelection(default = "show_menu", choices = [
100                 ("show_menu", _("Show shutdown menu")),
101                 ("shutdown", _("Immediate shutdown")),
102                 ("standby", _("Standby")) ] )
103         
104         config.usage.on_short_powerpress = ConfigSelection(default = "standby", choices = [
105                 ("show_menu", _("Show shutdown menu")),
106                 ("shutdown", _("Immediate shutdown")),
107                 ("standby", _("Standby")) ] )
108
109         choicelist = []
110         for i in range(-21600, 21601, 3600):
111                 h = abs(i / 3600)
112                 h = ngettext("%d hour", "%d hours", h) % h
113                 if i < 0:
114                         choicelist.append(("%d" % i, _("Shutdown in ") + h))
115                 elif i > 0:
116                         choicelist.append(("%d" % i, _("Standby in ") + h))
117                 else:
118                         choicelist.append(("0", _("Do nothing")))
119         config.usage.inactivity_timer = ConfigSelection(default = "0", choices = choicelist)
120         config.usage.inactivity_timer_blocktime = ConfigYesNo(default = True)
121         config.usage.inactivity_timer_blocktime_begin = ConfigClock(default = time.mktime((0, 0, 0, 6, 0, 0, 0, 0, 0)))
122         config.usage.inactivity_timer_blocktime_end = ConfigClock(default = time.mktime((0, 0, 0, 23, 0, 0, 0, 0, 0)))
123
124         choicelist = []
125         for i in range(-7200, 7201, 900):
126                 m = abs(i / 60)
127                 m = ngettext("%d minute", "%d minutes", m) % m
128                 if i < 0:
129                         choicelist.append(("%d" % i, _("Shutdown in ") + m))
130                 elif i > 0:
131                         choicelist.append(("%d" % i, _("Standby in ") + m))
132                 else:
133                         choicelist.append(("event_shutdown", _("Shutdown after current event")))
134                         choicelist.append(("0", _("Disabled")))
135                         choicelist.append(("event_standby", _("Standby after current event")))
136         config.usage.sleep_timer = ConfigSelection(default = "0", choices = choicelist)
137
138         choicelist = [("0", _("Disabled"))]
139         for i in range(900, 7201, 900):
140                 m = abs(i / 60)
141                 m = ngettext("%d minute", "%d minutes", m) % m
142                 choicelist.append(("%d" % i, _("after ") + m))
143         config.usage.standby_to_shutdown_timer = ConfigSelection(default = "0", choices = choicelist)
144
145         choicelist = [("0", _("Disabled"))]
146         for i in (5, 30, 60, 300, 600, 900, 1200, 1800, 2700, 3600):
147                 if i < 60:
148                         m = ngettext("%d second", "%d seconds", i) % i
149                 else:
150                         m = abs(i / 60)
151                         m = ngettext("%d minute", "%d minutes", m) % m
152                 choicelist.append(("%d" % i, m))
153         config.usage.screen_saver = ConfigSelection(default = "0", choices = choicelist)
154
155         config.usage.check_timeshift = ConfigYesNo(default = True)
156
157         choicelist = [("0", _("Disabled"))]
158         for i in (2, 3, 4, 5, 10, 20, 30):
159                 choicelist.append(("%d" % i, ngettext("%d second", "%d seconds", i) % i))
160         for i in (60, 120, 300):
161                 m = i / 60
162                 choicelist.append(("%d" % i, ngettext("%d minute", "%d minutes", m) % m))
163         config.usage.timeshift_start_delay = ConfigSelection(default = "0", choices = choicelist)
164
165         config.usage.alternatives_priority = ConfigSelection(default = "0", choices = [
166                 ("0", "DVB-S/-C/-T"),
167                 ("1", "DVB-S/-T/-C"),
168                 ("2", "DVB-C/-S/-T"),
169                 ("3", "DVB-C/-T/-S"),
170                 ("4", "DVB-T/-C/-S"),
171                 ("5", "DVB-T/-S/-C") ])
172
173         nims = [("-1", _("auto"))]
174         for x in nimmanager.nim_slots:
175                 nims.append((str(x.slot), x.getSlotName()))
176         config.usage.frontend_priority = ConfigSelection(default = "-1", choices = list(nims))
177         nims.insert(0,("-2", _("Disabled")))
178         config.usage.recording_frontend_priority = ConfigSelection(default = "-2", choices = nims)
179         config.misc.disable_background_scan = ConfigYesNo(default = False)
180
181         config.usage.show_event_progress_in_servicelist = ConfigSelection(default = 'barright', choices = [
182                 ('barleft', _("Progress bar left")),
183                 ('barright', _("Progress bar right")),
184                 ('percleft', _("Percentage left")),
185                 ('percright', _("Percentage right")),
186                 ('no', _("No")) ])
187         config.usage.show_channel_numbers_in_servicelist = ConfigYesNo(default = True)
188         config.usage.show_event_progress_in_servicelist.addNotifier(refreshServiceList)
189         config.usage.show_channel_numbers_in_servicelist.addNotifier(refreshServiceList)
190
191         config.usage.blinking_display_clock_during_recording = ConfigYesNo(default = False)
192
193         config.usage.show_message_when_recording_starts = ConfigYesNo(default = True)
194
195         config.usage.load_length_of_movies_in_moviellist = ConfigYesNo(default = True)
196         config.usage.show_icons_in_movielist = ConfigSelection(default = 'i', choices = [
197                 ('o', _("Off")),
198                 ('p', _("Progress")),
199                 ('s', _("Small progress")),
200                 ('i', _("Icons")),
201         ])
202         config.usage.movielist_unseen = ConfigYesNo(default = False)
203
204         config.usage.swap_snr_on_osd = ConfigYesNo(default = False)
205
206         def SpinnerOnOffChanged(configElement):
207                 setSpinnerOnOff(int(configElement.value))
208         config.usage.show_spinner.addNotifier(SpinnerOnOffChanged)
209
210         def EnableTtCachingChanged(configElement):
211                 setEnableTtCachingOnOff(int(configElement.value))
212         config.usage.enable_tt_caching.addNotifier(EnableTtCachingChanged)
213
214         def TunerTypePriorityOrderChanged(configElement):
215                 setTunerTypePriorityOrder(int(configElement.value))
216         config.usage.alternatives_priority.addNotifier(TunerTypePriorityOrderChanged, immediate_feedback=False)
217
218         def PreferredTunerChanged(configElement):
219                 setPreferredTuner(int(configElement.value))
220         config.usage.frontend_priority.addNotifier(PreferredTunerChanged)
221
222         config.usage.hide_zap_errors = ConfigYesNo(default = False)
223         config.usage.hide_ci_messages = ConfigYesNo(default = False)
224         config.usage.show_cryptoinfo = ConfigYesNo(default = True)
225         config.usage.show_eit_nownext = ConfigYesNo(default = True)
226         config.usage.show_vcr_scart = ConfigYesNo(default = False)
227
228         if SystemInfo["Fan"]:
229                 choicelist = [('off', _("Off")), ('on', _("On")), ('auto', _("Auto"))]
230                 if os.path.exists("/proc/stb/fp/fan_choices"):
231                         choicelist = [x for x in choicelist if x[0] in open("/proc/stb/fp/fan_choices", "r").read().strip().split(" ")]
232                 config.usage.fan = ConfigSelection(choicelist)
233                 def fanChanged(configElement):
234                         file = open("/proc/stb/fp/fan", "w")
235                         file.write(configElement.value)
236                         file.close()
237                 config.usage.fan.addNotifier(fanChanged)
238
239         if SystemInfo["FanPWM"]:
240                 def fanSpeedChanged(configElement):
241                         file = open("/proc/stb/fp/fan_pwm", "w")
242                         file.write(hex(configElement.value)[2:])
243                         file.close()
244                 config.usage.fanspeed = ConfigSlider(default=127, increment=8, limits=(0, 255))
245                 config.usage.fanspeed.addNotifier(fanSpeedChanged)
246
247         config.epg = ConfigSubsection()
248         config.epg.eit = ConfigYesNo(default = True)
249         config.epg.mhw = ConfigYesNo(default = False)
250         config.epg.freesat = ConfigYesNo(default = True)
251         config.epg.viasat = ConfigYesNo(default = True)
252         config.epg.netmed = ConfigYesNo(default = True)
253         config.misc.showradiopic = ConfigYesNo(default = True)
254         def EpgSettingsChanged(configElement):
255                 from enigma import eEPGCache
256                 mask = 0xffffffff
257                 if not config.epg.eit.value:
258                         mask &= ~(eEPGCache.NOWNEXT | eEPGCache.SCHEDULE | eEPGCache.SCHEDULE_OTHER)
259                 if not config.epg.mhw.value:
260                         mask &= ~eEPGCache.MHW
261                 if not config.epg.freesat.value:
262                         mask &= ~(eEPGCache.FREESAT_NOWNEXT | eEPGCache.FREESAT_SCHEDULE | eEPGCache.FREESAT_SCHEDULE_OTHER)
263                 if not config.epg.viasat.value:
264                         mask &= ~eEPGCache.VIASAT
265                 if not config.epg.netmed.value:
266                         mask &= ~(eEPGCache.NETMED_SCHEDULE | eEPGCache.NETMED_SCHEDULE_OTHER)
267                 eEPGCache.getInstance().setEpgSources(mask)
268         config.epg.eit.addNotifier(EpgSettingsChanged)
269         config.epg.mhw.addNotifier(EpgSettingsChanged)
270         config.epg.freesat.addNotifier(EpgSettingsChanged)
271         config.epg.viasat.addNotifier(EpgSettingsChanged)
272         config.epg.netmed.addNotifier(EpgSettingsChanged)
273
274         config.epg.histminutes = ConfigSelectionNumber(min = 0, max = 120, stepwidth = 15, default = 0, wraparound = True)
275         def EpgHistorySecondsChanged(configElement):
276                 from enigma import eEPGCache
277                 eEPGCache.getInstance().setEpgHistorySeconds(config.epg.histminutes.getValue()*60)
278         config.epg.histminutes.addNotifier(EpgHistorySecondsChanged)
279
280         def setHDDStandby(configElement):
281                 for hdd in harddiskmanager.HDDList():
282                         hdd[1].setIdleTime(int(configElement.value))
283         config.usage.hdd_standby.addNotifier(setHDDStandby, immediate_feedback=False)
284
285         def set12VOutput(configElement):
286                 if configElement.value == "on":
287                         enigma.Misc_Options.getInstance().set_12V_output(1)
288                 elif configElement.value == "off":
289                         enigma.Misc_Options.getInstance().set_12V_output(0)
290         config.usage.output_12V.addNotifier(set12VOutput, immediate_feedback=False)
291
292         SystemInfo["12V_Output"] = enigma.Misc_Options.getInstance().detected_12V_output()
293
294         config.usage.keymap = ConfigText(default = eEnv.resolve("${datadir}/enigma2/keymap.xml"))
295
296         config.seek = ConfigSubsection()
297         config.seek.selfdefined_13 = ConfigNumber(default=15)
298         config.seek.selfdefined_46 = ConfigNumber(default=60)
299         config.seek.selfdefined_79 = ConfigNumber(default=300)
300
301         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])
302         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])
303         config.seek.speeds_slowmotion = ConfigSet(default=[2, 4, 8], choices=[2, 4, 6, 8, 12, 16, 25])
304
305         config.seek.enter_forward = ConfigSelection(default = "2", choices = ["2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
306         config.seek.enter_backward = ConfigSelection(default = "1", choices = ["1", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
307
308         config.seek.on_pause = ConfigSelection(default = "play", choices = [
309                 ("play", _("Play")),
310                 ("step", _("Single step (GOP)")),
311                 ("last", _("Last speed")) ])
312
313
314         config.crash = ConfigSubsection()
315         config.crash.details = ConfigYesNo(default = False)
316         config.usage.timerlist_finished_timer_position = ConfigSelection(default = "end", choices = [("beginning", _("At beginning")), ("end", _("At end"))])
317
318         def updateEnterForward(configElement):
319                 if not configElement.value:
320                         configElement.value = [2]
321                 updateChoices(config.seek.enter_forward, configElement.value)
322
323         config.seek.speeds_forward.addNotifier(updateEnterForward, immediate_feedback = False)
324
325         def updateEnterBackward(configElement):
326                 if not configElement.value:
327                         configElement.value = [2]
328                 updateChoices(config.seek.enter_backward, configElement.value)
329
330         config.seek.speeds_backward.addNotifier(updateEnterBackward, immediate_feedback = False)
331
332         def updateEraseSpeed(el):
333                 enigma.eBackgroundFileEraser.getInstance().setEraseSpeed(int(el.value))
334         def updateEraseFlags(el):
335                 enigma.eBackgroundFileEraser.getInstance().setEraseFlags(int(el.value))
336         config.misc.erase_speed = ConfigSelection(default="20", choices = [
337                 ("10", "10 MB/s"),
338                 ("20", "20 MB/s"),
339                 ("50", "50 MB/s"),
340                 ("100", "100 MB/s")])
341         config.misc.erase_speed.addNotifier(updateEraseSpeed, immediate_feedback = False)
342         config.misc.erase_flags = ConfigSelection(default="1", choices = [
343                 ("0", _("Disable")),
344                 ("1", _("Internal hdd only")),
345                 ("3", _("Everywhere"))])
346         config.misc.erase_flags.addNotifier(updateEraseFlags, immediate_feedback = False)
347
348         SystemInfo["ZapMode"] = os.path.exists("/proc/stb/video/zapmode")
349         if SystemInfo["ZapMode"]:
350                 def setZapmode(el):
351                         try:
352                                 file = open("/proc/stb/video/zapmode", "w")
353                                 file.write(el.value)
354                                 file.close()
355                         except:
356                                 pass
357                 config.misc.zapmode = ConfigSelection(default = "mute", choices = [
358                         ("mute", _("Black screen")), ("hold", _("Hold screen")), ("mutetilllock", _("Black screen till locked")), ("holdtilllock", _("Hold till locked"))])
359                 config.misc.zapmode.addNotifier(setZapmode, immediate_feedback = False)
360
361         config.subtitles = ConfigSubsection()
362         config.subtitles.ttx_subtitle_colors = ConfigSelection(default = "1", choices = [
363                 ("0", _("original")),
364                 ("1", _("white")),
365                 ("2", _("yellow")) ])
366         config.subtitles.ttx_subtitle_original_position = ConfigYesNo(default = False)
367         config.subtitles.subtitle_position = ConfigSelection( choices = ["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100", "150", "200", "250", "300", "350", "400", "450"], default = "50")
368         config.subtitles.subtitle_alignment = ConfigSelection(choices = [("left", _("left")), ("center", _("center")), ("right", _("right"))], default = "center")
369         config.subtitles.subtitle_rewrap = ConfigYesNo(default = False)
370         config.subtitles.subtitle_borderwidth = ConfigSelection(choices = ["1", "2", "3", "4", "5"], default = "3")
371         config.subtitles.subtitle_fontsize  = ConfigSelection(choices = ["16", "18", "20", "22", "24", "26", "28", "30", "32", "34", "36", "38", "40", "42", "44", "46", "48", "50", "52", "54"], default = "34")
372
373         subtitle_delay_choicelist = []
374         for i in range(-900000, 1845000, 45000):
375                 if i == 0:
376                         subtitle_delay_choicelist.append(("0", _("No delay")))
377                 else:
378                         subtitle_delay_choicelist.append(("%d" % i, "%2.1f sec" % (i / 90000.)))
379         config.subtitles.subtitle_noPTSrecordingdelay = ConfigSelection(default = "315000", choices = subtitle_delay_choicelist)
380
381         config.subtitles.dvb_subtitles_yellow = ConfigYesNo(default = False)
382         config.subtitles.dvb_subtitles_original_position = ConfigSelection(default = "0", choices = [("0", _("Original")), ("1", _("Fixed")), ("2", _("Relative"))])
383         config.subtitles.dvb_subtitles_centered = ConfigYesNo(default = True)
384         config.subtitles.subtitle_bad_timing_delay = ConfigSelection(default = "0", choices = subtitle_delay_choicelist)
385         config.subtitles.dvb_subtitles_backtrans = ConfigSelection(default = "0", choices = [
386                 ("0", _("No transparency")),
387                 ("25", "10%"),
388                 ("50", "20%"),
389                 ("75", "30%"),
390                 ("100", "40%"),
391                 ("125", "50%"),
392                 ("150", "60%"),
393                 ("175", "70%"),
394                 ("200", "80%"),
395                 ("225", "90%"),
396                 ("255", _("Full transparency"))])
397         config.subtitles.pango_subtitle_colors = ConfigSelection(default = "0", choices = [
398                 ("0", _("alternative")),
399                 ("1", _("white")),
400                 ("2", _("yellow")) ])
401         config.subtitles.pango_subtitles_delay = ConfigSelection(default = "0", choices = subtitle_delay_choicelist)
402         config.subtitles.pango_subtitles_fps = ConfigSelection(default = "1", choices = [
403                 ("1", _("Original")),
404                 ("23976", _("23.976")),
405                 ("24000", _("24")),
406                 ("25000", _("25")),
407                 ("29970", _("29.97")),
408                 ("30000", _("30"))])
409         config.subtitles.pango_autoturnon = ConfigYesNo(default = True)
410
411         config.autolanguage = ConfigSubsection()
412         audio_language_choices=[
413                 ("---", _("None")),
414                 ("orj dos ory org esl qaa und mis mul ORY ORJ Audio_ORJ", _("Original")),
415                 ("ara", _("Arabic")),
416                 ("eus baq", _("Basque")),
417                 ("bul", _("Bulgarian")), 
418                 ("hrv", _("Croatian")),
419                 ("ces cze", _("Czech")),
420                 ("dan", _("Danish")),
421                 ("dut ndl", _("Dutch")),
422                 ("eng qaa", _("English")),
423                 ("est", _("Estonian")),
424                 ("fin", _("Finnish")),
425                 ("fra fre", _("French")),
426                 ("deu ger", _("German")),
427                 ("ell gre", _("Greek")),
428                 ("heb", _("Hebrew")),
429                 ("hun", _("Hungarian")),
430                 ("ita", _("Italian")),
431                 ("lav", _("Latvian")),
432                 ("lit", _("Lithuanian")),
433                 ("ltz", _("Luxembourgish")),
434                 ("nor", _("Norwegian")),
435                 ("pol", _("Polish")),
436                 ("por", _("Portuguese")),
437                 ("fas per", _("Persian")),
438                 ("ron rum", _("Romanian")),
439                 ("rus", _("Russian")),
440                 ("srp", _("Serbian")),
441                 ("slk slo", _("Slovak")),
442                 ("slv", _("Slovenian")),
443                 ("spa", _("Spanish")),
444                 ("swe", _("Swedish")),
445                 ("tha", _("Thai")),
446                 ("tur Audio_TUR", _("Turkish"))]
447
448         def setEpgLanguage(configElement):
449                 enigma.eServiceEvent.setEPGLanguage(configElement.value)
450         config.autolanguage.audio_epglanguage = ConfigSelection(audio_language_choices[:1] + audio_language_choices [2:], default="---")
451         config.autolanguage.audio_epglanguage.addNotifier(setEpgLanguage)
452
453         def setEpgLanguageAlternative(configElement):
454                 enigma.eServiceEvent.setEPGLanguageAlternative(configElement.value)
455         config.autolanguage.audio_epglanguage_alternative = ConfigSelection(audio_language_choices[:1] + audio_language_choices [2:], default="---")
456         config.autolanguage.audio_epglanguage_alternative.addNotifier(setEpgLanguageAlternative)
457
458         config.autolanguage.audio_autoselect1 = ConfigSelection(choices=audio_language_choices, default="---")
459         config.autolanguage.audio_autoselect2 = ConfigSelection(choices=audio_language_choices, default="---")
460         config.autolanguage.audio_autoselect3 = ConfigSelection(choices=audio_language_choices, default="---")
461         config.autolanguage.audio_autoselect4 = ConfigSelection(choices=audio_language_choices, default="---")
462         config.autolanguage.audio_defaultac3 = ConfigYesNo(default = False)
463         config.autolanguage.audio_defaultddp = ConfigYesNo(default = False)
464         config.autolanguage.audio_usecache = ConfigYesNo(default = True)
465
466         subtitle_language_choices = audio_language_choices[:1] + audio_language_choices [2:]
467         config.autolanguage.subtitle_autoselect1 = ConfigSelection(choices=subtitle_language_choices, default="---")
468         config.autolanguage.subtitle_autoselect2 = ConfigSelection(choices=subtitle_language_choices, default="---")
469         config.autolanguage.subtitle_autoselect3 = ConfigSelection(choices=subtitle_language_choices, default="---")
470         config.autolanguage.subtitle_autoselect4 = ConfigSelection(choices=subtitle_language_choices, default="---")
471         config.autolanguage.subtitle_hearingimpaired = ConfigYesNo(default = False)
472         config.autolanguage.subtitle_defaultimpaired = ConfigYesNo(default = False)
473         config.autolanguage.subtitle_defaultdvb = ConfigYesNo(default = False)
474         config.autolanguage.subtitle_usecache = ConfigYesNo(default = True)
475         config.autolanguage.equal_languages = ConfigSelection(default = "15", choices = [
476                 ("0", _("None")),("1", "1"),("2", "2"),("3", "1,2"),
477                 ("4", "3"),("5", "1,3"),("6", "2,3"),("7", "1,2,3"),
478                 ("8", "4"),("9", "1,4"),("10", "2,4"),("11", "1,2,4"),
479                 ("12", "3,4"),("13", "1,3,4"),("14", "2,3,4"),("15", _("All"))])
480
481         config.streaming = ConfigSubsection()
482         config.streaming.stream_ecm = ConfigYesNo(default = False)
483         config.streaming.descramble = ConfigYesNo(default = True)
484         config.streaming.stream_eit = ConfigYesNo(default = True)
485         config.streaming.stream_ait = ConfigYesNo(default = True)
486
487 def updateChoices(sel, choices):
488         if choices:
489                 defval = None
490                 val = int(sel.value)
491                 if not val in choices:
492                         tmp = choices[:]
493                         tmp.reverse()
494                         for x in tmp:
495                                 if x < val:
496                                         defval = str(x)
497                                         break
498                 sel.setChoices(map(str, choices), defval)
499
500 def preferredPath(path):
501         if config.usage.setup_level.index < 2 or path == "<default>":
502                 return None  # config.usage.default_path.value, but delay lookup until usage
503         elif path == "<current>":
504                 return config.movielist.last_videodir.value
505         elif path == "<timer>":
506                 return config.movielist.last_timer_videodir.value
507         else:
508                 return path
509
510 def preferredTimerPath():
511         return preferredPath(config.usage.timer_path.value)
512
513 def preferredInstantRecordPath():
514         return preferredPath(config.usage.instantrec_path.value)
515
516 def defaultMoviePath():
517         return defaultRecordingLocation(config.usage.default_path.value)