# -*- coding: utf-8 -*-
from Plugins.Extensions.WebInterface.WebScreens import WebScreen

class SrScreen(WebScreen):
	def __init__(self, session, request):
		WebScreen.__init__(self, session, request)
		from enigma import eServiceReference, iServiceInformation
		from Components.Sources.StaticText import StaticText
		from Plugins.Bp.geminimain.gTools import libgeminimain
		from Plugins.Bp.geminimain.plugin import BG_STREAM
		from Plugins.Bp.geminimain.gLocale import _
		from Plugins.Bp.geminisr.WebComponents.Sr import Sr
		currPlay = self.session.nav.getCurrentService()
		
		self["Recorder"] = Sr(session)
		
		if not bool(libgeminimain.getBGstatus() & BG_STREAM) and ( currPlay is None or currPlay.info().getInfoString(iServiceInformation.sTagOrganization) == "" ):
			self["Btn_Submit"] = StaticText("<img src=\"/web-data/img/save.png\" style=\"vertical-align:middle;\"/> " + _("Save"))
			self["Sr_Info"] = StaticText(_("Streamripper") + ": " + _("Station") + " " + _("not running") + " <img src=\"/web-data/img/speak_off.png\" style=\"background-color:#FFFFFF;\" />")
		else:
			self["Btn_Submit"] = StaticText("<img src=\"/web-data/img/control_stop_blue.png\" style=\"vertical-align:middle;\"/> " + _("Stop recording") if bool(libgeminimain.getBGstatus() & BG_STREAM) else "<img src=\"/web-data/img/record.png\" style=\"vertical-align:middle;\"/> " + _("Start recording"))
			self["Sr_Info"] = StaticText(_("Streamripper") + ": " + (_("running") + " <img src=\"/streamripper/img/rec_aktiv.gif\"/>" if bool(libgeminimain.getBGstatus() & BG_STREAM) else _("not running")))
		
		self["RecDir_txt"] = StaticText(_("record directory"))
		self["RecDir"] = StaticText(libgeminimain.getStrConfig("SR_path","/media/hdd"))
		self["Btn_Close"] = StaticText(_("Close"))
		
		self["ConstStream_txt"] = StaticText(_("constant stream"))
		self["ConstStream"] = StaticText(str("checked" if libgeminimain.getIntConfig("SR_conststream", 0) == 1 else "" ))
		