#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
#######################################################################
#
#    MyMetrix
#    Coded by iMaxxx (c) 2013
#    Mod MetrixStyle for DreamOS by arki
#
#  This plugin is licensed under the Creative Commons
#  Attribution-NonCommercial-ShareAlike 3.0 Unported License.
#  To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
#  or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
#
#  Alternatively, this plugin may be distributed and executed on hardware which
#  is licensed by Dream Multimedia GmbH.
#
#  This plugin is NOT free software. It is open source, you are allowed to
#  modify it (if you keep the license), but it may not be commercially
#  distributed other than under the conditions noted above.
#
#######################################################################

from Plugins.Plugin import PluginDescriptor
from Screens.Screen import Screen
from Screens.MessageBox import MessageBox
from Screens.ChoiceBox import ChoiceBox
from Screens.Console import Console
from Screens.Standby import TryQuitMainloop
from Components.ActionMap import NumberActionMap
from Components.AVSwitch import AVSwitch
from Components.config import config, configfile, ConfigYesNo, ConfigSubsection, getConfigListEntry, ConfigSelection, ConfigNumber, ConfigText, ConfigInteger
from Components.ConfigList import ConfigListScreen
from Components.Label import Label
from Components.Language import language
from os import environ, listdir, remove, rename, system, path
from skin import parseColor
from Components.Pixmap import Pixmap
from Components.Label import Label
import urllib
import gettext
from enigma import ePicLoad
from Tools.Directories import fileExists, resolveFilename, SCOPE_LANGUAGE, SCOPE_PLUGINS

#############################################################

lang = language.getLanguage()
environ["LANGUAGE"] = lang[:2]
gettext.bindtextdomain("enigma2", resolveFilename(SCOPE_LANGUAGE))
gettext.textdomain("enigma2")
gettext.bindtextdomain("MetrixStyle", "%s%s" % (resolveFilename(SCOPE_PLUGINS), "Extensions/MetrixStyle/locale/"))

def _(txt):
	t = gettext.dgettext("MetrixStyle", txt)
	if t == txt:
		t = gettext.gettext(txt)
	return t

def translateBlock(block):
	for x in TranslationHelper:
		if block.__contains__(x[0]):
			block = block.replace(x[0], x[1])
	return block

#######################################################################

def main(session, **kwargs):
	session.open(MetrixStyle,"/usr/lib/enigma2/python/Plugins/Extensions/MetrixStyle/images/metrixcolors.png")

def Plugins(**kwargs):
	return PluginDescriptor(name="MetrixStyle", description=_("Setup for Skin MetrixStyleHD"), where = PluginDescriptor.WHERE_PLUGINMENU, icon="plugin.png", fnc=main)

#######################################################################

