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=[])
12 config.plugins.pluginhider.hideeventinfo = ConfigSet(choices=[])
14 def PluginComponent_getPlugins(self, where):
15 if not isinstance(where, list):
19 if PluginDescriptor.WHERE_EXTENSIONSMENU in where:
20 hide = config.plugins.pluginhider.hideextensions.value
21 res.extend((x for x in self.plugins.get(PluginDescriptor.WHERE_EXTENSIONSMENU, []) if x.name not in hide))
22 where.remove(PluginDescriptor.WHERE_EXTENSIONSMENU)
24 if PluginDescriptor.WHERE_PLUGINMENU in where:
25 hide = config.plugins.pluginhider.hideplugins.value
26 res.extend((x for x in self.plugins.get(PluginDescriptor.WHERE_PLUGINMENU, []) if x.name not in hide))
27 where.remove(PluginDescriptor.WHERE_PLUGINMENU)
29 if PluginDescriptor.WHERE_EVENTINFO in where:
30 hide = config.plugins.pluginhider.hideeventinfo.value
31 res.extend((x for x in self.plugins.get(PluginDescriptor.WHERE_EVENTINFO , []) if x.name not in hide))
32 where.remove(PluginDescriptor.WHERE_EVENTINFO)
35 res.extend(PluginComponent.pluginHider_baseGetPlugins(self, where))
36 res.sort(key=lambda x:x.weight)
39 def autostart(reason, *args, **kwargs):
41 PluginComponent.pluginHider_baseGetPlugins = PluginComponent.getPlugins
42 PluginComponent.getPlugins = PluginComponent_getPlugins
44 PluginComponent.getPlugins = PluginComponent.pluginHider_baseGetPlugins
46 def main(session, *args, **kwargs):
47 session.open(PluginHiderSetup)
50 if menuid != "system":
52 return [(_("Hide Plugins"), main, "pluginhider_setup", None)]
54 def Plugins(**kwargs):
57 where=PluginDescriptor.WHERE_AUTOSTART,
62 where=PluginDescriptor.WHERE_MENU,