fix and simplify PluginList
[enigma2.git] / lib / python / Components / PluginList.py
1 from MenuList import MenuList
2
3 from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
4 from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
5
6 from enigma import eListboxPythonMultiContent, eListbox, gFont
7 from Tools.LoadPixmap import LoadPixmap
8
9 def PluginEntryComponent(plugin):
10         res = [ plugin ]
11         
12         res.append(MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=plugin.name))
13         res.append(MultiContentEntryText(pos=(120, 26), size=(320, 17), font=1, text=plugin.description))
14
15         if plugin.icon is None:
16                 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "plugin.png"))
17         else:
18                 png = plugin.icon
19         res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 5), size=(100, 40), png = png))
20         
21         return res
22
23 def PluginCategoryComponent(name, png):
24         res = [ name ]
25         
26         res.append(MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=name))
27         res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 0), size=(100, 50), png = png))
28         
29         return res
30
31 def PluginDownloadComponent(plugin, name):
32         res = [ plugin ]
33         
34         res.append(MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=name))
35         res.append(MultiContentEntryText(pos=(120, 26), size=(320, 17), font=1, text=plugin.description))
36
37         if plugin.icon is None:
38                 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "plugin.png"))
39         else:
40                 png = plugin.icon
41         res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 0), size=(100, 50), png = png))
42         
43         return res
44
45 class PluginList(MenuList):
46         def __init__(self, list, enableWrapAround=False):
47                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent())
48                 self.l.setFont(0, gFont("Regular", 20))
49                 self.l.setFont(1, gFont("Regular", 14))
50                 self.l.setItemHeight(50)