KParts.Plugin

KDE 4.2 PyKDE API Reference

- KDE's Python API

# Plugin Class Reference

`from PyKDE4.kparts import *`

Inherits: QObject,KXMLGUIClient
Namespace: KParts

## Detailed Description

A plugin is the way to add actions to an existing KParts application, or to a Part.

The XML of those plugins looks exactly like of the shell or parts, with one small difference: The document tag should have an additional attribute, named "library", and contain the name of the library implementing the plugin.

If you want this plugin to be used by a part, you need to install the rc file under the directory "data" (KDEDIR/share/apps usually)+"/instancename/kpartplugins/" where instancename is the name of the part's instance.

You should also install a "plugin info" .desktop file with the same name.

See also:
  KPluginInfo

For a tutorial on how to write plugins, see http://developer.kde.org/documentation/tutorials/developing-a-plugin-structure/index.html#developing_plugins

## Methods
| __init__ (self, QObject parent=0)
QString | localXMLFile (self)
| setComponentData (self, KComponentData instance)
QString | xmlFile (self)
## Static Methods
KParts.Plugin | loadPlugin (QObject parent, QString libname)
| loadPlugins (QObject parent, KComponentData instance)
| loadPlugins (QObject parent, [KParts::Plugin::PluginInfo] pluginInfos)
| loadPlugins (QObject parent, [KParts::Plugin::PluginInfo] pluginInfos, KComponentData instance)
| loadPlugins (QObject parent, KXMLGUIClient parentGUIClient, KComponentData instance, bool enableNewPluginsByDefault=1, int interfaceVersionRequired=0)
[KParts::Plugin::PluginInfo] | pluginInfos (KComponentData instance)
[KParts::Plugi] | pluginObjects (QObject parent)

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent=0
| ) |  |  |

KParts.Plugin loadPlugin | ( | QObject | parent,
|  | QString | libname
| ) |  |  |

Internal:

Returns:
  The plugin created from the library libname

loadPlugins | ( | QObject | parent,
|  | KComponentData | instance
| ) |  |  |

Load the plugin libraries from the directories appropriate to instance and make the Plugin objects children of parent.

It is recommended to use the last loadPlugins method instead, to support enabling and disabling of plugins.

loadPlugins | ( | QObject | parent,
|  | [KParts::Plugin::PluginInfo] | pluginInfos
| ) |  |  |

Load the plugin libraries specified by the list docs and make the Plugin objects children of parent .

It is recommended to use the last loadPlugins method instead, to support enabling and disabling of plugins.

loadPlugins | ( | QObject | parent,
|  | [KParts::Plugin::PluginInfo] | pluginInfos,
|  | KComponentData | instance
| ) |  |  |

Load the plugin libraries specified by the list pluginInfos, make the Plugin objects children of parent, and use the given instance.

It is recommended to use the last loadPlugins method instead, to support enabling and disabling of plugins.

loadPlugins | ( | QObject | parent,
|  | KXMLGUIClient | parentGUIClient,
|  | KComponentData | instance,
|  | bool | enableNewPluginsByDefault=1,
|  | int | interfaceVersionRequired=0
| ) |  |  |

Load the plugin libraries for the given instance, make the Plugin objects children of parent, and insert the plugin as a child GUI client of parentGUIClient.

This method uses the KConfig object of the given instance, to find out which plugins are enabled and which are disabled. What happens by default (i.e. for new plugins that are not in that config file) is controlled by enableNewPluginsByDefault. It can be overridden by the plugin if it sets the X-KDE-PluginInfo-EnabledByDefault key in the .desktop file (with the same name as the .rc file)

If a disabled plugin is already loaded it will be removed from the GUI factory and deleted.

If you change the binary interface offered by your part, you can avoid crashes from old plugins lying around by setting X-KDE-InterfaceVersion=2 in the .desktop files of the plugins, and passing 2 to interfaceVersionRequired, so that the old plugins are not loaded. Increase both numbers every time a binary incompatible change in the application's plugin interface is made.

This method is automatically called by KParts.Part and by KParts.MainWindow.

See also:
  PartBase.setPluginLoadingMode, PartBase.setPluginInterfaceVersion

If you call this method in an already constructed GUI (like when the user has changed which plugins are enabled) you need to add the new plugins to the KXMLGUIFactory:

     if( factory() )
     {
       const QList<KParts.Plugin *> plugins = KParts.Plugin.pluginObjects( this );
       foreach ( KParts.Plugin * plugin, plugins )
         factory()->addClient( plugin );
     }

QString localXMLFile | ( |  | self ) |

Reimplemented for internal reasons

[KParts::Plugin::PluginInfo] pluginInfos | ( | KComponentData | instance
| ) |  |  |

Look for plugins in the instance's "data" directory (+"/kpartplugins")

Returns:
  A list of QDomDocument s, containing the parsed xml documents returned by plugins.

[KParts::Plugi] pluginObjects | ( | QObject | parent
| ) |  |  |

Returns a list of plugin objects loaded for parent. This functions basically calls the queryList method of QObject to retrieve the list of child objects inheriting KParts.Plugin .

setComponentData | ( | self, |
|  | KComponentData | instance
| ) |  |  |

QString xmlFile | ( |  | self ) |

Reimplemented for internal reasons