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