4 from Plugins.Plugin import PluginDescriptor
6 from Components.PluginComponent import PluginComponent
7 from Components.config import config, ConfigSubsection, ConfigSet
9 from PluginHiderSetup import PluginHiderSetup
11 config.plugins.pluginhider = ConfigSubsection()
12 config.plugins.pluginhider.hideextensions = ConfigSet(choices=[])
13 config.plugins.pluginhider.hideplugins = ConfigSet(choices=[])
14 config.plugins.pluginhider.hideeventinfo = ConfigSet(choices=[])
16 def hidePlugin(plugin):
17 """Convenience function for external code to hide a plugin."""
18 hide = config.plugins.pluginhider.hideplugins.value
19 if not plugin.name in hide:
20 hide.append(plugin.name)
21 config.plugins.pluginhider.hideplugins.save()
23 def PluginComponent_getPlugins(self, where):
24 if not isinstance(where, list):
28 if PluginDescriptor.WHERE_EXTENSIONSMENU in where:
29 hide = config.plugins.pluginhider.hideextensions.value
30 res.extend((x for x in self.plugins.get(PluginDescriptor.WHERE_EXTENSIONSMENU, []) if x.name not in hide))
31 where.remove(PluginDescriptor.WHERE_EXTENSIONSMENU)
33 if PluginDescriptor.WHERE_PLUGINMENU in where:
34 hide = config.plugins.pluginhider.hideplugins.value
35 res.extend((x for x in self.plugins.get(PluginDescriptor.WHERE_PLUGINMENU, []) if x.name not in hide))
36 where.remove(PluginDescriptor.WHERE_PLUGINMENU)
38 if PluginDescriptor.WHERE_EVENTINFO in where:
39 hide = config.plugins.pluginhider.hideeventinfo.value
40 res.extend((x for x in self.plugins.get(PluginDescriptor.WHERE_EVENTINFO , []) if x.name not in hide))
41 where.remove(PluginDescriptor.WHERE_EVENTINFO)
44 res.extend(PluginComponent.pluginHider_baseGetPlugins(self, where))
45 res.sort(key=lambda x:x.weight)
48 def autostart(reason, *args, **kwargs):
50 PluginComponent.pluginHider_baseGetPlugins = PluginComponent.getPlugins
51 PluginComponent.getPlugins = PluginComponent_getPlugins
53 PluginComponent.getPlugins = PluginComponent.pluginHider_baseGetPlugins
55 def main(session, *args, **kwargs):
56 session.open(PluginHiderSetup)
59 if menuid != "system":
61 return [(_("Hide Plugins"), main, "pluginhider_setup", None)]
63 def Plugins(**kwargs):
66 where=PluginDescriptor.WHERE_AUTOSTART,
71 where=PluginDescriptor.WHERE_MENU,