1 #######################################################################
4 # Vali-XD-Skins Control for Dreambox/Enigma-2
5 # Coded by Vali (c)2009-2010
6 # Support: www.dreambox-tools.info
9 # This plugin is licensed under the Creative Commons
10 # Attribution-NonCommercial-ShareAlike 3.0 Unported License.
11 # To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
12 # or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
14 # Alternatively, this plugin may be distributed and executed on hardware which
15 # is licensed by Dream Multimedia GmbH.
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.
23 #######################################################################
27 from Plugins.Plugin import PluginDescriptor
28 from Screens.Screen import Screen
29 from Screens.MessageBox import MessageBox
30 from Screens.ChoiceBox import ChoiceBox
31 from Screens.Console import Console
32 from Screens.Standby import TryQuitMainloop
33 from Components.ActionMap import ActionMap
34 from Components.config import config, ConfigYesNo, ConfigSubsection, getConfigListEntry, ConfigSelection, ConfigText, ConfigInteger
35 from Components.ConfigList import ConfigListScreen
36 from Components.Label import Label
37 from Tools.Directories import fileExists
38 from skin import parseColor
43 config.plugins.valiXDsetup = ConfigSubsection()
44 config.plugins.valiXDsetup.ShowPicons = ConfigYesNo(default = False)
45 config.plugins.valiXDsetup.CenterMenus = ConfigYesNo(default = False)
46 config.plugins.valiXDsetup.Style = ConfigSelection(default="base", choices = [
48 ("beyonddreams", _("Beyond Dreams")),
49 ("validator", _("Validator")),
50 ("shadow", _("Magic Shadow")),
51 ("shadow2", _("New Shadow")),
53 ("metalpad", _("Metal Pad")),
54 ("vision", _("New Vision")),
55 ("atlantis", _("Atlantis")),
56 ("avalon", _("Avalon")),
57 ("blues", _("Blues of dream"))
59 config.plugins.valiXDsetup.ChannSelector = ConfigSelection(default="simple", choices = [
60 ("simple", _("Simple")),
62 ("full-vert", _("Full-vertical")),
63 ("full-hor", _("Full-horizontal")),
64 ("pig", _("with PiG"))
66 config.plugins.valiXDsetup.dmType = ConfigSelection(default="800", choices = [
67 ("800", _("DM-800 Simple")),
68 ("8000", _("DM-8000 Full")),
69 ("7025", _("DM-7025")),
70 ("verysimple", _("Very simple"))
72 config.plugins.valiXDsetup.BG = ConfigText(default = "18111112", fixed_size=8)
73 config.plugins.valiXDsetup.FG = ConfigText(default = "f0f0f0", fixed_size=6)
74 config.plugins.valiXDsetup.secondBG = ConfigText(default = "18071230", fixed_size=8)
75 config.plugins.valiXDsetup.secondFG = ConfigText(default = "fcc000", fixed_size=6)
76 config.plugins.valiXDsetup.selBG = ConfigText(default = "08303240", fixed_size=8)
77 config.plugins.valiXDsetup.selFG = ConfigText(default = "fcc000", fixed_size=6)
78 config.plugins.valiXDsetup.pollTime = ConfigInteger(default = 15, limits = (3, 60))
82 def main(session, **kwargs):
83 if fileExists("/usr/share/enigma2/Vali-XD/skin.xml"):
86 #session.open(MessageBox,_("Vali-XD skin not installed.\nWe have nothing to control."), MessageBox.TYPE_INFO)
91 def Plugins(**kwargs):
92 return PluginDescriptor(name="Vali-XD Skin Control", description=_("Configuration tool for Vali-XD skins"), where = PluginDescriptor.WHERE_PLUGINMENU, icon="plugin.png", fnc=main)
96 #######################################################################
101 class XDsetup(ConfigListScreen, Screen):
103 <screen name="XDsetup" position="center,center" size="600,340" title="Vali-XD-Skin Control">
104 <eLabel font="Regular;20" foregroundColor="#00ff4A3C" halign="center" position="20,308" size="120,26" text="Cancel"/>
105 <eLabel font="Regular;20" foregroundColor="#0056C856" halign="center" position="165,308" size="120,26" text="Save"/>
106 <eLabel font="Regular;20" foregroundColor="#00ffc000" halign="center" position="300,308" size="140,26" text="Test colors"/>
107 <eLabel font="Regular;20" foregroundColor="#00879ce1" halign="center" position="455,308" size="120,26" text="ToolBox"/>
108 <widget name="config" position="5,5" scrollbarMode="showOnDemand" size="590,300"/>
109 <widget name="myTestLabel" position="1000,1000" size="2,2"/>
112 def __init__(self, session):
113 Screen.__init__(self, session)
114 self.session = session
115 self.datei = "/usr/share/enigma2/Vali-XD/skin.xml"
116 self.daten = "/usr/lib/enigma2/python/Plugins/Extensions/ValiXDControl/data/"
117 self.komponente = "/usr/lib/enigma2/python/Plugins/Extensions/ValiXDControl/comp/"
118 self["myTestLabel"] = Label(_("t"))
120 list.append(getConfigListEntry(_("Infobar and Window Style:"), config.plugins.valiXDsetup.Style))
121 list.append(getConfigListEntry(_("Channel and EPG selectors Style:"), config.plugins.valiXDsetup.ChannSelector))
122 list.append(getConfigListEntry(_("Show Picons (Reference):"), config.plugins.valiXDsetup.ShowPicons))
123 list.append(getConfigListEntry(_("Center Mainmenu and Plugins-list:"), config.plugins.valiXDsetup.CenterMenus))
124 list.append(getConfigListEntry(_("OLED Layout like:"), config.plugins.valiXDsetup.dmType))
125 list.append(getConfigListEntry(_("Base background:"), config.plugins.valiXDsetup.BG))
126 #list.append(getConfigListEntry(_("Base foreground:"), config.plugins.valiXDsetup.FG))
127 list.append(getConfigListEntry(_("Second background:"), config.plugins.valiXDsetup.secondBG))
128 list.append(getConfigListEntry(_("Second foreground:"), config.plugins.valiXDsetup.secondFG))
129 list.append(getConfigListEntry(_("Selected background:"), config.plugins.valiXDsetup.selBG))
130 list.append(getConfigListEntry(_("Selected foreground:"), config.plugins.valiXDsetup.selFG))
131 #list.append(getConfigListEntry(_("SmartInfo update time:"), config.plugins.valiXDsetup.pollTime))
132 ConfigListScreen.__init__(self, list)
133 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
137 "yellow": self.colortest,
138 "blue": self.toolBox,
141 self.onLayoutFinish.append(self.UpdateComponents)
143 def UpdateComponents(self):
144 system('cp ' + self.komponente + 'vRendVolumeText.py /usr/lib/enigma2/python/Components/Renderer/vRendVolumeText.py')
145 system('cp ' + self.komponente + 'vRendMaxTemp.py /usr/lib/enigma2/python/Components/Renderer/vRendMaxTemp.py')
146 system('cp ' + self.komponente + 'vRendChNumber.py /usr/lib/enigma2/python/Components/Renderer/vRendChNumber.py')
147 system('cp ' + self.komponente + 'vRendVideoSize.py /usr/lib/enigma2/python/Components/Renderer/vRendVideoSize.py')
148 system('cp ' + self.komponente + 'vRendMovieDirSize.py /usr/lib/enigma2/python/Components/Renderer/vRendMovieDirSize.py')
149 system('cp ' + self.komponente + 'vConvSmartInfo.py /usr/lib/enigma2/python/Components/Converter/vConvSmartInfo.py')
150 system('cp ' + self.komponente + 'vConvClockToText.py /usr/lib/enigma2/python/Components/Converter/vConvClockToText.py')
154 if fileExists("/usr/lib/enigma2/python/Components/Renderer/vRendChNumber.py") \
155 and fileExists("/usr/lib/enigma2/python/Components/Renderer/vRendMaxTemp.py") \
156 and fileExists("/usr/lib/enigma2/python/Components/Renderer/vRendVolumeText.py") \
157 and fileExists("/usr/lib/enigma2/python/Components/Renderer/vRendVideoSize.py") \
158 and fileExists("/usr/lib/enigma2/python/Components/Renderer/vRendMovieDirSize.py") \
159 and fileExists("/usr/lib/enigma2/python/Components/Converter/vConvSmartInfo.py") \
160 and fileExists("/usr/lib/enigma2/python/Components/Converter/vConvClockToText.py"):
163 self.session.open(MessageBox,_("Vali-XD converters and renderers are not installed!!!"), MessageBox.TYPE_ERROR)
165 for x in self["config"].list:
169 head_file = self.daten + "head.xml"
170 skFile = open(head_file, "r")
171 head_lines = skFile.readlines()
175 skn_file = self.daten + "skin-" + config.plugins.valiXDsetup.Style.value
176 if config.plugins.valiXDsetup.ShowPicons.value:
177 skn_file = skn_file + "-picon.xml"
179 skn_file = skn_file + ".xml"
180 if (config.plugins.valiXDsetup.Style.value=='base'):
181 if self.checkUserColors():
182 skin_lines.append(' <!-- ##### Colors ##### -->\n')
183 skin_lines.append(' <colors>\n')
184 skin_lines.append(' <color name="background" value="#'+config.plugins.valiXDsetup.BG.value+'"/>\n')
185 skin_lines.append(' <color name="foreground" value="#00f0f0f0"/>\n')
186 skin_lines.append(' <color name="secondBG" value="#'+config.plugins.valiXDsetup.secondBG.value+'"/>\n')
187 skin_lines.append(' <color name="secondFG" value="#00'+config.plugins.valiXDsetup.secondFG.value+'"/>\n')
188 skin_lines.append(' <color name="selectedBG" value="#'+config.plugins.valiXDsetup.selBG.value+'"/>\n')
189 skin_lines.append(' <color name="selectedFG" value="#00'+config.plugins.valiXDsetup.selFG.value+'"/>\n')
191 skin_lines.append(' <!-- ##### Colors ##### -->\n')
192 skin_lines.append(' <colors>\n')
193 skin_lines.append(' <color name="background" value="#18111112"/>\n')
194 skin_lines.append(' <color name="foreground" value="#00f0f0f0"/>\n')
195 skin_lines.append(' <color name="secondBG" value="#18071230"/>\n')
196 skin_lines.append(' <color name="secondFG" value="#00fcc000"/>\n')
197 skin_lines.append(' <color name="selectedBG" value="#08303240"/>\n')
198 skin_lines.append(' <color name="selectedFG" value="#00fcc000"/>\n')
199 skFile = open(skn_file, "r")
200 file_lines = skFile.readlines()
204 skn_file = self.daten + "channelselector-"
205 if config.plugins.valiXDsetup.ChannSelector.value=="pig":
206 skn_file = skn_file + "pig.xml"
207 elif config.plugins.valiXDsetup.ChannSelector.value=="full":
208 skn_file = skn_file + "full.xml"
209 elif config.plugins.valiXDsetup.ChannSelector.value=="full-vert":
210 skn_file = skn_file + "full-vert.xml"
211 elif config.plugins.valiXDsetup.ChannSelector.value=="full-hor":
212 skn_file = skn_file + "full-hor.xml"
214 skn_file = skn_file + "simple.xml"
215 skFile = open(skn_file, "r")
216 file_lines = skFile.readlines()
220 mnu_file = self.daten + "menu-"
221 if config.plugins.valiXDsetup.CenterMenus.value:
222 mnu_file = mnu_file + "center.xml"
224 mnu_file = mnu_file + "right.xml"
225 skFile = open(mnu_file, "r")
226 file_lines = skFile.readlines()
230 base_file = self.daten + "main.xml"
231 skFile = open(base_file, "r")
232 file_lines = skFile.readlines()
236 if config.plugins.valiXDsetup.dmType.value == "8000":
237 oled_file = self.daten + "oled-8000.xml"
238 elif config.plugins.valiXDsetup.dmType.value == "7025":
239 oled_file = self.daten + "oled-7025.xml"
240 elif config.plugins.valiXDsetup.dmType.value == "verysimple":
241 oled_file = self.daten + "oled-VerySymple.xml"
243 oled_file = self.daten + "oled-800.xml"
244 skFile = open(oled_file, "r")
245 file_lines = skFile.readlines()
249 xFile = open(self.datei, "w")
250 for xx in skin_lines:
254 self.session.open(MessageBox, _("Error by processing the skin file !!!"), MessageBox.TYPE_ERROR)
255 restartbox = self.session.openWithCallback(self.restartGUI,MessageBox,_("GUI needs a restart to apply a new skin.\nDo you want to Restart the GUI now?"), MessageBox.TYPE_YESNO)
256 restartbox.setTitle(_("Restart GUI now?"))
258 def restartGUI(self, answer):
260 self.session.open(TryQuitMainloop, 3)
265 for x in self["config"].list:
270 contextFileList = [(_("Help information"), "INFO"),
271 (_("Install round buttons"), "ROUNDBUTT"),
272 (_("Install magic buttons"), "MAGICBUTT"),
273 (_("Suomipoeka-Movielist patch"), "PATCHSUOMI"),
274 (_("Colored icons patch"), "PATCHCONSTABLE")]
275 self.session.openWithCallback(self.toolExec, ChoiceBox, title=_("Vali-XD Tool Box..."), list=contextFileList)
277 def toolExec(self, answer):
278 answer = answer and answer[1]
280 hilfeText = _("Color format: TTRRGGBB (hexadecimal)\nTT=Transparenty RR=Red GG=Green BB=Blue\nSee more colors by www.colorpicker.com\n\nSupport: www.dreambox-tools.info")
281 self.session.open(MessageBox, hilfeText, MessageBox.TYPE_INFO)
282 elif answer == "PATCHSUOMI":
283 self.session.open(Console, cmdlist=[("chmod 755 " + self.komponente + "suomi_patch"), (self.komponente + "suomi_patch")])
284 elif answer == "PATCHCONSTABLE":
285 self.session.open(Console, cmdlist=[("tar -xzvf " + self.komponente + "spetial_icons.tar.gz" + " -C /")])
286 elif answer == "ROUNDBUTT":
287 self.session.open(Console, cmdlist=[("tar -xzvf " + self.komponente + "round_buttons.tar.gz" + " -C /")])
288 elif answer == "MAGICBUTT":
289 self.session.open(Console, cmdlist=[("tar -xzvf " + self.komponente + "magic_buttons.tar.gz" + " -C /")])
291 def checkUserColors(self):
292 if (config.plugins.valiXDsetup.Style.value=='base'):
294 self["myTestLabel"].instance.setBackgroundColor(parseColor('#'+config.plugins.valiXDsetup.BG.value))
295 self["myTestLabel"].instance.setBackgroundColor(parseColor('#'+config.plugins.valiXDsetup.FG.value))
296 self["myTestLabel"].instance.setBackgroundColor(parseColor('#'+config.plugins.valiXDsetup.secondBG.value))
297 self["myTestLabel"].instance.setBackgroundColor(parseColor('#'+config.plugins.valiXDsetup.secondFG.value))
298 self["myTestLabel"].instance.setBackgroundColor(parseColor('#'+config.plugins.valiXDsetup.selBG.value))
299 self["myTestLabel"].instance.setBackgroundColor(parseColor('#'+config.plugins.valiXDsetup.selFG.value))
300 config.plugins.valiXDsetup.BG.save()
301 config.plugins.valiXDsetup.FG.save()
302 config.plugins.valiXDsetup.secondBG.save()
303 config.plugins.valiXDsetup.secondFG.save()
304 config.plugins.valiXDsetup.selBG.save()
305 config.plugins.valiXDsetup.selFG.save()
308 self.session.open(MessageBox, _("There are errors in the color-strings!\nThe PlugIn will use default colors."), MessageBox.TYPE_ERROR)
311 self.session.open(MessageBox, _("Colors setup are only for Base-Style possible."), MessageBox.TYPE_INFO)
314 if self.checkUserColors():
315 PreviewString='<screen backgroundColor="#'+config.plugins.valiXDsetup.BG.value+'" flags="wfNoBorder" position="0,433" size="1024,176" title="Preview">\n'
316 PreviewString=PreviewString+'<ePixmap alphatest="off" pixmap="Vali-XD/border/up-shadow.png" position="0,0" size="1024,8" zPosition="0"/>\n'
317 PreviewString=PreviewString+'<eLabel backgroundColor="#'+config.plugins.valiXDsetup.secondBG.value+'" font="Regular;22" foregroundColor="#'+config.plugins.valiXDsetup.secondFG.value
318 PreviewString=PreviewString+'" halign="center" position="0,8" size="152,168" text="Second foreground" valign="center" zPosition="1"/>\n<eLabel backgroundColor="#'+config.plugins.valiXDsetup.secondBG.value
319 PreviewString=PreviewString+'" font="Regular;22" foregroundColor="#'+config.plugins.valiXDsetup.secondFG.value+'" halign="center" position="872,8" size="152,168" text="Second foreground" valign="center" zPosition="1"/>\n'
320 PreviewString=PreviewString+'<eLabel font="Regular;22" foregroundColor="#'+'00f0f0f0'+'" halign="center" position="275,45" size="457,30" text="Main element" valign="center" transparent="1" zPosition="2"/>\n'
321 PreviewString=PreviewString+'<eLabel backgroundColor="#'+config.plugins.valiXDsetup.selBG.value+'" font="Regular;22" foregroundColor="#'+config.plugins.valiXDsetup.selFG.value
322 PreviewString=PreviewString+'" halign="center" position="275,80" size="457,30" text="Selected element" valign="center" zPosition="2"/>\n</screen>'
323 self.session.open(UserStylePreview, PreviewString)
331 #######################################################################
335 class UserStylePreview(Screen):
336 def __init__(self, session, prvScreen='<screen position="80,150" size="560,310" title="Template">\n</screen>'):
337 self.skin = prvScreen
338 Screen.__init__(self, session)
339 self["actions"] = ActionMap(["OkCancelActions"], {"ok": self.close, "cancel": self.close}, -1)