from Screens.DefaultWizard import DefaultWizard
from Screens.LanguageSelection import LanguageSelection, _cached
from Screens.Rc import Rc
from Screens.ScanSetup import DefaultSatLists
from Screens.Wizard import wizardManager
from Screens.WizardLanguage import WizardLanguage
from Components.config import config, ConfigBoolean, configfile, ConfigSubsection
from Components.Label import Label
from Components.NimManager import nimmanager
from Components.Pixmap import Pixmap
from Components.ResourceManager import resourcemanager
from Components.Sources.Boolean import Boolean
from Components.Sources.StaticText import StaticText

try:
	from Screens.StartWizard import StartWizard
	print "[PowerMetrixFHD] 018 -OK-- StartWizard"
except:
	print "[PowerMetrixFHD] 018 -NOK- StartWizard"

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

emptyWizardList = []

def makeEmptyWizard():
	global emptyWizardList
	class EmptyWizard(object):
		pass
	emptyWizardList.append(EmptyWizard)
	return EmptyWizard

NetworkWizardNew = resourcemanager.getResource("NetworkWizard.NetworkWizardNew", makeEmptyWizard())
VideoWizard = resourcemanager.getResource("videomode.videowizard", makeEmptyWizard())

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

def StartWizard__init__(self, session, silent = True, showSteps = False, neededTag = None):
	self.xmlfile = ["startwizard.xml", "defaultsatlistsPS.xml"]
	DefaultWizard.__init__(self, session, silent, showSteps, neededTag = "services", default = True)
	WizardLanguage.__init__(self, session, showSteps = False, showMulticontentList = True)
	Rc.__init__(self)

	self["wizard"] = Pixmap()

	# needed for LanguageSelection
	self.png_cache = { }

	self["button_green"] = Boolean(False)
	self["button_green_text"] = StaticText()
	#self["button_green_text"].hide()
	self["button_yellow"] = Boolean(False)
	self["button_yellow_text"] = StaticText()
	#self["button_yellow_text"].hide()
	self["button_blue"] = Boolean(False)
	self["button_blue_text"] = StaticText()
	#self["button_blue_text"].hide()

	self["state_label"] = Label()
	self["state"] = Label()
	self.showState(False)

	NetworkWizardNew.__init__(self)
	self.networkWizardAvailable = NetworkWizardNew not in emptyWizardList

	self["portpic"] = Pixmap()
	VideoWizard.__init__(self)
	self.videoWizardAvailable = VideoWizard not in emptyWizardList

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

def StartWizardshowHideButtons(self, green = False, yellow = False, blue = False):
	if green:
		self["button_green"].boolean = True
		#self["button_green_text"].show()
	else:
		self["button_green"].boolean = False
		self["button_green_text"].text = ""
		#self["button_green_text"].hide()

	if yellow:
		self["button_yellow"].boolean = True
		#self["button_yellow_text"].show()
	else:
		self["button_yellow"].boolean = False
		self["button_yellow_text"].text = ""
		#self["button_yellow_text"].hide()

	if blue:
		self["button_blue"].boolean = True
		#self["button_blue_text"].show()
	else:
		self["button_blue"].boolean = False
		self["button_blue_text"].text = ""
		#self["button_blue_text"].hide()

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

def doStartWizardChange():
	try:
		StartWizard.__init__ = StartWizard__init__
		StartWizard.showHideButtons = StartWizardshowHideButtons
		print "[PowerMetrixFHD] 018 -OK-- StartWizard"
	except:
		print "[PowerMetrixFHD] 018 -NOK- StartWizard"
