from Components.SetupGuide.BaseStep import SetupListStep
from Screens.MerlinRecommendedAddons import MerlinRecommendedAddons
from enigma import eNetworkManager
from Tools.Log import Log

class RecommendedAddonsStep(SetupListStep):
	def __init__(self, parent):
		SetupListStep.__init__(self, parent)
		self._options = []

	def prepare(self):
		nm = eNetworkManager.getInstance()
		if not nm.online():
			Log.w("No network available! Skipping!")
			return False
		self.title = _("Recommended addons")
		self.text = _("Do you want to check the list of our recommended addons?")
		self._options = [
			(True, _("Yes")),
			(False, _("No"))
		]
		return True

	@property
	def listContent(self):
		return self._options

	def buildfunc(self, enabled, entry):
		return [entry,enabled]

	def onOk(self):
		lst = self.parent.list
		if not lst.current or not lst.current[0]:
			return True
		self.parent.session.openWithCallback(self._onMerlinRecommendedAddonsSet, MerlinRecommendedAddons)
		return False

	def _onMerlinRecommendedAddonsSet(self, result=False):
		self.parent.nextStep()
