Creating Additional Plugins |
Prev | Next |
Table of Contents
WARNING: This section was written for Kst version 1 and may be somewhat, or even totally obsolete. WARNING
Kst has a simple and standardized interface that facilitates easy creation of additional plugins. In addition to detailing basic requirements for plugins, the following sections describe how to make use of pre-written header files to create certain types of plugins.
A Kst plugin consists of two files—a KDE desktop service file and a shared object file.
The KDE desktop service file provides information about the plugin to the Kst plugin loading infrastructure. The following is an example of a KDE desktop service file for a Kst plugin:
[Desktop Entry] Encoding=UTF-8 Type=Service ServiceTypes=Kst Data Object X-KDE-ModuleType=Plugin X-KDE-Library=kst_FOO_plugin X-Kst-Plugin-Author=FOO Name=FOO Plugin Comment=The FOO algorithm for Kst.
Generally, you can use the example above as a template and modify the FOO entries to fit your plugin.
As can be seen from the example, the desktop service file consists of a series of key value pairs. The
ServiceTypes
entry should be left as seen above. This key indicates that the plugin inherits
the KstDataObject class. See the API documentation for the interfaces this class exposes. The
X-KDE-Library
key points to the shared object file that implements your plugin. Do not
include the shared object's file extension.
Once you have completed the desktop file, save it as [X-KDE-LIBRARY].desktop
, where
[X-KDE-LIBRARY]
is the value of the key in the desktop file.
The shared object file contains the actual functionality of the plugin. The following are the requirements for the shared object file:
The object must inherit the KstDataObject class:
#ifndef FOOPLUGIN_H #define FOOPLUGIN_H #include <kstdataobject.h> class FooPlugin : public KstDataObject { Q_OBJECT public: FooPlugin(QObject *parent, const char *name, const QStringList &args); virtual ~FooPlugin(); virtual KstObject::UpdateType update(int); virtual QString propertyString() const; virtual KstDataObjectPtr makeDuplicate(KstDataObjectDataObjectMap&); protected slots: virtual void _showDialog(); }; #endif
The following is an example of the shared object file source code for a simple plugin:
If you are using gcc to compile your plugin, simply compile the object file:
cc -Wall -c -o myplugin.o myplugin.c -fPIC -DPIC
and then create the shared library:
ld -o myplugin.so -shared myplugin.o
The resulting *.so
file and *.xml
file must be put in the same
directory. When you use Kst's Plugin Manager to load the XML file, it will automatically look for the
shared object file in the same directory.
Prev | Contents | Next |
Licensing | Up | Creating Linear Fit Plugins |