remove /media/hdd/picon as picon source..
[enigma2.git] / lib / python / Components / Renderer / Picon.py
1 ##
2 ## Picon renderer by Gruffy .. some speedups by Ghost
3 ##
4 from Renderer import Renderer
5 from enigma import ePixmap
6 from Tools.Directories import pathExists, fileExists, SCOPE_SKIN_IMAGE, resolveFilename
7
8 class Picon(Renderer):
9         pngname = ""
10         nameCache = { }
11         searchPaths = ['/usr/share/enigma2/picon/',
12                                 '/media/cf/picon/',
13                                 '/media/usb/picon/']
14
15         def __init__(self):
16                 Renderer.__init__(self)
17
18         GUI_WIDGET = ePixmap
19
20         def changed(self, what):
21                 if self.instance:
22                         pngname = ""
23                         if what[0] != self.CHANGED_CLEAR:
24                                 sname = self.source.text
25                                 # strip all after last :
26                                 pos = sname.rfind(':')
27                                 if pos != -1:
28                                         sname = sname[:pos].rstrip(':').replace(':','_')
29                                 pngname = self.nameCache.get(sname, "")
30                                 if pngname == "":
31                                         pngname = self.findPicon(sname)
32                                         if pngname != "":
33                                                 self.nameCache[sname] = pngname
34                         if pngname == "": # no picon for service found
35                                 pngname = self.nameCache.get("default", "")
36                                 if pngname == "": # no default yet in cache..
37                                         pngname = self.findPicon("picon_default")
38                                         if pngname == "": # Fallback to enigma2 logo
39                                                 pngname = resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/enigma2.png")
40                                         self.nameCache["default"] = pngname
41                         if self.pngname != pngname:
42                                 self.instance.setPixmapFromFile(pngname)
43                                 self.pngname = pngname
44
45         def findPicon(self, serviceName):
46                 for path in self.searchPaths:
47                         pngname = path + serviceName + ".png"
48                         if fileExists(pngname):
49                                 return pngname
50                 return ""