Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
from Plugins.Plugin import PluginDescriptor
from Screens.MessageBox import MessageBox
from Components.config import config, ConfigYesNo, ConfigSubsection
from Tools.Directories import resolveFilename, SCOPE_SKIN
from os.path import dirname

import SkinReloader

config.plugins.skinreloader = ConfigSubsection()
config.plugins.skinreloader.reloadInfobar 				= ConfigYesNo(default = True)
config.plugins.skinreloader.checkSkinSyntaxOnReload 	= ConfigYesNo(default = False)
config.plugins.skinreloader.activateSkinWatchOnStart 	= ConfigYesNo(default = False)
config.plugins.skinreloader.showInExtMenu 				= ConfigYesNo(default = True)
config.plugins.skinreloader.closeAfterReloadSkin		= ConfigYesNo(default = False)

reload_value   = True
fileMonitor    = None
skinReloader   = None
current_dialog = None

def main(session, **kwargs):
	reloadSkinReloader(session)
	from SkinReloader import ReloadSkinScreen
	global current_dialog
	current_dialog = session.current_dialog
	session.openWithCallback(ReloadSkinCallback, ReloadSkinScreen)

def ReloadSkinCallback(retValue=None, session=None):
	if retValue:
		from Screens.PluginBrowser import PluginBrowser
		if isinstance(current_dialog,PluginBrowser):
			current_dialog.close() #close PluginBrowser

def extmenu(session, **kwargs):
	#reloadSkinReloader(session)
	skinReloader.reloadSkinFirst()

def changeSkin(session, **kwargs):
	#reloadSkinReloader(session)
	from SkinReloader import OwnSkinSelector
	session.openWithCallback(SkinSelectorCallback, OwnSkinSelector)

def SkinSelectorCallback(session = None, retValue = None):
	if retValue:
		skinReloader.reloadSkinFirst(new_name=retValue)

def reloadSkinReloader(session):
	if reload_value:
		reload(SkinReloader)
		from SkinReloader import SkinReload
		global skinReloader
		skinReloader = SkinReload(session)

def skinWatch(session, **kwargs):
	if fileMonitor is not None and fileMonitor.isWatching:
		fileMonitor.stop()
		session.open(MessageBox,_("SkinReloader\n\nThe skinWatcher has been stopped."), MessageBox.TYPE_INFO,timeout=3)
	elif fileMonitor is not None:
		fileMonitor.start()
		filename = resolveFilename(SCOPE_SKIN, config.skin.primary_skin.value)
		currentSkin = dirname(filename)
		session.open(MessageBox,_("SkinReloader\n\nThe skinWatcher was started.\n\ncurrent skin-folder to watch:\n * " + currentSkin + "   (skin.xml)\n * /etc/enigma2   (skin_user.xml + skin_user_display.xml)"), MessageBox.TYPE_INFO,timeout=5)

def shutdown():
	global fileMonitor
	if fileMonitor is not None and fileMonitor.isWatching:
		fileMonitor.stop()
		fileMonitor = None

def autostart(reason, **kwargs):
	if "session" in kwargs:
		session = kwargs["session"]
		global fileMonitor, skinReloader
		from SkinReloader import FileWatchHandler, SkinReload
		skinReloader = SkinReload(session)
		fileMonitor = FileWatchHandler(session)
		if config.plugins.skinreloader.activateSkinWatchOnStart.value:
			fileMonitor.start()

def startInfoBar(session, **kwargs):
		from Screens.InfoBar import InfoBar
		from Tools.BoundFunction import boundFunction
		InfoBar.onShowSkinReloader = boundFunction(InfoBarOnShow,InfoBar.instance)
		InfoBar.instance.onShow.append(InfoBar.onShowSkinReloader)

def InfoBarOnShow(self):
		from Screens.InfoBar import InfoBar
		from Tools.BoundFunction import boundFunction
		InfoBar.instance.onShow.remove(InfoBar.onShowSkinReloader)
		del InfoBar.onShowSkinReloader
		InfoBar.InfoBar_SkinReloader = InfoBar.instance.session.current_dialog


extMenuReloadSkinPluginDescriptor = PluginDescriptor(name =_("SkinReloader (reload skin)"), description=_("SkinReloader (reload skin)"), where = [PluginDescriptor.WHERE_EXTENSIONSMENU], fnc = extmenu, needsRestart = False, icon="SkinReloader.svg")

extMenuChangeSkinPluginDescriptor = PluginDescriptor(name =_("SkinReloader (change Skin)"), description=_("SkinReloader (change Skin)"), where = [PluginDescriptor.WHERE_EXTENSIONSMENU], fnc = changeSkin, needsRestart = False, icon="SkinReloader.svg")

extMenuToggleSkinWatcherPluginDescriptor = PluginDescriptor(name =_("SkinReloader (start skinWatch)"), description=_("SkinReloader (start skinWatch)"), where = [PluginDescriptor.WHERE_EXTENSIONSMENU], fnc = skinWatch, needsRestart = False, icon="SkinReloader.svg")


def Plugins(**kwargs):
	
	descriptors = []
	
	descriptors.append(PluginDescriptor(where=[PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc=autostart, wakeupfnc=shutdown))
	
	descriptors.append( PluginDescriptor(name =_("SkinReloader"), description=_("Reload Skin without GUI-Restart (v%s)" % SkinReloader.version), where= PluginDescriptor.WHERE_PLUGINMENU, fnc = main, needsRestart = False, icon="SkinReloader.svg" ))
	
	if config.plugins.skinreloader.showInExtMenu.value:
		descriptors.append(extMenuReloadSkinPluginDescriptor)
		descriptors.append(extMenuChangeSkinPluginDescriptor)
		descriptors.append(extMenuToggleSkinWatcherPluginDescriptor)
	
	descriptors.append( PluginDescriptor(where=[PluginDescriptor.WHERE_INFOBAR,], fnc=startInfoBar))
	
	return descriptors