From bb438bec17665a907c28ca47d665766c7b26be79 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Fri, 6 Jan 2006 15:48:47 +0000 Subject: plugins can register their own menu now menus have their own id now the update plugin for example adds a menu item to the Setup menu with the id "setup" --- lib/python/Components/PluginComponent.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'lib/python/Components/PluginComponent.py') diff --git a/lib/python/Components/PluginComponent.py b/lib/python/Components/PluginComponent.py index f1a0a95a..5315d3d9 100644 --- a/lib/python/Components/PluginComponent.py +++ b/lib/python/Components/PluginComponent.py @@ -1,12 +1,14 @@ import os from Tools.Directories import * +from Screens.Menu import menuupdater #import Plugins class PluginComponent: def __init__(self): self.plugins = [] self.setPluginPrefix("Plugins.") + self.menuEntries = [] def setPluginPrefix(self, prefix): self.prefix = prefix @@ -14,18 +16,32 @@ class PluginComponent: def getPluginList(self): list = [] dir = os.listdir("/usr/lib/enigma2/python/Plugins/") + self.menuDelete() + self.menuEntries = [] for x in dir: if x[-3:] == ".py" and x[:-3] != "__init__": - #try: print "trying to import " + self.prefix + x[:-3] exec "import " + self.prefix + x[:-3] picturepath = eval(self.prefix + x[:-3]).getPicturePath() pluginname = eval(self.prefix + x[:-3]).getPluginName() + try: + for menuEntry in eval(self.prefix + x[:-3]).getMenuRegistrationList(): + self.menuEntries.append([menuEntry, self.prefix + x[:-3]]) + except: + pass + list.append((picturepath, pluginname , x[:-3])) - #except: - #print "Failed to open module - wrong plugin!" + self.menuUpdate() return list + def menuDelete(self): + for menuEntry in self.menuEntries: + menuupdater.delMenuItem(menuEntry[0][0], menuEntry[0][2], menuEntry[1], menuEntry[0][3]) + + def menuUpdate(self): + for menuEntry in self.menuEntries: + menuupdater.addMenuItem(menuEntry[0][0], menuEntry[0][2], menuEntry[1], menuEntry[0][3]) + def runPlugin(self, plugin, session): try: exec "import " + self.prefix + plugin[2] -- cgit v1.2.3