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