follow changes
[enigma2.git] / lib / python / Plugins / Plugin.py
1 from enigma import loadPNG
2
3 class PluginDescriptor:
4         """An object to describe a plugin."""
5         
6         # where to list the plugin. Note that there are different call arguments,
7         # so you might not be able to combine them.
8         
9         # supported arguments are:
10         #   session
11         #   servicereference
12         #   reason
13         
14         # you have to ignore unknown kwargs!
15         
16         # argument: session
17         WHERE_BLUEMENU = 0
18         WHERE_MAINMENU = 1
19         WHERE_PLUGINMENU  = 2
20         # argument: session, serviceref (currently selected)
21         WHERE_MOVIELIST = 3
22         # ...
23         WHERE_SETUP    = 4
24         
25         # reason (0: start, 1: end)
26         WHERE_AUTOSTART = 5
27         
28         # start as wizard. In that case, fnc must be a screen class!
29         WHERE_WIZARD = 6
30         
31         # like autostart, but for a session. currently, only session starts are 
32         # delivered, and only on pre-loaded plugins
33         WHERE_SESSIONSTART = 7
34         
35         # start as teletext plugin. arguments: session, serviceref
36         WHERE_TELETEXT = 8
37         
38         def __init__(self, name = "Plugin", where = [ ], description = "", icon = None, fnc = None):
39                 self.name = name
40                 if type(where) is list:
41                         self.where = where
42                 else:
43                         self.where = [ where ]
44                 self.description = description
45
46                 if type(icon) is str or icon is None:
47                         self.iconstr = icon
48                         self.icon = None
49                 else:
50                         self.icon = icon
51
52                 self.__call__ = fnc
53
54         def updateIcon(self, path):
55                 if type(self.iconstr) is str:
56                         self.icon = loadPNG(path + "/" + self.iconstr)
57                 else:
58                         self.icon = None
59
60         def __eq__(self, other):
61                 return self.__call__ == other.__call__