From eeda01368cface7208fd221ac82f4ff4a44115e3 Mon Sep 17 00:00:00 2001 From: Acid Burn Date: Tue, 10 Nov 2009 23:30:56 +0100 Subject: [PATCH] Tools/Directories.py: - add fallback to default_skin if SCOPE_CURRENT_SKIN is used and the wanted file is not found inside the current skin path. - introduce SCOPE_CURRENT_PLUGIN whitch first looks inside the current skin path for the requested file and if not found fallbacks to SCOPE_PLUGINS. For Example: pixmap = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, 'skin_default/icons/epgclock.png')) first looks inside /usr/lib/enigma2/yourskinfolder/skin_default/icons/ for the png file and if not found it takes the png from /usr/lib/enigma2/skin_default/icons/. Similiar pixmap = LoadPixmap(resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png")) does the same, except that it fallbacks to SCOPE_PLUGINS, aka /usr/lib/enigma2/python/Plugins. In this example /usr/lib/enigma2/python/Plugins/SystemPlugins/SoftwareManager/ and gets the provided original png. So it is now possible to reskin hardcoded pixmaps inside .py files through the skin by providing new graphics inside the current skin path and overriding the original values. This fixes #249 --- lib/python/Tools/Directories.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/python/Tools/Directories.py b/lib/python/Tools/Directories.py index 681bc04..8ed2c8a 100755 --- a/lib/python/Tools/Directories.py +++ b/lib/python/Tools/Directories.py @@ -33,6 +33,7 @@ SCOPE_DEFAULTDIR = 13 SCOPE_DEFAULTPARTITION = 14 SCOPE_DEFAULTPARTITIONMOUNTDIR = 15 SCOPE_METADIR = 16 +SCOPE_CURRENT_PLUGIN = 17 PATH_CREATE = 0 PATH_DONTCREATE = 1 @@ -85,7 +86,27 @@ def resolveFilename(scope, base = "", path_prefix = None): tmp = defaultPaths[SCOPE_SKIN] pos = config.skin.primary_skin.value.rfind('/') if pos != -1: - path = tmp[0]+config.skin.primary_skin.value[:pos+1] + #if basefile is not available use default skin path as fallback + tmpfile = tmp[0]+config.skin.primary_skin.value[:pos+1] + base + if fileExists(tmpfile): + path = tmp[0]+config.skin.primary_skin.value[:pos+1] + else: + path = tmp[0] + else: + path = tmp[0] + + elif scope == SCOPE_CURRENT_PLUGIN: + tmp = defaultPaths[SCOPE_PLUGINS] + from Components.config import config + skintmp = defaultPaths[SCOPE_SKIN] + pos = config.skin.primary_skin.value.rfind('/') + if pos != -1: + #if basefile is not available inside current skin path, use the original provided file as fallback + skintmpfile = skintmp[0]+config.skin.primary_skin.value[:pos+1] + base + if fileExists(skintmpfile): + path = skintmp[0]+config.skin.primary_skin.value[:pos+1] + else: + path = tmp[0] else: path = tmp[0] else: -- 2.7.4