2 from Plugins.Plugin import PluginDescriptor
4 from Components.PluginComponent import PluginComponent
5 from Components.config import config, ConfigSubsection, ConfigSet
7 from PluginHiderSetup import PluginHiderSetup
9 config.plugins.pluginhider = ConfigSubsection()
10 config.plugins.pluginhider.hideextensions = ConfigSet(choices=[])
11 config.plugins.pluginhider.hideplugins = ConfigSet(choices=[])
13 def PluginComponent_getPlugins(self, where):
14 if not isinstance(where, list):
18 if PluginDescriptor.WHERE_EXTENSIONSMENU in where:
19 hideextensions = config.plugins.pluginhider.hideextensions.value
20 res.extend((x for x in self.plugins.get(PluginDescriptor.WHERE_EXTENSIONSMENU, []) if x.name not in hideextensions))
21 where.remove(PluginDescriptor.WHERE_EXTENSIONSMENU)
23 if PluginDescriptor.WHERE_PLUGINMENU in where:
24 hideplugins = config.plugins.pluginhider.hideplugins.value
25 res.extend((x for x in self.plugins.get(PluginDescriptor.WHERE_PLUGINMENU, []) if x.name not in hideplugins))
26 where.remove(PluginDescriptor.WHERE_PLUGINMENU)
29 res.extend(PluginComponent.pluginHider_baseGetPlugins(self, where))
30 res.sort(key=lambda x:x.weight)
33 def autostart(reason, *args, **kwargs):
35 PluginComponent.pluginHider_baseGetPlugins = PluginComponent.getPlugins
36 PluginComponent.getPlugins = PluginComponent_getPlugins
38 PluginComponent.getPlugins = PluginComponent.pluginHider_baseGetPlugins
40 def main(session, *args, **kwargs):
41 session.open(PluginHiderSetup)
44 if menuid != "system":
46 return [(_("Hide Plugins"), main, "pluginhider_setup", None)]
48 def Plugins(**kwargs):
51 where=PluginDescriptor.WHERE_AUTOSTART,
56 where=PluginDescriptor.WHERE_MENU,