UsageConfig: write str(i) instead of "%d"%i
[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, 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 = False)
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 = None, 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")) ])
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 = ConfigYesNo(default = False)
123
124         config.usage.on_long_powerpress = ConfigSelection(default = "show_menu", choices = [
125                 ("show_menu", _("Show shutdown menu")),
126                 ("shutdown", _("Immediate shutdown")),
127                 ("standby", _("Standby")) ] )
128
129         config.usage.on_short_powerpress = ConfigSelection(default = "standby", choices = [
130                 ("show_menu", _("Show shutdown menu")),
131                 ("shutdown", _("Immediate shutdown")),
132                 ("standby", _("Standby")) ] )
133
134         choicelist = [("0", _("Do nothing"))]
135         for i in range(3600, 21601, 3600):
136                 h = abs(i / 3600)
137                 h = ngettext("%d hour", "%d hours", h) % h
138                 choicelist.append((str(i), _("Standby in ") + h))
139         config.usage.inactivity_timer = ConfigSelection(default = "0", choices = choicelist)
140         config.usage.inactivity_timer_blocktime = ConfigYesNo(default = True)
141         config.usage.inactivity_timer_blocktime_begin = ConfigClock(default = time.mktime((0, 0, 0, 18, 0, 0, 0, 0, 0)))
142         config.usage.inactivity_timer_blocktime_end = ConfigClock(default = time.mktime((0, 0, 0, 23, 0, 0, 0, 0, 0)))
143         config.usage.inactivity_timer_blocktime_extra = ConfigYesNo(default = False)
144         config.usage.inactivity_timer_blocktime_extra_begin = ConfigClock(default = time.mktime((0, 0, 0, 6, 0, 0, 0, 0, 0)))
145         config.usage.inactivity_timer_blocktime_extra_end = ConfigClock(default = time.mktime((0, 0, 0, 9, 0, 0, 0, 0, 0)))
146
147         choicelist = [("0", _("Disabled")),("event_standby", _("Standby after current event"))]
148         for i in range(900, 7201, 900):
149                 m = abs(i / 60)
150                 m = ngettext("%d minute", "%d minutes", m) % m
151                 choicelist.append((str(i), _("Standby in ") + m))
152         config.usage.sleep_timer = ConfigSelection(default = "0", choices = choicelist)
153
154         choicelist = [("0", _("Disabled"))]
155         for i in [60, 300, 600] + range(900, 7201, 900):
156                 m = abs(i / 60)
157                 m = ngettext("%d minute", "%d minutes", m) % m
158                 choicelist.append((str(i), _("after ") + m))
159         config.usage.standby_to_shutdown_timer = ConfigSelection(default = "0", choices = choicelist)
160         config.usage.standby_to_shutdown_timer_blocktime = ConfigYesNo(default = True)
161         config.usage.standby_to_shutdown_timer_blocktime_begin = ConfigClock(default = time.mktime((0, 0, 0, 6, 0, 0, 0, 0, 0)))
162         config.usage.standby_to_shutdown_timer_blocktime_end = ConfigClock(default = time.mktime((0, 0, 0, 23, 0, 0, 0, 0, 0)))
163
164         choicelist = [("0", _("Disabled"))]
165         for m in (1, 5, 10, 15, 30, 60):
166                 choicelist.append((str(m * 60), ngettext("%d minute", "%d minutes", m) % m))
167         config.usage.screen_saver = ConfigSelection(default = "300", choices = choicelist)
168
169         config.usage.check_timeshift = ConfigYesNo(default = True)
170
171         choicelist = [("0", _("Disabled"))]
172         for i in (2, 3, 4, 5, 10, 20, 30):
173                 choicelist.append((str(i), ngettext("%d second", "%d seconds", i) % i))
174         for i in (60, 120, 300):
175                 m = i / 60
176                 choicelist.append((str(i), ngettext("%d minute", "%d minutes", m) % m))
177         config.usage.timeshift_start_delay = ConfigSelection(default = "0", choices = choicelist)
178
179         config.usage.alternatives_priority = ConfigSelection(default = "0", choices = [
180                 ("0", "DVB-S/-C/-T"),
181                 ("1", "DVB-S/-T/-C"),
182                 ("2", "DVB-C/-S/-T"),
183                 ("3", "DVB-C/-T/-S"),
184                 ("4", "DVB-T/-C/-S"),
185                 ("5", "DVB-T/-S/-C"),
186                 ("127", _("No priority")) ])
187
188         config.usage.remote_fallback_enabled = ConfigYesNo(default = False);
189         config.usage.remote_fallback = ConfigText(default = "", fixed_size = False);
190
191         nims = [("-1", _("auto"))]
192         for x in nimmanager.nim_slots:
193                 nims.append((str(x.slot), x.getSlotName()))
194         config.usage.frontend_priority = ConfigSelection(default = "-1", choices = list(nims))
195         nims.insert(0,("-2", _("Disabled")))
196         config.usage.recording_frontend_priority = ConfigSelection(default = "-2", choices = nims)
197         config.misc.disable_background_scan = ConfigYesNo(default = False)
198
199         config.usage.show_event_progress_in_servicelist = ConfigSelection(default = 'barright', choices = [
200                 ('barleft', _("Progress bar left")),
201                 ('barright', _("Progress bar right")),
202                 ('percleft', _("Percentage left")),
203                 ('percright', _("Percentage right")),
204                 ('no', _("No")) ])
205         config.usage.show_channel_numbers_in_servicelist = ConfigYesNo(default = True)
206         config.usage.show_event_progress_in_servicelist.addNotifier(refreshServiceList)
207         config.usage.show_channel_numbers_in_servicelist.addNotifier(refreshServiceList)
208
209         config.usage.blinking_display_clock_during_recording = ConfigYesNo(default = False)
210
211         config.usage.show_message_when_recording_starts = ConfigYesNo(default = True)
212
213         config.usage.load_length_of_movies_in_moviellist = ConfigYesNo(default = True)
214         config.usage.show_icons_in_movielist = ConfigSelection(default = 'i', choices = [
215                 ('o', _("Off")),
216                 ('p', _("Progress")),
217                 ('s', _("Small progress")),
218                 ('i', _("Icons")),
219         ])
220         config.usage.movielist_unseen = ConfigYesNo(default = False)
221
222         config.usage.swap_snr_on_osd = ConfigYesNo(default = False)
223
224         def SpinnerOnOffChanged(configElement):
225                 setSpinnerOnOff(int(configElement.value))
226         config.usage.show_spinner.addNotifier(SpinnerOnOffChanged)
227
228         def EnableTtCachingChanged(configElement):
229                 setEnableTtCachingOnOff(int(configElement.value))
230         config.usage.enable_tt_caching.addNotifier(EnableTtCachingChanged)
231
232         def TunerTypePriorityOrderChanged(configElement):
233                 setTunerTypePriorityOrder(int(configElement.value))
234         config.usage.alternatives_priority.addNotifier(TunerTypePriorityOrderChanged, immediate_feedback=False)
235
236         def PreferredTunerChanged(configElement):
237                 setPreferredTuner(int(configElement.value))
238         config.usage.frontend_priority.addNotifier(PreferredTunerChanged)
239
240         config.usage.hide_zap_errors = ConfigYesNo(default = False)
241         config.usage.hide_ci_messages = ConfigYesNo(default = True)
242         config.usage.show_cryptoinfo = ConfigYesNo(default = True)
243         config.usage.show_eit_nownext = ConfigYesNo(default = True)
244         config.usage.show_vcr_scart = ConfigYesNo(default = False)
245         config.usage.show_update_disclaimer = ConfigYesNo(default = True)
246         config.usage.pic_resolution = ConfigSelection(default = None, choices = [(None, _("Same resolution as skin")), ("(720, 576)","720x576"), ("(1280, 720)", "1280x720"), ("(1920, 1080)", "1920x1080")])
247
248         if SystemInfo["Fan"]:
249                 choicelist = [('off', _("Off")), ('on', _("On")), ('auto', _("Auto"))]
250                 if os.path.exists("/proc/stb/fp/fan_choices"):
251                         choicelist = [x for x in choicelist if x[0] in open("/proc/stb/fp/fan_choices", "r").read().strip().split(" ")]
252                 config.usage.fan = ConfigSelection(choicelist)
253                 def fanChanged(configElement):
254                         open(SystemInfo["Fan"], "w").write(configElement.value)
255                 config.usage.fan.addNotifier(fanChanged)
256
257         if SystemInfo["FanPWM"]:
258                 def fanSpeedChanged(configElement):
259                         open(SystemInfo["FanPWM"], "w").write(hex(configElement.value)[2:])
260                 config.usage.fanspeed = ConfigSlider(default=127, increment=8, limits=(0, 255))
261                 config.usage.fanspeed.addNotifier(fanSpeedChanged)
262
263         if SystemInfo["StandbyLED"]:
264                 def standbyLEDChanged(configElement):
265                         open(SystemInfo["StandbyLED"], "w").write(configElement.value and "on" or "off")
266                 config.usage.standbyLED = ConfigYesNo(default = True)
267                 config.usage.standbyLED.addNotifier(standbyLEDChanged)
268
269         if SystemInfo["WakeOnLAN"]:
270                 def wakeOnLANChanged(configElement):
271                         if "fp" in SystemInfo["WakeOnLAN"]:
272                                 open(SystemInfo["WakeOnLAN"], "w").write(configElement.value and "enable" or "disable")
273                         else:
274                                 open(SystemInfo["WakeOnLAN"], "w").write(configElement.value and "on" or "off")
275                 config.usage.wakeOnLAN = ConfigYesNo(default = False)
276                 config.usage.wakeOnLAN.addNotifier(wakeOnLANChanged)
277
278         config.epg = ConfigSubsection()
279         config.epg.eit = ConfigYesNo(default = True)
280         config.epg.mhw = ConfigYesNo(default = False)
281         config.epg.freesat = ConfigYesNo(default = True)
282         config.epg.viasat = ConfigYesNo(default = True)
283         config.epg.netmed = ConfigYesNo(default = True)
284         config.epg.virgin = ConfigYesNo(default = False)
285         config.misc.showradiopic = ConfigYesNo(default = True)
286         def EpgSettingsChanged(configElement):
287                 from enigma import eEPGCache
288                 mask = 0xffffffff
289                 if not config.epg.eit.value:
290                         mask &= ~(eEPGCache.NOWNEXT | eEPGCache.SCHEDULE | eEPGCache.SCHEDULE_OTHER)
291                 if not config.epg.mhw.value:
292                         mask &= ~eEPGCache.MHW
293                 if not config.epg.freesat.value:
294                         mask &= ~(eEPGCache.FREESAT_NOWNEXT | eEPGCache.FREESAT_SCHEDULE | eEPGCache.FREESAT_SCHEDULE_OTHER)
295                 if not config.epg.viasat.value:
296                         mask &= ~eEPGCache.VIASAT
297                 if not config.epg.netmed.value:
298                         mask &= ~(eEPGCache.NETMED_SCHEDULE | eEPGCache.NETMED_SCHEDULE_OTHER)
299                 if not config.epg.virgin.value:
300                         mask &= ~(eEPGCache.VIRGIN_NOWNEXT | eEPGCache.VIRGIN_SCHEDULE)
301                 eEPGCache.getInstance().setEpgSources(mask)
302         config.epg.eit.addNotifier(EpgSettingsChanged)
303         config.epg.mhw.addNotifier(EpgSettingsChanged)
304         config.epg.freesat.addNotifier(EpgSettingsChanged)
305         config.epg.viasat.addNotifier(EpgSettingsChanged)
306         config.epg.netmed.addNotifier(EpgSettingsChanged)
307         config.epg.virgin.addNotifier(EpgSettingsChanged)
308
309         config.epg.histminutes = ConfigSelectionNumber(min = 0, max = 120, stepwidth = 15, default = 0, wraparound = True)
310         def EpgHistorySecondsChanged(configElement):
311                 from enigma import eEPGCache
312                 eEPGCache.getInstance().setEpgHistorySeconds(config.epg.histminutes.getValue()*60)
313         config.epg.histminutes.addNotifier(EpgHistorySecondsChanged)
314
315         def setHDDStandby(configElement):
316                 for hdd in harddiskmanager.HDDList():
317                         hdd[1].setIdleTime(int(configElement.value))
318         config.usage.hdd_standby.addNotifier(setHDDStandby, immediate_feedback=False)
319
320         if SystemInfo["12V_Output"]:
321                 def set12VOutput(configElement):
322                         Misc_Options.getInstance().set_12V_output(configElement.value == "on" and 1 or 0)
323                 config.usage.output_12V.addNotifier(set12VOutput, immediate_feedback=False)
324
325         config.usage.keymap = ConfigText(default = eEnv.resolve("${datadir}/enigma2/keymap.xml"))
326
327         config.seek = ConfigSubsection()
328         config.seek.selfdefined_13 = ConfigNumber(default=15)
329         config.seek.selfdefined_46 = ConfigNumber(default=60)
330         config.seek.selfdefined_79 = ConfigNumber(default=300)
331
332         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])
333         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])
334         config.seek.speeds_slowmotion = ConfigSet(default=[2, 4, 8], choices=[2, 4, 6, 8, 12, 16, 25])
335
336         config.seek.enter_forward = ConfigSelection(default = "2", choices = ["2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
337         config.seek.enter_backward = ConfigSelection(default = "1", choices = ["1", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
338
339         config.seek.on_pause = ConfigSelection(default = "play", choices = [
340                 ("play", _("Play")),
341                 ("step", _("Single step (GOP)")),
342                 ("last", _("Last speed")) ])
343
344         config.usage.timerlist_finished_timer_position = ConfigSelection(default = "end", choices = [("beginning", _("At beginning")), ("end", _("At end"))])
345
346         def updateEnterForward(configElement):
347                 if not configElement.value:
348                         configElement.value = [2]
349                 updateChoices(config.seek.enter_forward, configElement.value)
350
351         config.seek.speeds_forward.addNotifier(updateEnterForward, immediate_feedback = False)
352
353         def updateEnterBackward(configElement):
354                 if not configElement.value:
355                         configElement.value = [2]
356                 updateChoices(config.seek.enter_backward, configElement.value)
357
358         config.seek.speeds_backward.addNotifier(updateEnterBackward, immediate_feedback = False)
359
360         def updateEraseSpeed(el):
361                 eBackgroundFileEraser.getInstance().setEraseSpeed(int(el.value))
362         def updateEraseFlags(el):
363                 eBackgroundFileEraser.getInstance().setEraseFlags(int(el.value))
364         config.misc.erase_speed = ConfigSelection(default="20", choices = [
365                 ("10", "10 MB/s"),
366                 ("20", "20 MB/s"),
367                 ("50", "50 MB/s"),
368                 ("100", "100 MB/s")])
369         config.misc.erase_speed.addNotifier(updateEraseSpeed, immediate_feedback = False)
370         config.misc.erase_flags = ConfigSelection(default="1", choices = [
371                 ("0", _("Disable")),
372                 ("1", _("Internal hdd only")),
373                 ("3", _("Everywhere"))])
374         config.misc.erase_flags.addNotifier(updateEraseFlags, immediate_feedback = False)
375
376         if SystemInfo["ZapMode"]:
377                 def setZapmode(el):
378                         open(SystemInfo["ZapMode"], "w").write(el.value)
379                 config.misc.zapmode = ConfigSelection(default = "mute", choices = [
380                         ("mute", _("Black screen")), ("hold", _("Hold screen")), ("mutetilllock", _("Black screen till locked")), ("holdtilllock", _("Hold till locked"))])
381                 config.misc.zapmode.addNotifier(setZapmode, immediate_feedback = False)
382
383         if SystemInfo["VFD_scroll_repeats"]:
384                 def scroll_repeats(el):
385                         open(SystemInfo["VFD_scroll_repeats"], "w").write(el.value)
386                 choicelist = []
387                 for i in range(1, 11, 1):
388                         choicelist.append((str(i)))
389                 config.usage.vfd_scroll_repeats = ConfigSelection(default = "3", choices = choicelist)
390                 config.usage.vfd_scroll_repeats.addNotifier(scroll_repeats, immediate_feedback = False)
391
392         if SystemInfo["VFD_scroll_delay"]:
393                 def scroll_delay(el):
394                         open(SystemInfo["VFD_scroll_delay"], "w").write(el.value)
395                 choicelist = []
396                 for i in range(0, 1001, 50):
397                         choicelist.append((str(i)))
398                 config.usage.vfd_scroll_delay = ConfigSelection(default = "150", choices = choicelist)
399                 config.usage.vfd_scroll_delay.addNotifier(scroll_delay, immediate_feedback = False)
400
401         if SystemInfo["VFD_initial_scroll_delay"]:
402                 def initial_scroll_delay(el):
403                         open(SystemInfo["VFD_initial_scroll_delay"], "w").write(el.value)
404                 choicelist = []
405                 for i in range(0, 20001, 500):
406                         choicelist.append((str(i)))
407                 config.usage.vfd_initial_scroll_delay = ConfigSelection(default = "1000", choices = choicelist)
408                 config.usage.vfd_initial_scroll_delay.addNotifier(initial_scroll_delay, immediate_feedback = False)
409
410         if SystemInfo["VFD_final_scroll_delay"]:
411                 def final_scroll_delay(el):
412                         open(SystemInfo["VFD_final_scroll_delay"], "w").write(el.value)
413                 choicelist = []
414                 for i in range(0, 20001, 500):
415                         choicelist.append((str(i)))
416                 config.usage.vfd_final_scroll_delay = ConfigSelection(default = "1000", choices = choicelist)
417                 config.usage.vfd_final_scroll_delay.addNotifier(final_scroll_delay, immediate_feedback = False)
418
419         config.subtitles = ConfigSubsection()
420         config.subtitles.ttx_subtitle_colors = ConfigSelection(default = "1", choices = [
421                 ("0", _("original")),
422                 ("1", _("white")),
423                 ("2", _("yellow")) ])
424         config.subtitles.ttx_subtitle_original_position = ConfigYesNo(default = False)
425         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")
426         config.subtitles.subtitle_alignment = ConfigSelection(choices = [("left", _("left")), ("center", _("center")), ("right", _("right"))], default = "center")
427         config.subtitles.subtitle_rewrap = ConfigYesNo(default = False)
428         config.subtitles.colourise_dialogs = ConfigYesNo(default = False)
429         config.subtitles.subtitle_borderwidth = ConfigSelection(choices = ["1", "2", "3", "4", "5"], default = "3")
430         config.subtitles.subtitle_fontsize  = ConfigSelection(choices = ["%d" % x for x in range(16,101) if not x % 2], default = "40")
431
432         subtitle_delay_choicelist = []
433         for i in range(-900000, 1845000, 45000):
434                 if i == 0:
435                         subtitle_delay_choicelist.append(("0", _("No delay")))
436                 else:
437                         subtitle_delay_choicelist.append((str(i), "%2.1f sec" % (i / 90000.)))
438         config.subtitles.subtitle_noPTSrecordingdelay = ConfigSelection(default = "315000", choices = subtitle_delay_choicelist)
439
440         config.subtitles.dvb_subtitles_yellow = ConfigYesNo(default = False)
441         config.subtitles.dvb_subtitles_original_position = ConfigSelection(default = "0", choices = [("0", _("Original")), ("1", _("Fixed")), ("2", _("Relative"))])
442         config.subtitles.dvb_subtitles_centered = ConfigYesNo(default = True)
443         config.subtitles.subtitle_bad_timing_delay = ConfigSelection(default = "0", choices = subtitle_delay_choicelist)
444         config.subtitles.dvb_subtitles_backtrans = ConfigSelection(default = "0", choices = [
445                 ("0", _("No transparency")),
446                 ("25", "10%"),
447                 ("50", "20%"),
448                 ("75", "30%"),
449                 ("100", "40%"),
450                 ("125", "50%"),
451                 ("150", "60%"),
452                 ("175", "70%"),
453                 ("200", "80%"),
454                 ("225", "90%"),
455                 ("255", _("Full transparency"))])
456         config.subtitles.pango_subtitle_colors = ConfigSelection(default = "1", choices = [
457                 ("0", _("alternative")),
458                 ("1", _("white")),
459                 ("2", _("yellow")) ])
460         config.subtitles.pango_subtitle_fontswitch = ConfigYesNo(default = True)
461         config.subtitles.pango_subtitles_delay = ConfigSelection(default = "0", choices = subtitle_delay_choicelist)
462         config.subtitles.pango_subtitles_fps = ConfigSelection(default = "1", choices = [
463                 ("1", _("Original")),
464                 ("23976", _("23.976")),
465                 ("24000", _("24")),
466                 ("25000", _("25")),
467                 ("29970", _("29.97")),
468                 ("30000", _("30"))])
469         config.subtitles.pango_autoturnon = ConfigYesNo(default = True)
470
471         config.autolanguage = ConfigSubsection()
472         audio_language_choices=[
473                 ("---", _("None")),
474                 ("orj dos ory org esl qaa und mis mul ORY ORJ Audio_ORJ", _("Original")),
475                 ("ara", _("Arabic")),
476                 ("eus baq", _("Basque")),
477                 ("bul", _("Bulgarian")),
478                 ("hrv", _("Croatian")),
479                 ("ces cze", _("Czech")),
480                 ("dan", _("Danish")),
481                 ("dut ndl", _("Dutch")),
482                 ("eng qaa", _("English")),
483                 ("est", _("Estonian")),
484                 ("fin", _("Finnish")),
485                 ("fra fre", _("French")),
486                 ("deu ger", _("German")),
487                 ("ell gre", _("Greek")),
488                 ("heb", _("Hebrew")),
489                 ("hun", _("Hungarian")),
490                 ("ita", _("Italian")),
491                 ("lav", _("Latvian")),
492                 ("lit", _("Lithuanian")),
493                 ("ltz", _("Luxembourgish")),
494                 ("nor", _("Norwegian")),
495                 ("pol", _("Polish")),
496                 ("por", _("Portuguese")),
497                 ("fas per", _("Persian")),
498                 ("ron rum", _("Romanian")),
499                 ("rus", _("Russian")),
500                 ("srp", _("Serbian")),
501                 ("slk slo", _("Slovak")),
502                 ("slv", _("Slovenian")),
503                 ("spa", _("Spanish")),
504                 ("swe", _("Swedish")),
505                 ("tha", _("Thai")),
506                 ("tur Audio_TUR", _("Turkish")),
507                 ("ukr Ukr", _("Ukrainian"))]
508
509         def setEpgLanguage(configElement):
510                 eServiceEvent.setEPGLanguage(configElement.value)
511         config.autolanguage.audio_epglanguage = ConfigSelection(audio_language_choices[:1] + audio_language_choices [2:], default="---")
512         config.autolanguage.audio_epglanguage.addNotifier(setEpgLanguage)
513
514         def setEpgLanguageAlternative(configElement):
515                 eServiceEvent.setEPGLanguageAlternative(configElement.value)
516         config.autolanguage.audio_epglanguage_alternative = ConfigSelection(audio_language_choices[:1] + audio_language_choices [2:], default="---")
517         config.autolanguage.audio_epglanguage_alternative.addNotifier(setEpgLanguageAlternative)
518
519         config.autolanguage.audio_autoselect1 = ConfigSelection(choices=audio_language_choices, default="---")
520         config.autolanguage.audio_autoselect2 = ConfigSelection(choices=audio_language_choices, default="---")
521         config.autolanguage.audio_autoselect3 = ConfigSelection(choices=audio_language_choices, default="---")
522         config.autolanguage.audio_autoselect4 = ConfigSelection(choices=audio_language_choices, default="---")
523         config.autolanguage.audio_defaultac3 = ConfigYesNo(default = False)
524         config.autolanguage.audio_defaultddp = ConfigYesNo(default = False)
525         config.autolanguage.audio_usecache = ConfigYesNo(default = True)
526
527         subtitle_language_choices = audio_language_choices[:1] + audio_language_choices [2:]
528         config.autolanguage.subtitle_autoselect1 = ConfigSelection(choices=subtitle_language_choices, default="---")
529         config.autolanguage.subtitle_autoselect2 = ConfigSelection(choices=subtitle_language_choices, default="---")
530         config.autolanguage.subtitle_autoselect3 = ConfigSelection(choices=subtitle_language_choices, default="---")
531         config.autolanguage.subtitle_autoselect4 = ConfigSelection(choices=subtitle_language_choices, default="---")
532         config.autolanguage.subtitle_hearingimpaired = ConfigYesNo(default = False)
533         config.autolanguage.subtitle_defaultimpaired = ConfigYesNo(default = False)
534         config.autolanguage.subtitle_defaultdvb = ConfigYesNo(default = False)
535         config.autolanguage.subtitle_usecache = ConfigYesNo(default = True)
536         config.autolanguage.equal_languages = ConfigSelection(default = "15", choices = [
537                 ("0", _("None")),("1", "1"),("2", "2"),("3", "1,2"),
538                 ("4", "3"),("5", "1,3"),("6", "2,3"),("7", "1,2,3"),
539                 ("8", "4"),("9", "1,4"),("10", "2,4"),("11", "1,2,4"),
540                 ("12", "3,4"),("13", "1,3,4"),("14", "2,3,4"),("15", _("All"))])
541
542         config.streaming = ConfigSubsection()
543         config.streaming.stream_ecm = ConfigYesNo(default = False)
544         config.streaming.descramble = ConfigYesNo(default = True)
545         config.streaming.stream_eit = ConfigYesNo(default = True)
546         config.streaming.stream_ait = ConfigYesNo(default = True)
547         config.streaming.authentication = ConfigYesNo(default = False)
548
549 def updateChoices(sel, choices):
550         if choices:
551                 defval = None
552                 val = int(sel.value)
553                 if not val in choices:
554                         tmp = choices[:]
555                         tmp.reverse()
556                         for x in tmp:
557                                 if x < val:
558                                         defval = str(x)
559                                         break
560                 sel.setChoices(map(str, choices), defval)
561
562 def preferredPath(path):
563         if config.usage.setup_level.index < 2 or path == "<default>":
564                 return None  # config.usage.default_path.value, but delay lookup until usage
565         elif path == "<current>":
566                 return config.movielist.last_videodir.value
567         elif path == "<timer>":
568                 return config.movielist.last_timer_videodir.value
569         else:
570                 return path
571
572 def preferredTimerPath():
573         return preferredPath(config.usage.timer_path.value)
574
575 def preferredInstantRecordPath():
576         return preferredPath(config.usage.instantrec_path.value)
577
578 def defaultMoviePath():
579         return defaultRecordingLocation(config.usage.default_path.value)