treewide: remove references to /media/cf and /media/usb
[enigma2-plugins.git] / merlinepgcenter / src / ConfigTabs.py
1 #
2 #  MerlinEPGCenter E2 Plugin
3 #
4 #  $Id: ConfigTabs.py,v 1.0 2011-06-13 17:15:00 shaderman Exp $
5 #
6 #  Coded by Shaderman (c) 2011
7 #  Support: www.dreambox-tools.info
8 #
9 #  This plugin is licensed under the Creative Commons 
10 #  Attribution-NonCommercial-ShareAlike 3.0 Unported 
11 #  License. To view a copy of this license, visit
12 #  http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative
13 #  Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
14 #
15 #  Alternatively, this plugin may be distributed and executed on hardware which
16 #  is licensed by Dream Multimedia GmbH.
17
18 #  This plugin is NOT free software. It is open source, you are allowed to
19 #  modify it (if you keep the license), but it may not be commercially 
20 #  distributed other than under the conditions noted above.
21 #
22         
23
24 # for localized messages
25 from . import _
26
27 # ENIGMA IMPORTS
28 from Components.config import config, ConfigSubsection, getConfigListEntry, ConfigSet, ConfigClock, ConfigYesNo, ConfigInteger, ConfigSelection, ConfigText, NoSave, ConfigSelectionNumber
29 from enigma import eEnv
30 from Tools.Directories import SCOPE_CURRENT_PLUGIN, resolveFilename
31
32 STYLE_SIMPLE_BAR = "0"
33 STYLE_PIXMAP_BAR = "1"
34 STYLE_MULTI_PIXMAP = "2"
35 STYLE_PERCENT_TEXT = "3"
36 STYLE_SIMPLE_BAR_LIST_OFF = "4"
37 STYLE_PIXMAP_BAR_LIST_OFF = "5"
38 STYLE_MULTI_PIXMAP_LIST_OFF = "6"
39 STYLE_PERCENT_TEXT_LIST_OFF = "7"
40
41 SKINDIR = "Extensions/MerlinEPGCenter/skins/"
42
43 SKINLIST =      [ # order is important (HD_BORDER, XD_BORDER, SD, HD, XD)!
44                 (resolveFilename(SCOPE_CURRENT_PLUGIN, ''.join([SKINDIR, "HD_border.xml"])), "HD_border.xml"),
45                 (resolveFilename(SCOPE_CURRENT_PLUGIN, ''.join([SKINDIR, "XD_border.xml"])), "XD_border.xml"),
46                 (resolveFilename(SCOPE_CURRENT_PLUGIN, ''.join([SKINDIR, "SD_default.xml"])), "SD_default.xml"),
47                 (resolveFilename(SCOPE_CURRENT_PLUGIN, ''.join([SKINDIR, "HD_default.xml"])), "HD_default.xml"),
48                 (resolveFilename(SCOPE_CURRENT_PLUGIN, ''.join([SKINDIR, "XD_default.xml"])), "XD_default.xml")
49                 ]
50                 
51 # check Merlin2 feature "keep outdated events in epgcache"
52 try:
53         KEEP_OUTDATED_TIME = config.merlin2.keep_outdated_epg.value * 60
54 except KeyError:
55         KEEP_OUTDATED_TIME = 0
56         
57
58 # OWN IMPORTS
59 from EpgCenterList import MULTI_EPG_NOW, MULTI_EPG_NEXT, SINGLE_EPG, MULTI_EPG_PRIMETIME, TIMERLIST, EPGSEARCH_HISTORY
60 from MerlinEPGCenter import STYLE_SINGLE_LINE, STYLE_SHORT_DESCRIPTION, TAB_TEXT_EPGLIST
61 from SkinFinder import SkinFinder
62
63 TAB_CHOICES = [ ("-1", _("disabled")),
64                 (str(MULTI_EPG_NOW), TAB_TEXT_EPGLIST[MULTI_EPG_NOW]),
65                 (str(MULTI_EPG_NEXT), TAB_TEXT_EPGLIST[MULTI_EPG_NEXT]),
66                 (str(SINGLE_EPG), TAB_TEXT_EPGLIST[SINGLE_EPG]),
67                 (str(MULTI_EPG_PRIMETIME), TAB_TEXT_EPGLIST[MULTI_EPG_PRIMETIME]),
68                 (str(TIMERLIST), TAB_TEXT_EPGLIST[TIMERLIST]),
69                 (str(EPGSEARCH_HISTORY), TAB_TEXT_EPGLIST[EPGSEARCH_HISTORY]),]
70
71
72 config.plugins.merlinEpgCenter = ConfigSubsection()
73 config.plugins.merlinEpgCenter.primeTime = ConfigClock(default = 69300)
74 config.plugins.merlinEpgCenter.showListNumbers = ConfigYesNo(True)
75 config.plugins.merlinEpgCenter.showPicons = ConfigYesNo(False)
76 config.plugins.merlinEpgCenter.showServiceName = ConfigYesNo(True)
77 config.plugins.merlinEpgCenter.serviceNameWidth = ConfigSelectionNumber(min = -10, max = 20, stepwidth = 1, default = 0)
78 config.plugins.merlinEpgCenter.lastUsedTab = ConfigInteger(0)
79 config.plugins.merlinEpgCenter.showEventInfo = ConfigYesNo(True)
80 config.plugins.merlinEpgCenter.showVideoPicture = ConfigYesNo(True)
81 config.plugins.merlinEpgCenter.rememberLastTab = ConfigYesNo(True)
82 config.plugins.merlinEpgCenter.selectRunningService = ConfigYesNo(True)
83 config.plugins.merlinEpgCenter.replaceInfobarEpg = ConfigYesNo(False)
84 config.plugins.merlinEpgCenter.replaceInfobarChannelUp = ConfigSelection(default = "-1", choices = TAB_CHOICES)
85 config.plugins.merlinEpgCenter.replaceInfobarChannelDown = ConfigSelection(default = "-1", choices = TAB_CHOICES)
86 config.plugins.merlinEpgCenter.replaceShowEventView = ConfigSelection(default = "-1", choices = TAB_CHOICES)
87 config.plugins.merlinEpgCenter.epgPaths = ConfigSelection(default = eEnv.resolve('${datadir}/enigma2/picon_50x30/'), choices = [
88                                 (eEnv.resolve('${datadir}/enigma2/picon_50x30/'), eEnv.resolve('${datadir}/enigma2/picon_50x30')),
89                                 ])
90 config.plugins.merlinEpgCenter.showColoredEpgTimes = ConfigYesNo(True)
91 config.plugins.merlinEpgCenter.searchString = NoSave(ConfigText(default = ""))
92 config.plugins.merlinEpgCenter.searchHistory = ConfigSet(choices = [])
93 config.plugins.merlinEpgCenter.showInputHelp = ConfigYesNo(True)
94 config.plugins.merlinEpgCenter.listItemHeight = ConfigSelectionNumber(min = 0, max = 20, stepwidth = 2, default = 0, wraparound = True)
95 config.plugins.merlinEpgCenter.listStyle = ConfigSelection(default = STYLE_SINGLE_LINE, choices = [
96                                 (STYLE_SINGLE_LINE, _("single line style")),
97                                 (STYLE_SHORT_DESCRIPTION, _("with short description")),
98                                 ])
99 config.plugins.merlinEpgCenter.skin = ConfigText(default = "")
100 config.plugins.merlinEpgCenter.skinSelection = NoSave(ConfigSelection(choices = []))
101 config.plugins.merlinEpgCenter.limitSearchToBouquetServices = ConfigYesNo(False)
102 config.plugins.merlinEpgCenter.exitOnTvRadioSwitch = ConfigYesNo(False)
103 config.plugins.merlinEpgCenter.numNextEvents = ConfigSelectionNumber(min = 0, max = 3, stepwidth = 1, default = 1, wraparound = True)
104 config.plugins.merlinEpgCenter.showDuration = ConfigYesNo(True)
105 config.plugins.merlinEpgCenter.showBeginRemainTime = ConfigYesNo(True)
106 config.plugins.merlinEpgCenter.listProgressStyle = ConfigSelection(default = STYLE_PIXMAP_BAR, choices = [
107                                 (STYLE_SIMPLE_BAR, _("list and event info: simple")),
108                                 (STYLE_PIXMAP_BAR, _("list and event info: gradient")),
109                                 (STYLE_MULTI_PIXMAP, _("list and event info: four parts")),
110                                 (STYLE_PERCENT_TEXT, _("list and event info: percent (text)")),
111                                 (STYLE_SIMPLE_BAR_LIST_OFF, _("list: off, event info: simple")),
112                                 (STYLE_PIXMAP_BAR_LIST_OFF, _("list: off, event info: gradient")),
113                                 (STYLE_MULTI_PIXMAP_LIST_OFF, _("list: off, event info: four parts")),
114                                 (STYLE_PERCENT_TEXT_LIST_OFF, _("list: off, event info: percent (text)")),
115                                 ])
116 config.plugins.merlinEpgCenter.blinkingPicon = ConfigYesNo(False)
117 config.plugins.merlinEpgCenter.showShortDescInEventInfo = ConfigYesNo(True)
118 config.plugins.merlinEpgCenter.adjustFontSize = ConfigSelectionNumber(min = -5, max = 5, stepwidth = 1, default = 0)
119 config.plugins.merlinEpgCenter.mainTab = ConfigSelection(default = "-1", choices = TAB_CHOICES)
120 config.plugins.merlinEpgCenter.embeddedVolume = ConfigYesNo(False)
121 config.plugins.merlinEpgCenter.columnSpace = ConfigSelectionNumber(min = 0, max = 40, stepwidth = 1, default = 5, wraparound = True)
122
123 # INVISIBLE OPTIONS
124 # These config values should be set in the skin in a <applet type="onLayoutFinish"></applet> tag
125
126 # Set it to false to disable the dependency between the videoPicture/MiniTv and the description widget.
127 # This allows moving the videoPicture/MiniTv widget above the description text.
128 config.plugins.merlinEpgCenter.setDescriptionSize = NoSave(ConfigYesNo(True))
129
130 # Two background Pixmaps can be set. These will be swapped for the lists "timerlist", "list", "history" and "settings",
131 # depending on the value of config.plugins.merlinEpgCenter.showEventInfo
132 config.plugins.merlinEpgCenter.backgroundPixmapShort = NoSave(ConfigText(default = ""))
133 config.plugins.merlinEpgCenter.backgroundPixmapLong = NoSave(ConfigText(default = ""))
134
135 config.plugins.merlinEpgCenter.selectionPixmapShort = NoSave(ConfigText(default = ""))
136 config.plugins.merlinEpgCenter.selectionPixmapLong = NoSave(ConfigText(default = ""))
137
138 # Use this to override the default tab text color
139 config.plugins.merlinEpgCenter.tabTextColorSelected = NoSave(ConfigText(default = "#ef7f1a"))
140
141 # Default is to show the text "Bouquet:" in front of a bouquet name. Use this option to hide it
142 config.plugins.merlinEpgCenter.showBouquetText = NoSave(ConfigYesNo(True))
143
144 # Allows changing the color of the event title in lists
145 config.plugins.merlinEpgCenter.titleColor = NoSave(ConfigInteger(default = 0x00ffffff))
146 config.plugins.merlinEpgCenter.titleColorSelected = NoSave(ConfigInteger(default = 0x00ffffff))
147
148 # Show the primetime value on tab 4 instead of the text "Prime Time"
149 config.plugins.merlinEpgCenter.showPrimeTimeValue = NoSave(ConfigYesNo(False))
150
151
152 ############################################################################################
153 # CONFIG CLASSES
154
155 # base class for all config tab classes
156 class ConfigBaseTab():
157         settingsWidget  = None
158         
159         def __init__(self):
160                 pass
161                 
162         # activate this tab
163         def show(self):
164                 ConfigBaseTab.settingsWidget.setList(self.configList)
165                 
166         def expandableSettingChanged(self, configElement = None):
167                 self.buildConfigList()
168                 self.show()
169                 
170         def removeNotifier(self):
171                 pass
172                 
173 # config general
174 class ConfigGeneral(ConfigBaseTab):
175         def __init__(self):
176                 ConfigBaseTab.__init__(self)
177                 self.configList = []
178                 self.buildConfigList()
179                 
180         def show(self):
181                 ConfigBaseTab.settingsWidget.setList(self.configList)
182                 
183         def buildConfigList(self):
184                 cfgList = []
185                 cfgList.append(getConfigListEntry(_("Prime time:"), config.plugins.merlinEpgCenter.primeTime))
186                 cfgList.append(getConfigListEntry(_("Remember last tab:"), config.plugins.merlinEpgCenter.rememberLastTab))
187                 cfgList.append(getConfigListEntry(_("Select running service on start:"), config.plugins.merlinEpgCenter.selectRunningService))
188                 cfgList.append(getConfigListEntry(_("Show text input help for epg search:"), config.plugins.merlinEpgCenter.showInputHelp))
189                 cfgList.append(getConfigListEntry(_("Use skin:"), config.plugins.merlinEpgCenter.skinSelection))
190                 cfgList.append(getConfigListEntry(_("Limit search results to bouquet services:"), config.plugins.merlinEpgCenter.limitSearchToBouquetServices))
191                 cfgList.append(getConfigListEntry(_("Exit on TV <-> Radio switch:"), config.plugins.merlinEpgCenter.exitOnTvRadioSwitch))
192                 cfgList.append(getConfigListEntry(_("Adjust font size:"), config.plugins.merlinEpgCenter.adjustFontSize))
193                 cfgList.append(getConfigListEntry(_("Embed volume slider:"), config.plugins.merlinEpgCenter.embeddedVolume))
194                 self.configList = cfgList
195                 
196 # config list settings
197 class ConfigListSettings(ConfigBaseTab):
198         def __init__(self):
199                 ConfigBaseTab.__init__(self)
200                 self.configList = []
201                 self.buildConfigList()
202                 self.setNotifier()
203                 
204         def buildConfigList(self):
205                 cfgList = []
206                 cfgList.append(getConfigListEntry(_("Show list numbers:"), config.plugins.merlinEpgCenter.showListNumbers))
207                 cfgList.append(getConfigListEntry(_("Show picons:"), config.plugins.merlinEpgCenter.showPicons))
208                 if config.plugins.merlinEpgCenter.showPicons.value:
209                         cfgList.append(getConfigListEntry(_("Use picons (50x30) from:"), config.plugins.merlinEpgCenter.epgPaths))
210                 cfgList.append(getConfigListEntry(_("Show service name:"), config.plugins.merlinEpgCenter.showServiceName))
211                 if config.plugins.merlinEpgCenter.showServiceName.value:
212                         cfgList.append(getConfigListEntry(_("Adjust service name column width:"), config.plugins.merlinEpgCenter.serviceNameWidth))
213                 cfgList.append(getConfigListEntry(_("Show duration:"), config.plugins.merlinEpgCenter.showDuration))
214                 cfgList.append(getConfigListEntry(_("Show begin/remain times:"), config.plugins.merlinEpgCenter.showBeginRemainTime))
215                 if config.plugins.merlinEpgCenter.showBeginRemainTime.value:
216                         cfgList.append(getConfigListEntry(_("Show multi colored begin/remain times:"), config.plugins.merlinEpgCenter.showColoredEpgTimes))
217                 cfgList.append(getConfigListEntry(_("Increase list item height:"), config.plugins.merlinEpgCenter.listItemHeight))
218                 cfgList.append(getConfigListEntry(_("Space between columns:"), config.plugins.merlinEpgCenter.columnSpace))
219                 cfgList.append(getConfigListEntry(_("List style:"), config.plugins.merlinEpgCenter.listStyle))
220                 cfgList.append(getConfigListEntry(_("Progress bar style:"), config.plugins.merlinEpgCenter.listProgressStyle))
221                 cfgList.append(getConfigListEntry(_("Number of upcoming events to show:"), config.plugins.merlinEpgCenter.numNextEvents))
222                 self.configList = cfgList
223                 
224         def setNotifier(self):
225                 config.plugins.merlinEpgCenter.showPicons.addNotifier(self.expandableSettingChanged, initial_call = False)
226                 config.plugins.merlinEpgCenter.epgPaths.addNotifier(self.piconPathChanged, initial_call = False)
227                 config.plugins.merlinEpgCenter.showBeginRemainTime.addNotifier(self.expandableSettingChanged, initial_call = False)
228                 config.plugins.merlinEpgCenter.showServiceName.addNotifier(self.expandableSettingChanged, initial_call = False)
229                 
230         def removeNotifier(self):
231                 config.plugins.merlinEpgCenter.showPicons.removeNotifier(self.expandableSettingChanged)
232                 config.plugins.merlinEpgCenter.epgPaths.removeNotifier(self.piconPathChanged)
233                 config.plugins.merlinEpgCenter.showBeginRemainTime.removeNotifier(self.expandableSettingChanged)
234                 config.plugins.merlinEpgCenter.showServiceName.removeNotifier(self.expandableSettingChanged)
235                 
236         def piconPathChanged(self, configElement = None):
237                 config.plugins.merlinEpgCenter.epgPaths.save()
238                 
239 # config event information
240 class ConfigEventInfo(ConfigBaseTab):
241         def __init__(self):
242                 ConfigBaseTab.__init__(self)
243                 self.configList = []
244                 self.buildConfigList()
245                 self.setNotifier()
246                 
247         def buildConfigList(self):
248                 cfgList = []
249                 cfgList.append(getConfigListEntry(_("Show event information:"), config.plugins.merlinEpgCenter.showEventInfo))
250                 if config.plugins.merlinEpgCenter.showEventInfo.value:
251                         cfgList.append(getConfigListEntry(_("Show video picture:"), config.plugins.merlinEpgCenter.showVideoPicture))
252                 cfgList.append(getConfigListEntry(_("Show blinking picon for running timers:"), config.plugins.merlinEpgCenter.blinkingPicon))
253                 cfgList.append(getConfigListEntry(_("Show short description:"), config.plugins.merlinEpgCenter.showShortDescInEventInfo))
254                 self.configList = cfgList
255                         
256         def setNotifier(self):
257                 config.plugins.merlinEpgCenter.showEventInfo.addNotifier(self.expandableSettingChanged, initial_call = False)
258                 
259         def removeNotifier(self):
260                 config.plugins.merlinEpgCenter.showEventInfo.removeNotifier(self.expandableSettingChanged)
261                 
262 # config key settings
263 class ConfigKeys(ConfigBaseTab):
264         def __init__(self):
265                 ConfigBaseTab.__init__(self)
266                 self.configList = []
267                 self.buildConfigList()
268                 
269         def buildConfigList(self):
270                 cfgList = []
271                 cfgList.append(getConfigListEntry(_("Return to main tab with exit:"), config.plugins.merlinEpgCenter.mainTab))
272                 cfgList.append(getConfigListEntry(_("Replace InfoBar single and multi EPG:"), config.plugins.merlinEpgCenter.replaceInfobarEpg))
273                 cfgList.append(getConfigListEntry(_("Replace ChannelSelection key up to start with tab:"), config.plugins.merlinEpgCenter.replaceInfobarChannelUp))
274                 cfgList.append(getConfigListEntry(_("Replace ChannelSelection key down to start with tab:"), config.plugins.merlinEpgCenter.replaceInfobarChannelDown))
275                 cfgList.append(getConfigListEntry(_("Replace EventView key to start with tab:"), config.plugins.merlinEpgCenter.replaceShowEventView))
276                 self.configList = cfgList
277