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