class MetrixStyle(ConfigListScreen, Screen):
	skin = """
<screen name="MetrixStyle-Setup" position="40,40" size="1200,640" flags="wfNoBorder" backgroundColor="#40000000">
	<eLabel position="20,15" size="300,50" text="MetrixStyle" font="Regular; 40" valign="center" transparent="1" backgroundColor="#40000000" />
	<eLabel position="325,18" size="350,50" text="Setup" foregroundColor="#00ffffff" font="Regular; 30" valign="center" backgroundColor="#40000000" transparent="1" halign="left" />
	<widget name="config" position="20,100" scrollbarMode="showOnDemand" size="590,450" transparent="1" />	
	<eLabel font="Regular; 20" foregroundColor="#00ffffff" backgroundColor="#40000000" valign="center" position="35,600" size="250,30" text="Cancel" transparent="1" />
	<eLabel font="Regular; 20" foregroundColor="#00ffffff" backgroundColor="#40000000" valign="center" position="335,600" size="250,30" text="Save" transparent="1" />
	<eLabel font="Regular; 20" foregroundColor="#00ffffff" backgroundColor="#40000000" valign="center" position="635,600" size="250,30" text="Default" transparent="1" />
	<eLabel font="Regular; 20" foregroundColor="#00ffffff" backgroundColor="#40000000" valign="center" position="935,600" size="250,30" text="Info" transparent="1" />			
	<eLabel position="20,600" size="6,30" backgroundColor="#00ff0000" />
	<eLabel position="320,600" size="6,30" backgroundColor="#0000ff00" />	
	<eLabel position="620,600" size="6,30" backgroundColor="#00ffff00" />
	<eLabel position="920,600" size="6,30" backgroundColor="#000000ff" />	
	<widget name="helperimage" position="625,100" size="560,315" zPosition="1" />
	<eLabel font="Regular;30" halign="center" valign="center" position="625,450" size="560,40" text="Skin MetrixStyleHD" transparent="1" />		
	<eLabel font="Regular;26" halign="center" valign="center" position="625,500" size="560,40" text="modded for DreamOS" transparent="1" />	
</screen>
"""

	def __init__(self, session, args = None, picPath = None):
		self.version = "v1.1b"
		self.skin_lines = []
		Screen.__init__(self, session)
		self.session = session
		self.datei = "/usr/share/enigma2/MetrixStyleHD/skin.xml"
		self.dateiTMP = "/usr/share/enigma2/MetrixStyleHD/skin.xml.tmp"
		self.daten = "/usr/lib/enigma2/python/Plugins/Extensions/MetrixStyle/data/"		
		self.picPath = picPath
		self.Scale = AVSwitch().getFramebufferScale()
		self.PicLoad = ePicLoad()
		self["helperimage"] = Pixmap()
		self.ConfigDreamboxPluginDetection()
		list = []
		list.append(getConfigListEntry(_("Backgroundcolor"), config.plugins.MetrixStyle.SkinBackgroundColor))
		list.append(getConfigListEntry(_("... with corner radius"), config.plugins.MetrixStyle.SkinCornerRadius))		
		list.append(getConfigListEntry(_("Selection backgroundcolor"), config.plugins.MetrixStyle.SkinSelectedBackgroundColor))
		list.append(getConfigListEntry(_("... with line"), config.plugins.MetrixStyle.SkinSelectedLine))		
		list.append(getConfigListEntry(_("Selection textcolor"), config.plugins.MetrixStyle.SkinSelectedForegroundColor))				
		list.append(getConfigListEntry(_("font color"), config.plugins.MetrixStyle.SkinForegroundColor))
		list.append(getConfigListEntry(_("Helptext color"), config.plugins.MetrixStyle.SkinSelectedHelpTextColor))		
		list.append(getConfigListEntry(_("Date color"), config.plugins.MetrixStyle.SkinClockColor))
		list.append(getConfigListEntry(_("CAID color"), config.plugins.MetrixStyle.SkinCaidInfoColor))		
		list.append(getConfigListEntry(_("Health color"), config.plugins.MetrixStyle.SkinTunerInfoColor))	
		list.append(getConfigListEntry(_("Progressbar color"), config.plugins.MetrixStyle.SkinProgressbarColor))
		list.append(getConfigListEntry(_("Volume"), config.plugins.MetrixStyle.VolumeStyle))
		list.append(getConfigListEntry(_("Text subtitle presentation"), config.plugins.MetrixStyle.SubtitleStyle))		
		list.append(getConfigListEntry(_("*** Mainmenu ***"), ))			
		list.append(getConfigListEntry(_("Style"), config.plugins.MetrixStyle.MenuStyle))	
		list.append(getConfigListEntry(_("backgrouncolor symbol"), config.plugins.MetrixStyle.MenuIconBackColor))		
		list.append(getConfigListEntry(_("*** Plugins ***"), ))
		if self.has_ams:
			list.append(getConfigListEntry(_("AMS"), config.plugins.MetrixStyle.AMSStyle))		
		if self.has_emc:
			list.append(getConfigListEntry(_("EMC"), config.plugins.MetrixStyle.EMCStyle))
		if self.has_videodb:
			list.append(getConfigListEntry(_("Video DB"), config.plugins.MetrixStyle.VideoDBStyle))
		if self.has_valisepg:
			list.append(getConfigListEntry(_("Vali's EPG"), config.plugins.MetrixStyle.ValisEPGStyle))			
		list.append(getConfigListEntry(_("*** Display ***"), ))
		if self.boxtype == "dm7080" or self.boxtype == "dm820":
			list.append(getConfigListEntry(_("OLED-Display Infobar"), config.plugins.MetrixStyle.OledDisplayInfobarStyle))
		list.append(getConfigListEntry(_("Display Idle Mode"), config.plugins.MetrixStyle.DisplayIdleStyle))		
		if self.has_color:
			list.append(getConfigListEntry(_("LCD-Display")+" "+_("backgroundcolor"), config.plugins.MetrixStyle.SkinLCDbackgroundColor))				
			list.append(getConfigListEntry(_("LCD-Display foregroundcolor"), config.plugins.MetrixStyle.SkinLCDforegroundColor))
			list.append(getConfigListEntry(_("LCD-Display clock color"), config.plugins.MetrixStyle.SkinLCDclockColor))
			list.append(getConfigListEntry(_("LCD-Display")+" "+_("Channel Selection"), config.plugins.MetrixStyle.DisplayChanelselectionStyle))                		
			list.append(getConfigListEntry(_("LCD-Display Infobar"), config.plugins.MetrixStyle.DisplayInfobarStyle))		
		list.append(getConfigListEntry(_("*** Channel Selection ***"), ))		
		list.append(getConfigListEntry(_("Channellist Style"), config.plugins.MetrixStyle.ChannelselectionStyle))
		list.append(getConfigListEntry(_("Infopanel"), config.plugins.MetrixStyle.ChannelselectionInfo))
		list.append(getConfigListEntry(_("Picon on top"), config.plugins.MetrixStyle.ChannelselectionPicon))		
		list.append(getConfigListEntry(_("Description color"), config.plugins.MetrixStyle.Channeldescription))		
		list.append(getConfigListEntry(_("*** InfoBar ***"), ))		
		list.append(getConfigListEntry(_("Style"), config.plugins.MetrixStyle.InfobarStyle))
		list.append(getConfigListEntry(_("picon path"), config.plugins.MetrixStyle.InfobarPiconPath))		
		list.append(getConfigListEntry(_("Servicename and number"), config.plugins.MetrixStyle.InfobarShowChannelname))				
		list.append(getConfigListEntry(_("... color"), config.plugins.MetrixStyle.InfobarChannelnamecolor))
		list.append(getConfigListEntry(_("separator line"), config.plugins.MetrixStyle.InfobarSeparator))		
		list.append(getConfigListEntry(_("top left"), config.plugins.MetrixStyle.InfobarTopLeft))
		list.append(getConfigListEntry(_("top center"), config.plugins.MetrixStyle.InfobarTopCenter))		
		list.append(getConfigListEntry(_("top right"), config.plugins.MetrixStyle.InfobarTopRight))		
		list.append(getConfigListEntry(_("above the infobar"), config.plugins.MetrixStyle.InfobarHead))				
		list.append(getConfigListEntry(_("bottom left"), config.plugins.MetrixStyle.InfobarBottomLeft))
		list.append(getConfigListEntry(_("bottom center"), config.plugins.MetrixStyle.InfobarBottomCenter))		
		list.append(getConfigListEntry(_("bottom right"), config.plugins.MetrixStyle.InfobarBottomRight))
		list.append(getConfigListEntry(_("Show Record Icon"), config.plugins.MetrixStyle.InfobarRecordState))		
		if self.has_secondinfobarme or self.has_sib:
			list.append(getConfigListEntry(_("*** SecondInfoBar ***"), ))		
			list.append(getConfigListEntry(_("top left"), config.plugins.MetrixStyle.SecondInfobarTopLeft))
			list.append(getConfigListEntry(_("top center"), config.plugins.MetrixStyle.SecondInfobarTopCenter))		
			list.append(getConfigListEntry(_("top right"), config.plugins.MetrixStyle.SecondInfobarTopRight))						
			list.append(getConfigListEntry(_("Info Panel"), config.plugins.MetrixStyle.SecondInfobarEPGWidget))		
		
		ConfigListScreen.__init__(self, list)
		self["actions"] = NumberActionMap(["OkCancelActions","DirectionActions", "InputActions", "ColorActions", "MenuActions"], {"left": self.keyLeft, "down": self.keyDown, "up": self.keyUp, "right": self.keyRight, "red": self.exit, "0": self.resetAll, "blue": self.showInfo, "green": self.save, "cancel": self.exit, "yellow": self.resetConf}, -2)
		self.onLayoutFinish.append(self.UpdateComponents)

	def ConfigDreamboxPluginDetection(self):

		# Boxtype
		self.boxtype="dm7080"                  
		if path.exists("/proc/stb/info/model"):
		        f=open("/proc/stb/info/model")   
		        self.boxtype=f.read()             
			f.close()                 
			self.boxtype=self.boxtype.replace("\n","").replace("\l","")
		self.has_tuners=0
		for name in listdir("/sys/class/dvb"):
		        if name.startswith("dvb0.frontend"):
        		        self.has_tuners+=1 
		print "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", self.has_tuners

		if self.boxtype.startswith("dm5"):
			self.has_lcd=False
		else:
			self.haslcd=True
			
		if self.boxtype.startswith("dm9"):
			self.has_color=True
			self.has_cputemp=True
		else:
			self.has_color=False
			self.has_cputemp=False

		# Plugins
		if path.exists("/usr/lib/enigma2/python/Plugins/Extensions/ValisEPG"):
			self.has_valisepg=True
		else:
			self.has_valisepg=False
			
		if path.exists("/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPGCenter"):
			self.has_merlinepgcenter=True
		else:
			self.has_merlinepgcenter=False
		if path.exists("/usr/lib/enigma2/python/Plugins/Extensions/AdvancedMovieSelection"):
			self.has_ams=True
		else:
			self.has_ams=False
			
		if path.exists("/usr/lib/enigma2/python/Plugins/Extensions/EnhancedMovieCenter"):
			self.has_emc=True
		else:
			self.has_emc=False
			
		if path.exists("/usr/lib/enigma2/python/Plugins/Extensions/VideoDB"):
			self.has_videodb=True
		else:
			self.has_videodb=False
			
		if path.exists("/usr/lib/enigma2/python/Plugins/Extensions/secondinfobarme"):
			self.has_secondinfobarme=True
		else:
			self.has_secondinfobarme=False
			
		if path.exists("/usr/lib/enigma2/python/Plugins/Extensions/2IB"):
			self.has_sib=True
		else:
			self.has_sib=False			

		if path.exists("/usr/lib/enigma2/python/Plugins/Extensions/WeatherPlugin"):
			self.has_msnweather=True
		else:
			self.has_msnweather=False			

		# Config
		config.plugins.MetrixStyle = ConfigSubsection()

		#General
		config.plugins.MetrixStyle.SkinBackgroundColor = ConfigSelection(default="#30000000", choices = [
				("#00000000", _("black")),
				("#07000000", _("Metrix 7")),					
				("#15000000", _("Metrix 15")),
				("#30000000", _("Metrix 30")+" "+_("(")+_("default")+_(")")),				
				("#40000000", _("Metrix 40")),
				("#00111010", _("Anthrazit")),
				("#07111010", _("Anthrazit 7")),				
				("#15111010", _("Anthrazit 15")),																
				("#30111010", _("Anthrazit 30")),
				("#40111010", _("Anthrazit 40")),				
				("#00353535", _("dark")),
				("#07353535", _("dark 7")),				
				("#15353535", _("dark 15")),
				("#30353535", _("dark 30")),
				("#40353535", _("dark 40")),				
				("#05000080", _("blue")),
				("#000050EF", _("cobalt")),
				("#006A00FF", _("indigo")),
				("#006c0aab", _("violett")),				
				("#15003c51", _("turquoise")),				
				("#05770000", _("red")),				
				("#05002900", _("pine green")),
				("#00cea66b", _("beige"))				
				])
		config.plugins.MetrixStyle.SkinCornerRadius = ConfigSelection(default="0012", choices = [
				("0012", _("yes")+" "+_("(")+_("default")+_(")")),			
				("0000", _("no"))
				])
		config.plugins.MetrixStyle.SkinSelectedBackgroundColor = ConfigSelection(default="#000050EE", choices = [
				("#00F0A30A", _("amber")),
				("#00825A2C", _("brown")),
				("#000050EE", _("cobalt")+" "+_("(")+_("default")+_(")")),
				("#001677d2", _("blueberry")),				
				("#00911d10", _("crimson")),
				("#001BA1E2", _("cyan")),
				("#00a61d4d", _("magenta")),
				("#00A4C400", _("lime green")),
				("#006A00FF", _("indigo")),
				("#0070ad11", _("green")),
				("#00008A00", _("emerald")),
				("#0076608A", _("mauve")),
				("#006D8764", _("oliv")),
				("#00c3461b", _("orange")),
				("#00F472D0", _("pink")),
				("#00E51400", _("blood red")),
				("#007A3B3F", _("siena")),
				("#00647687", _("steel")),
				("#00149baf", _("teal")),
				("#006c0aab", _("violett")),
				("#00bf9217", _("gold")),
				("#00ffcc00", _("yellow")),
				("#00cea66b", _("beige")),				
				("#00000000", _("black")),
				("#07000000", _("Metrix 7")),					
				("#15000000", _("Metrix 15")),
				("#30000000", _("Metrix 30")),				
				("#40000001", _("Metrix 40")),
				("#00111010", _("Anthrazit")),
				("#07111010", _("Anthrazit 7")),				
				("#15111010", _("Anthrazit 15")),																
				("#30111010", _("Anthrazit 30")),
				("#40111010", _("Anthrazit 40")),
				("#00353535", _("dark")),
				("#07353535", _("dark 7")),				
				("#15353535", _("dark 15")),
				("#30353535", _("dark 30")),
				("#40353535", _("dark 40")),				
				("#05000080", _("blue")),
				("#15003c51", _("turquoise")),				
				("#05770000", _("red")),
				("#05002900", _("pine green"))				
				])

		config.plugins.MetrixStyle.SkinSelectedLine = ConfigSelection(default="line-no", choices = [
				("p_bar", _("white")),
				("p_bar_amber", _("amber")),				
				("p_bar_brown", _("brown")),				
				("p_bar_cobalt", _("cobalt")),
				("p_bar_blue", _("blueberry")),
				("p_bar_crimson", _("crimson")),				
				("p_bar_cyan", _("cyan")),
				("p_bar_magenta", _("magenta")),
				("p_bar_lime", _("lime green")),
				("p_bar_indigo", _("indigo")),
				("p_bar_green", _("green")),				
				("p_bar_emerald", _("emerald")),
				("p_bar_mauve", _("mauve")),
				("p_bar_olive", _("oliv")),
				("p_bar_orange", _("orange")),
				("p_bar_pink", _("pink")),				
				("p_bar_red", _("blood red")),
				("p_bar_sienna", _("siena")),
				("p_bar_steel", _("steel")),
				("p_bar_teal", _("teal")),
				("p_bar_violet", _("violett")),				
				("p_bar_gold", _("gold")),
				("p_bar_yellow", _("yellow")),
				("p_bar_beige",_("beige")),				
				("line-no", _("no")+" "+_("(")+_("default")+_(")"))
				])				

		config.plugins.MetrixStyle.SkinSelectedForegroundColor = ConfigSelection(default="#00fffffd", choices = [
				("#00fffffd", _("white")+" "+_("(")+_("default")+_(")")),
				("#00F0A30A", _("amber")),
				("#00825A2C", _("brown")),
				("#000050EF", _("cobalt")),
				("#001677d2", _("blueberry")),				
				("#00911d10", _("crimson")),
				("#001BA1E2", _("cyan")),
				("#00a61d4d", _("magenta")),
				("#00A4C400", _("lime green")),
				("#006A00FF", _("indigo")),
				("#0070ad11", _("green")),
				("#00008A00", _("emerald")),
				("#0076608A", _("mauve")),
				("#006D8764", _("oliv")),
				("#00c3461b", _("orange")),
				("#00F472D0", _("pink")),
				("#00E51400", _("blood red")),
				("#007A3B3F", _("siena")),
				("#00647687", _("steel")),
				("#00149baf", _("teal")),
				("#006c0aab", _("violett")),
				("#00bf9217", _("gold")),
				("#00ffcc00", _("yellow")),
				("#00cea66b", _("beige")),				
				("#00000000", _("black"))
				])													

		config.plugins.MetrixStyle.SkinForegroundColor = ConfigSelection(default="#00fffffe", choices = [
				("#00fffffe", _("white")+" "+_("(")+_("default")+_(")")),				
				("#00bf9217", _("gold")),				
				("#00cea66b", _("beige")),
				("#00F0A30A", _("amber")),
				("#00825A2C", _("brown"))				
				])

		config.plugins.MetrixStyle.SkinSelectedHelpTextColor = ConfigSelection(default="#00fffffc", choices = [
				("#00fffffc", _("white")+" "+_("(")+_("default")+_(")")),
				("#00F0A30A", _("amber")),
				("#00825A2C", _("brown")),
				("#000050EF", _("cobalt")),
				("#001677d2", _("blueberry")),				
				("#00911d10", _("crimson")),
				("#001BA1E2", _("cyan")),
				("#00a61d4d", _("magenta")),
				("#00A4C400", _("lime green")),
				("#006A00FF", _("indigo")),
				("#0070ad11", _("green")),
				("#00008A00", _("emerald")),
				("#0076608A", _("mauve")),
				("#006D8764", _("oliv")),
				("#00c3461b", _("orange")),
				("#00F472D0", _("pink")),
				("#00E51400", _("blood red")),
				("#007A3B3F", _("siena")),
				("#00647687", _("steel")),
				("#00149baf", _("teal")),
				("#006c0aab", _("violett")),
				("#00bf9217", _("gold")),
				("#00ffcc00", _("yellow")),
				("#00cea66b", _("beige"))				
				])				

		config.plugins.MetrixStyle.SkinClockColor = ConfigSelection(default="#00dddddd", choices = [
				("#00dddddd", _("white")+" "+_("(")+_("default")+_(")")),
				("#00F0A30A", _("amber")),
				("#00825A2C", _("brown")),
				("#000050EF", _("cobalt")),
				("#001677d2", _("blueberry")),				
				("#00911d10", _("crimson")),
				("#001BA1E2", _("cyan")),
				("#00a61d4d", _("magenta")),
				("#00A4C400", _("lime green")),
				("#006A00FF", _("indigo")),
				("#0070ad11", _("green")),
				("#00008A00", _("emerald")),
				("#0076608A", _("mauve")),
				("#006D8764", _("oliv")),
				("#00c3461b", _("orange")),
				("#00F472D0", _("pink")),
				("#00E51400", _("blood red")),
				("#007A3B3F", _("siena")),
				("#00647687", _("steel")),
				("#00149baf", _("teal")),
				("#006c0aab", _("violett")),
				("#00bf9217", _("gold")),
				("#00ffcc00", _("yellow")),
				("#00cea66b", _("beige"))
				])

		config.plugins.MetrixStyle.SkinCaidInfoColor = ConfigSelection(default="#00008A01", choices = [
				("#00F0A30A", _("amber")),
				("#00825A2C", _("brown")),
				("#000050EF", _("cobalt")),
				("#001677d2", _("blueberry")),				
				("#00911d10", _("crimson")),
				("#001BA1E2", _("cyan")),
				("#00a61d4d", _("magenta")),
				("#00A4C400", _("lime green")),
				("#006A00FF", _("indigo")),
				("#0070ad11", _("green")),
				("#00008A01", _("emerald")+" "+_("(")+_("default")+_(")")),
				("#0076608A", _("mauve")),
				("#006D8764", _("oliv")),
				("#00c3461b", _("orange")),
				("#00F472D0", _("pink")),
				("#00E51400", _("blood red")),
				("#007A3B3F", _("siena")),
				("#00647687", _("steel")),
				("#00149baf", _("teal")),
				("#006c0aab", _("violett")),
				("#00bf9217", _("gold")),
				("#00ffcc00", _("yellow")),
				("#00cea66b", _("beige"))				
				])				

		config.plugins.MetrixStyle.SkinTunerInfoColor = ConfigSelection(default="#0070ad10", choices = [
				("#00ddddde", _("white")),
				("#00F0A30A", _("amber")),
				("#00825A2C", _("brown")),
				("#000050EF", _("cobalt")),
				("#001677d2", _("blueberry")),				
				("#00911d10", _("crimson")),
				("#001BA1E2", _("cyan")),
				("#00a61d4d", _("magenta")),
				("#00A4C400", _("lime green")),
				("#006A00FF", _("indigo")),
				("#0070ad10", _("green")+" "+_("(")+_("default")+_(")")),
				("#00008A00", _("emerald")),
				("#0076608A", _("mauve")),
				("#006D8764", _("oliv")),
				("#00c3461b", _("orange")),
				("#00F472D0", _("pink")),
				("#00E51400", _("blood red")),
				("#007A3B3F", _("siena")),
				("#00647687", _("steel")),
				("#00149baf", _("teal")),
				("#006c0aab", _("violett")),
				("#00bf9217", _("gold")),
				("#00ffcc00", _("yellow")),
				("#00cea66b", _("beige"))
				])				

		config.plugins.MetrixStyle.SkinProgressbarColor = ConfigSelection(default="p_bar", choices = [
				("p_bar", _("white")+" "+_("(")+_("default")+_(")")),
				("p_bar_amber", _("amber")),
				("p_bar_brown", _("brown")),
				("p_bar_cobalt", _("cobalt")),
				("p_bar_blue", _("blueberry")),
				("p_bar_crimson", _("crimson")),
				("p_bar_cyan", _("cyan")),
				("p_bar_magenta", _("magenta")),
				("p_bar_lime", _("lime green")),
				("p_bar_indigo", _("indigo")),
				("p_bar_green", _("green")),
				("p_bar_emerald", _("emerald")),
				("p_bar_mauve", _("mauve")),
				("p_bar_olive", _("oliv")),
				("p_bar_orange", _("orange")),
				("p_bar_pink", _("pink")),
				("p_bar_red", _("blood red")),
				("p_bar_sienna", _("siena")),
				("p_bar_steel", _("steel")),
				("p_bar_teal", _("teal")),
				("p_bar_violet", _("violett")),
				("p_bar_gold", _("gold")),
				("p_bar_yellow", _("yellow")),				
				("p_bar_beige",_("beige"))
				])								
	
		config.plugins.MetrixStyle.VolumeStyle = ConfigSelection(default="volume-classic-center", choices = [
				("volume-classic", _("top left")),
				("volume-classic-center", _("top center")+" "+_("(")+_("default")+_(")")),
				("volume-classic-right", _("top right")),				
				("volume-new", _("big"))
				])				

		config.plugins.MetrixStyle.SubtitleStyle = ConfigSelection(default="subtitle-default", choices = [
				("subtitle-small", _("small")),
				("subtitle-default", _("default")),
				("subtitle-big", _("big")),				
				("subtitle-very_large", _("very large"))
				])													

		config.plugins.MetrixStyle.MenuStyle = ConfigSelection(default="menu-center", choices = [
				("menu-center", _("Metrix centered")+" "+_("(")+_("default")+_(")")),
				("menu-left", _("Metrix left justified")),				
				("menu-center-untitled", _("MetrixStyle centered")),				
				("menu-left-untitled", _("MetrixStyle left justified")),				
				("menu-big", _("big centered")),
				("menu-big-left", _("big left justified"))				
				])

		config.plugins.MetrixStyle.MenuIconBackColor = ConfigSelection(default="menu-icon-backcolor", choices = [
				("menu-icon-backcolor", _("Selection backgroundcolor")),
				("menu-icon", _("Backgroundcolor"))			
				])									

		config.plugins.MetrixStyle.AMSStyle = ConfigSelection(default="no-widget", choices = [
				("no-widget", _("no")),
				("ams-metrix", _("yes"))
				])								

		config.plugins.MetrixStyle.EMCStyle = ConfigSelection(default="emc-metrix", choices = [
				("emc-metrix", _("Metrix")),
				("emc-metrix-pic", _("Metrix PIG"))				
				])	

		config.plugins.MetrixStyle.VideoDBStyle = ConfigSelection(default="no-widget", choices = [
				("no-widget", _("no")),
				("videodb", _("yes"))				
				])

		config.plugins.MetrixStyle.ValisEPGStyle = ConfigSelection(default="vali-epg", choices = [
				("vali-epg", _("Simple")),
				("vali-epg-extended", _("Extended")),
				("vali-epg-extended-pic", _("Extended")+" "+_("+")+" "+_("PIC")),				
				])				

		#Display
		config.plugins.MetrixStyle.OledDisplayInfobarStyle = ConfigSelection(default="display-oled-default", choices = [
				("display-oled-default", _("default")),
				("display-oled-picon", _("Picon .../picon_oled")),
				("display-oled-clock", _("Clock")),
				("display-oled-remaining", _("Clock/Remaining"))				
				])

		config.plugins.MetrixStyle.DisplayIdleStyle = ConfigSelection(default="display-idle-clock-date", choices = [				
				("display-idle-clock", _("Clock")),
				("display-idle-clock-date", _("Clock/Date")+" "+_("(")+_("default")+_(")"))				
				])				

		config.plugins.MetrixStyle.SkinLCDbackgroundColor = ConfigSelection(default="#000001", choices = [
				("#000001", _("black")+" "+_("(")+_("default")+_(")")),				
				("#00007f", _("blue")),
				("#7f007f", _("violett")),				
				("#007f00", _("green")),			
				("#ff0000", _("red")),
				("#7f0000", _("crimson"))				
				])				

		config.plugins.MetrixStyle.SkinLCDforegroundColor = ConfigSelection(default="#ffffef", choices = [
				("#ffffef", _("white")+" "+_("(")+_("default")+_(")")),
				("#00E51400", _("red")),				
				("#00ffcc00", _("yellow")),
				("#00F0A30A", _("amber")),				
				("#00cea66b", _("beige")),				
				("#0070ad11", _("green")),
				("#00008A00", _("emerald")),
				("#00F472D0", _("pink")),
				("#00a61d4d", _("magenta")),
				("#00647687", _("steel")),
				("#000050EF", _("cobalt")),			
				("#001BA1E2", _("cyan"))				
				])

		config.plugins.MetrixStyle.SkinLCDclockColor = ConfigSelection(default="#ffffdf", choices = [
				("#ffffdf", _("white")+" "+_("(")+_("default")+_(")")),
				("#00E51400", _("red")),				
				("#00ffcc00", _("yellow")),
				("#00F0A30A", _("amber")),				
				("#00cea66b", _("beige")),				
				("#0070ad11", _("green")),
				("#00008A00", _("emerald")),
				("#00F472D0", _("pink")),
				("#00a61d4d", _("magenta")),
				("#00647687", _("steel")),
				("#000050EF", _("cobalt")),			
				("#001BA1E2", _("cyan"))				
				])				

		config.plugins.MetrixStyle.DisplayChanelselectionStyle = ConfigSelection(default="display-channelselection-default", choices = [
				("display-channelselection-default", _("default")),
				("display-channelselection-service-event", _("Service")+" "+_("+")+" "+_("Event")),
				("display-channelselection-picon", _("Picon")),				
				("display-channelselection-picon_2", _("Picon + Event")),
				("display-channelselection-picon_4", _("Picon + Progressbar")),					
				("display-channelselection-picon_3", _("Picon .../picon_400x170")),				
				("display-channelselection-clock", _("Clock")),
				("display-channelselection-clock-date", _("Clock/Date")),				
				("display-channelselection-remaining", _("Clock/Remaining"))			
				])				
	
		config.plugins.MetrixStyle.DisplayInfobarStyle = ConfigSelection(default="display-default", choices = [
				("display-default", _("default")),
				("display-service-event", _("Service")+" "+_("+")+" "+_("Event")),				
				("display-picon", _("Picon")),				
				("display-picon_2", _("Picon + Event")),
				("display-picon_4", _("Picon + Progressbar")),				
				("display-picon_3", _("Picon .../picon_400x170")),
				("display-clock", _("Clock")),
				("display-clock-date", _("Clock/Date")),				
				("display-remaining", _("Clock/Remaining"))				
				])			

		#Channelselection
		config.plugins.MetrixStyle.ChannelselectionStyle = ConfigSelection(default="channelselection-classic", choices = [
				("channelselection-senior", _("10 lines")),								
				("channelselection-me12", _("12 lines")),
				("channelselection-classic", _("15 lines")+" "+_("(")+_("default")+_(")")),				
				("channelselection-me16", _("16 lines")),
				("channelselection-20z", _("20 lines")),				
				("channelselection-simple", _("12 lines, complete width"))				
				])

		config.plugins.MetrixStyle.ChannelselectionInfo = ConfigSelection(default="channelselection-style1a", choices = [
				("channelselection-style1a", _("Style 1a")+" "+_("(")+_("default")+_(")")),
				("channelselection-style1b", _("Style 1b")),
				("channelselection-style1c", _("Style 1c")),				
				("channelselection-style2a", _("Style 2a")),
				("channelselection-style2b", _("Style 2b")),				
				("channelselection-me3ev", _("Style 2c")),				
				("channelselection-me1ev", _("Style 3a")),
				("channelselection-style6", _("Style 3b")),
				("channelselection-style8", _("Style 3c")),				
				("channelselection-pic-left", _("Style 4a")),
				("channelselection-pic-right", _("Style 4b")),				
				("channelselection-style5", _("Style 5a")),
				("channelselection-style5b", _("Style 5b")),
				("channelselection-style5c", _("Style 5c")),
				("channelselection-style9", _("Style 6a")),
				("channelselection-style10", _("Style 6b")),				
				("channelselection-style7", _("Style 7a")),
				("channelselection-style7b", _("Style 7b")),
				("channelselection-style7c", _("Style 7c")),				
				("channelselection-style11", _("Style 11a")),
				("channelselection-style11b", _("Style 11b")),
				("channelselection-style11c", _("Style 11c")),
				("channelselection-style11d", _("Style 11d")),				
				("no-widget", _("blank"))				
				])

		config.plugins.MetrixStyle.ChannelselectionPicon = ConfigSelection(default="channelselection-picon-no", choices = [
				("channelselection-picon", _("yes")),																
				("channelselection-picon-no", _("no")+" "+_("(")+_("default")+_(")"))				
				])				

		config.plugins.MetrixStyle.Channeldescription = ConfigSelection(default="#00999998", choices = [
				("#00999998", _("grey")+" "+_("(")+_("default")+_(")")),
				("#00ddddde", _("white")),
				("#00F0A30A", _("amber")),
				("#00825A2C", _("brown")),
				("#000050EF", _("cobalt")),
				("#001677d2", _("blueberry")),				
				("#00911d10", _("crimson")),
				("#001BA1E2", _("cyan")),
				("#00a61d4d", _("magenta")),
				("#00A4C400", _("lime green")),
				("#006A00FF", _("indigo")),
				("#0070ad11", _("green")),
				("#00008A00", _("emerald")),
				("#0076608A", _("mauve")),
				("#006D8764", _("oliv")),
				("#00c3461b", _("orange")),
				("#00F472D0", _("pink")),
				("#00E51400", _("blood red")),
				("#007A3B3F", _("siena")),
				("#00647687", _("steel")),
				("#00149baf", _("teal")),
				("#006c0aab", _("violett")),
				("#00bf9217", _("gold")),
				("#00ffcc00", _("yellow")),
				("#00cea66b", _("beige"))				
				])					

		#InfoBar
		config.plugins.MetrixStyle.InfobarStyle = ConfigSelection(default="infobar-style-classic", choices = [
				("infobar-style-classic", _("Metrix")+" "+_("(")+_("default")+_(")")),
				("infobar-style-metrix1", _("MetrixStyle I")),				
				("infobar-style-metrix2", _("MetrixStyle I (Ticker) ")),
				("infobar-style-metrix3", _("MetrixStyle II")),
				("infobar-style-metrix4", _("MetrixStyle II (Ticker)")),				
				("infobar-style-hc", _("HC")),				
				("infobar-style-hct", _("HC (Ticker) "))							
				])

		config.plugins.MetrixStyle.InfobarPiconPath = ConfigSelection(default="infobar-picon", choices = [			
				("infobar-picon", _(" .../picon")+" "+_("(")+_("default")+_(")")),
				("infobar-picon-220x132", _(".../picon_220x132")),
				("infobar-picon-500x300", _(".../picon_500x300")),				
				("infobar-picon-channelnumber", _("Show service numbers")),
				("no-widget", _("blank"))				
				])

		config.plugins.MetrixStyle.InfobarShowChannelname = ConfigSelection(default="infobar-channelname-number", choices = [
				("no-widget", _("no")),				
				("infobar-channelname-number", _("center")+" "+_("(")+_("default")+_(")")),				
				("infobar-channelname", _("Channelename only, center")),				
				("infobar-channelname-number-left", _("left justified")),
				("infobar-channelname-number-left-white", _("Channelename only, left justified"))				
				])				

		config.plugins.MetrixStyle.InfobarChannelnamecolor = ConfigSelection(default="#00999996", choices = [
				("#00999996", _("grey")+" "+_("(")+_("default")+_(")")),
				("#00ddddde", _("white")),
				("#00F0A30A", _("amber")),
				("#00825A2C", _("brown")),
				("#000050EF", _("cobalt")),
				("#001677d2", _("blueberry")),				
				("#00911d10", _("crimson")),
				("#001BA1E2", _("cyan")),
				("#00a61d4d", _("magenta")),
				("#00A4C400", _("lime green")),
				("#006A00FF", _("indigo")),
				("#0070ad11", _("green")),
				("#00008A00", _("emerald")),
				("#0076608A", _("mauve")),
				("#006D8764", _("oliv")),
				("#00c3461b", _("orange")),
				("#00F472D0", _("pink")),
				("#00E51400", _("blood red")),
				("#007A3B3F", _("siena")),
				("#00647687", _("steel")),
				("#00149baf", _("teal")),
				("#006c0aab", _("violett")),
				("#00bf9217", _("gold")),
				("#00ffcc00", _("yellow")),
				("#00cea66b", _("beige"))				
				])				

		config.plugins.MetrixStyle.InfobarSeparator = ConfigSelection(default="infobar-separatorline", choices = [
				("infobar-separatorline", _("yes")+" "+_("(")+_("default")+_(")")),																
				("infobar-separatorline-no", _("no"))				
				])				

		infobartopleftopt=[]
		infobartopleftopt.append(( "no-widget", _("off")+" "+_("(")+_("default")+_(")") ))
		infobartopleftopt.append(( "infobar-top-left-clockdate", _("Clock")+_("/")+_("Date") ))
		infobartopleftopt.append(( "infobar-top-left-clockdateextended", _("Clock")+_("/")+_("Date")+" "+_("Extended") ))				
		if self.has_msnweather:
			infobartopleftopt.append(( "infobar-top-left-msnweather", _("Weather") ))				
		config.plugins.MetrixStyle.InfobarTopLeft = ConfigSelection(default="no-widget", choices = infobartopleftopt)

		infobartopcenteropt=[]
		infobartopcenteropt.append(( "no-widget", _("off")+" "+_("(")+_("default")+_(")") ))
		infobartopcenteropt.append(( "infobar-top-center-cryptinfo", _("Show CAID/ECM Info") ))
		infobartopcenteropt.append(( "infobar-top-center-serviceinfo", _("Serviceinfo") ))
		infobartopcenteropt.append(( "infobar-top-center-satinfo", _("Serviceinfo") ))
		if self.has_tuners > 5:
			infobartopcenteropt.append(( "infobar-top-center-tunerinfo", _("Tunerinfo(FBC)") ))				
		else:
			infobartopcenteropt.append(( "infobar-top-center-tunerinfo", _("Tunerinfo") ))				
		infobartopcenteropt.append(( "infobar-top-center-syteminfo", _("Show System Info") ))
		if self.has_msnweather:
			infobartopcenteropt.append(( "infobar-top-center-weather-clockdate", _("Weather/Clock/Date full size") ))	
		else:
			infobartopcenteropt.append(( "infobar-top-center-weather-clockdate", _("Clock/Date full size") ))	
		config.plugins.MetrixStyle.InfobarTopCenter = ConfigSelection(default="no-widget", choices = infobartopcenteropt)

		infobartoprightopt=[]
		infobartoprightopt.append(( "no-widget", _("off")+" "+_("(")+_("default")+_(")") ))
		infobartoprightopt.append(( "infobar-top-right-clockdate", _("Clock")+_("/")+_("Date") ))
		infobartoprightopt.append(( "infobar-top-right-clockdateextended", _("Clock")+_("/")+_("Date")+" "+_("Extended") ))				
		if self.has_msnweather:
			infobartoprightopt.append(( "infobar-top-right-msnweather", _("Weather") ))				
		config.plugins.MetrixStyle.InfobarTopRight = ConfigSelection(default="infobar-top-right-clockdate", choices = infobartoprightopt)

		config.plugins.MetrixStyle.InfobarHead = ConfigSelection(default="no-widget", choices = [
				("no-widget", _("off")+" "+_("(")+_("default")+_(")")),
				("infobar-head-cryptinfo", _("Show CAID/ECM Info")),
				("infobar-head-serviceinfo", _("Serviceinfo")),
				("infobar-head-serviceinfo-pid", _("PIDs/Sat/Transponder")),				
				("infobar-head-colorbuttonts", _("Show Colorbuttonts"))				
				])								

		infobarbottomleftopt=[]
		infobarbottomleftopt.append(( "no-widget", _("off") ))
		infobarbottomleftopt.append(( "infobar-bottom-left-caidsoftcam", _("Show CAID/CI+/SNR dB") ))				
		infobarbottomleftopt.append(( "infobar-bottom-left-resolution-provider", _("Show Resulotion/Provider") ))				
		infobarbottomleftopt.append(( "infobar-bottom-left-resolutionhealthpg", _("Show Resulotion/Health progress") ))				
		infobarbottomleftopt.append(( "infobar-bottom-left-resolutionhealth", _("Show Resulotion/Health")+" "+_("(")+_("default")+_(")") ))				
		infobarbottomleftopt.append(( "infobar-bottom-left-resolution-ciplus-health", _("Show Resulotion/CiPlus/SNR dB") ))				
		infobarbottomleftopt.append(( "infobar-bottom-left-resolution-temp-health", _("Show Resulotion/Fan/SNR dB") ))
		infobarbottomleftopt.append(( "infobar-bottom-left-resolution-cputemp-health", _("Show Resulotion/CPU Temp/SNR dB") ))				
		infobarbottomleftopt.append(( "infobar-bottom-left-tuner-signal", _("Show Tunerinfo/SNR dB") ))
		if self.has_tuners > 5:
			infobarbottomleftopt.append(( "infobar-tunerinfo-6", _("Show Tunerinfo(FBC)/SNR dB")))				
		else:
			infobarbottomleftopt.append(( "infobar-tunerinfo-6", _("Show Tunerinfo/SNR dB")))				
		config.plugins.MetrixStyle.InfobarBottomLeft = ConfigSelection(default="infobar-bottom-left-resolutionhealth", choices = infobarbottomleftopt)

		infobarbottomcenteropt=[]
		if self.has_tuners > 1:
			infobarbottomcenteropt.append(( "infobar-tunerinfo-ab", _("2 Tuner")+" "+_("(")+_("default")+_(")") ))
		if self.has_tuners > 2:
			infobarbottomcenteropt.append(( "infobar-tunerinfo-abc", _("3 Tuner") ))								
		if self.has_tuners > 3:
			infobarbottomcenteropt.append(( "infobar-tunerinfo-abcd", _("4 Tuner") ))
		if self.has_tuners > 4:
			infobarbottomcenteropt.append(( "infobar-tunerinfo-abd", _("5 Tuner") ))	
		if self.has_tuners > 5:
			infobarbottomcenteropt.append(( "infobar-tunerinfo-8", _("8 Tuner(FBC)") ))				
		infobarbottomcenteropt.append(( "infobar-bottom-center-snr", _("Signal %") ))
		infobarbottomcenteropt.append(( "infobar-bottom-center-resolution", _("Resolution") ))
		if self.has_cputemp:
			infobarbottomcenteropt.append(( "infobar-bottom-center-cputemp", _("CPU Temperatur") ))
		infobarbottomcenteropt.append(( "no-widget", _("off") ))
		if self.has_tuners < 3:
			infobarbottomcenterdef="infobar-tunerinfo-ab"
		elif self.has_tuners == 3:
			infobarbottomcenterdef="infobar-tunerinfo-abc"
		elif self.has_tuners == 4:
			infobarbottomcenterdef="infobar-tunerinfo-abcd"
		elif self.has_tuners == 5:
			infobarbottomcenterdef="infobar-tunerinfo-abd"
		else:
			infobarbottomcenterdef="infobar-tunerinfo-8"
		config.plugins.MetrixStyle.InfobarBottomCenter = ConfigSelection(default=infobarbottomcenterdef, choices = infobarbottomcenteropt)

		config.plugins.MetrixStyle.InfobarBottomRight = ConfigSelection(default="infobar-bottom-right-icons", choices = [
				("infobar-bottom-right-icons", _("Icons Metrix")+" "+_("(")+_("default")+_(")")),
				("infobar-bottom-right-icons_new", _("Icons MetrixStyle")),							
				("no-widget", _("off"))				
				])

		config.plugins.MetrixStyle.InfobarRecordState = ConfigSelection(default="no-widget", choices = [
				("no-widget", _("no")+" "+_("(")+_("default")+_(")")),
				("infobar-recordstate-red", _("yes"))				
				])				

		#SecondInfoBar
		config.plugins.MetrixStyle.SecondInfobarTopLeft = ConfigSelection(default="no-widget", choices = [
				("no-widget", _("off")+" "+_("(")+_("default")+_(")")),
				("infobar-top-left-clockdate", _("Clock")+_("/")+_("Date")),
				("infobar-top-left-clockdateextended", _("Clock")+_("/")+_("Date")+" "+_("Extended")),				
				("infobar-top-left-msnweather", _("Weather"))				
				])

		config.plugins.MetrixStyle.SecondInfobarTopCenter = ConfigSelection(default="no-widget", choices = [
				("no-widget", _("off")+" "+_("(")+_("default")+_(")")),
				("infobar-top-center-cryptinfo", _("Show CAID/ECM Info")),
				("infobar-top-center-serviceinfo", _("Serviceinfo")),
				("infobar-top-center-satinfo", _("Serviceinfo")),
				("infobar-top-center-tunerinfo", _("Tunerinfo(FBC)")),				
				("infobar-top-center-syteminfo", _("Show System Info")),
				("infobar-top-center-weather-clockdate", _("Weather/Clock/Date full size"))	
				])				

		config.plugins.MetrixStyle.SecondInfobarTopRight = ConfigSelection(default="infobar-top-right-clockdate", choices = [
				("no-widget", _("off")),
				("infobar-top-right-clockdate", _("Clock")+_("/")+_("Date")+" "+_("(")+_("default")+_(")")),				
				("infobar-top-right-clockdateextended", _("Clock")+_("/")+_("Date")+" "+_("Extended")),				
				("infobar-top-right-msnweather", _("Weather"))				
				])				

		config.plugins.MetrixStyle.SecondInfobarEPGWidget = ConfigSelection(default="secondinfobar-epgwidget", choices = [
				("secondinfobar-epgwidget", _("Now/Next description")+" "+_("(")+_("default")+_(")")),
				("secondinfobar-epgwidget-running", _("Now/Next description/running")),				
				("secondinfobar-extendedinfo", _("Service extendedinfo")),				
				("no-widget", _("off"))
				])
								
	def GetPicturePath(self):
		try:
			returnValue = self["config"].getCurrent()[1].value
			#print "\n selectedOption: " + returnValue + "\n"
			path = "/usr/lib/enigma2/python/Plugins/Extensions/MetrixStyle/images/" + returnValue + ".png"
			return path
		except:
			return "/usr/lib/enigma2/python/Plugins/Extensions/MetrixStyle/images/no-widget.png"
		
	def UpdatePicture(self):
		self.PicLoad_conn = self.PicLoad.PictureData.connect(self.DecodePicture)
		self.onLayoutFinish.append(self.ShowPicture)
	
	def ShowPicture(self):
		self.PicLoad.setPara([self["helperimage"].instance.size().width(),self["helperimage"].instance.size().height(),self.Scale[0],self.Scale[1],0,1,"#002C2C39"])
		self.PicLoad.startDecode(self.GetPicturePath())
		#print "showing image"
		
	def DecodePicture(self, PicInfo = ""):
		#print "decoding picture"
		ptr = self.PicLoad.getData()
		self["helperimage"].instance.setPixmap(ptr)	

	def UpdateComponents(self):
		self.UpdatePicture()

	def resetConf(self):	
		print self["config"].getCurrent()[1].value
		print self["config"].getCurrent()[1].default
		self["config"].getCurrent()[1].value=self["config"].getCurrent()[1].default
		self["config"].invalidateCurrent()
		self.ShowPicture()

	def resetAll(self,key):	
		metrix_settings="MetrixStyle"+" "+_("Settings")
		self.session.openWithCallback(self.resetAllConf, MessageBox, _("Do you really want to delete %s?") % metrix_settings)
	
	def resetAllConf(self, result):
		if not result:
			return
		for x in self["config"].list:
			if len(x) > 1:
        			x[1].value=x[1].default
			else:
       				pass
		# set updated list ...
		lst = self["config"]                                          
                lst.list = self["config"].list                                           
                lst.l.setList(self["config"].list)      

	def keyLeft(self):	
		ConfigListScreen.keyLeft(self)	
		self.ShowPicture()

	def keyRight(self):
		ConfigListScreen.keyRight(self)
		self.ShowPicture()
	
	def keyDown(self):
		#print "key down"
		self["config"].instance.moveSelection(self["config"].instance.moveDown)
		#ConfigListScreen.keyDown(self)
		self.ShowPicture()
		
	def keyUp(self):
		#print "key up"
		self["config"].instance.moveSelection(self["config"].instance.moveUp)
		#ConfigListScreen.keyUp(self)
		self.ShowPicture()
		
	def showInfo(self):
		self.session.open(MessageBox, _("Skin MetrixStyle  10.2 \n\nmodded for DreamOS by arki \n\nsupport www.nachtfalke.biz"), MessageBox.TYPE_INFO)

	def save(self):
		for x in self["config"].list:
			if len(x) > 1:
        			x[1].save()
			else:
       				pass
       			
		###########READING DATA FILES
		try:
			self.appendSkinFile(self.daten + "header.xml")
			#SelectedLine
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.SkinSelectedLine.value +".xml")			
			###InfoBar
			self.appendSkinFile(self.daten + "infobar-header.xml")
			#Style
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.InfobarStyle.value + ".xml")
			#Picon			
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.InfobarPiconPath.value + ".xml")
			#Separator			
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.InfobarSeparator.value + ".xml")			
			#TopLeft			
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.InfobarTopLeft.value + ".xml")
			#TopCenter
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.InfobarTopCenter.value + ".xml")
			#TopRight
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.InfobarTopRight.value + ".xml")
			#InfobarHeadPanel
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.InfobarHead.value + ".xml")			
			#ChannelName
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.InfobarShowChannelname.value + ".xml")		
			#BottomLeft
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.InfobarBottomLeft.value + ".xml")
			#BottomCenter
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.InfobarBottomCenter.value + ".xml")			
			#BottomRight
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.InfobarBottomRight.value + ".xml")
			#RecordState
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.InfobarRecordState.value + ".xml")			
			#Footer
			self.appendSkinFile(self.daten + "infobar-footer.xml")			
			###SecondInfoBar
			self.appendSkinFile(self.daten + "secondinfobar-header.xml")
			#TopLeft
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.SecondInfobarTopLeft.value + ".xml")
			#TopCenter
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.SecondInfobarTopCenter.value + ".xml")
			#TopRight
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.SecondInfobarTopRight.value + ".xml")			
			#EPGWidget
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.SecondInfobarEPGWidget.value + ".xml")			
			#Footer
			self.appendSkinFile(self.daten + "secondinfobar-footer.xml")
			#Channelselection			
			self.appendSkinFile(self.daten + "channelselection-header.xml")
			#Channelselectionlist
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.ChannelselectionStyle.value + ".xml")
			#Channelselectioninfo
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.ChannelselectionInfo.value + ".xml")
			#Channelselection picon
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.ChannelselectionPicon.value + ".xml")			
			#Footer			
			self.appendSkinFile(self.daten + "channelselection-footer.xml")			
			#VOLUMESTYLE
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.VolumeStyle.value + ".xml")
			#SUBTITLESTYLE
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.SubtitleStyle.value + ".xml")			
			#MAINMENU
			self.appendSkinFile(self.daten + "menu-header.xml")
			#MENUSTYLE			
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.MenuStyle.value +".xml")
			#ICONSTYLE			
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.MenuIconBackColor.value +".xml")			
			#Footer
			self.appendSkinFile(self.daten + "menu-footer.xml")			
			#AMS
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.AMSStyle.value +".xml")			
			#EMC
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.EMCStyle.value +".xml")
			#VideoDB
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.VideoDBStyle.value +".xml")
			#Valis EPG
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.ValisEPGStyle.value +".xml")			
			#Display OLED			
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.OledDisplayInfobarStyle.value +".xml")
			#Display Idle			
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.DisplayIdleStyle.value +".xml")			
			#Display LCD
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.DisplayInfobarStyle.value +".xml")
			#Display LCD
			self.appendSkinFile(self.daten + config.plugins.MetrixStyle.DisplayChanelselectionStyle.value +".xml")			
			###Main XML
			self.appendSkinFile(self.daten + "main.xml")
			### END			
			self.appendSkinFile(self.daten + "footer.xml")				
							
			xFile = open(self.dateiTMP, "w")
			for xx in self.skin_lines:
				xFile.writelines(xx)
			xFile.close()
			#Replaces <color name="metrixSelection" value="#000050EE" /> with SkinSelectedBackgroundColor.value
			o = open(self.datei,"w")
			for line in open(self.dateiTMP):
				
				line = line.replace("#000050EE", config.plugins.MetrixStyle.SkinSelectedBackgroundColor.value )				
				line = line.replace("#00fffffd", config.plugins.MetrixStyle.SkinSelectedForegroundColor.value )
				line = line.replace("#40000000", config.plugins.MetrixStyle.SkinBackgroundColor.value )				
				line = line.replace("#00fffffe", config.plugins.MetrixStyle.SkinForegroundColor.value )
				line = line.replace("#00fffffc", config.plugins.MetrixStyle.SkinSelectedHelpTextColor.value )				
				line = line.replace("#00dddddd", config.plugins.MetrixStyle.SkinClockColor.value )
				line = line.replace("#00008A01", config.plugins.MetrixStyle.SkinCaidInfoColor.value )				
				line = line.replace("#0070ad10", config.plugins.MetrixStyle.SkinTunerInfoColor.value )				
				line = line.replace("#00999998", config.plugins.MetrixStyle.Channeldescription.value )
				line = line.replace("#00999996", config.plugins.MetrixStyle.InfobarChannelnamecolor.value )				
				line = line.replace("p_bar", config.plugins.MetrixStyle.SkinProgressbarColor.value )
				line = line.replace("#000001", config.plugins.MetrixStyle.SkinLCDbackgroundColor.value )				
				line = line.replace("#ffffef", config.plugins.MetrixStyle.SkinLCDforegroundColor.value )				
				line = line.replace("#ffffdf", config.plugins.MetrixStyle.SkinLCDclockColor.value )				
				line = line.replace("0012", config.plugins.MetrixStyle.SkinCornerRadius.value )				
				o.write(line)
			o.close()
			system('rm -rf ' + self.dateiTMP)

		except:
			self.session.open(MessageBox, _("Error creating Skin!"), MessageBox.TYPE_ERROR)
		configfile.save()
		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)
		restartbox.setTitle(_("Restart GUI"))

	def restartGUI(self, answer):
		if answer:
			self.session.open(TryQuitMainloop, 3)
			
	def appendSkinFile(self,appendFileName):
		skFile = open(appendFileName, "r")
		file_lines = skFile.readlines()
		skFile.close()	
		for x in file_lines:
			self.skin_lines.append(x)
			
	def exit(self):
		for x in self["config"].list:
			if len(x) > 1:
					x[1].cancel()
			else:
       				pass
		del self.PicLoad
		self.close()
