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