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