5
5
plugin for KIPI, and how to add KIPI support to a new
6
6
application (referred to as host application).
8
You can find more information about KIPI at this <a
9
href="http://wwww.digikam.org/docs">url</a>.
11
This documentation has been writen by Gilles Caulier.
13
<h1>Developing a New Plugin</h1>
15
The easiest way to start a new plugin, is to copy the
16
<a href="https://projects.kde.org/projects/extragear/graphics/kipi-plugins/repository/revisions/master/show/tests/helloworld">
17
HelloWorld</a> plugin, which you may find in <a
18
href="https://projects.kde.org/projects/extragear/graphics/kipi-plugins">
19
kipi-plugins</a> project from KDE git repository. Please also read <a
8
This documentation has been writen by Gilles Caulier and has been updated
9
and improved by Victor Dodon.
11
<h1>General information about libkipi 2.0.0</h1>
13
Starting with 2.0.0 version of libkipi shared library, Plugin class
14
inherits KXMLGUIClient class. This means that if your application uses
15
KDE-XML GUI, you can add plugin actions to the toolbar(if you add plugins to
16
the guiFactory of you KXMLGuiWindow). For more documentation about KDE-XML
17
GUI you can look <a href="http://techbase.kde.org/Development/Architecture/KDE4/XMLGUI_Technology">here</a>.
19
<h2>Developing a new KIPI plugin</h2>
21
The easiest way to start a new plugin, is to copy the
22
<a href="https://projects.kde.org/projects/kde/kdegraphics/libs/libkipi/repository/show/tests/kxmlhelloworld?rev=development%2F2.0.0">
23
KXMLHelloWorld</a> plugin, which you may find in <a
24
href="https://projects.kde.org/projects/kde/kdegraphics/libs/libkipi">
25
libkipi</a> project from KDE git repository. Please also read <a
20
26
href="http://www.ukuug.org/events/linux2004/programme/paper-JPedersen-2/index.html">
21
27
this tutorial</a> which tells in general about developing a plugin
22
28
structure for an application, but it also gives some background
23
29
information on how plugins are loaded, and especially on the macros
24
30
involved. The tutorial has been written by one of the KIPI authors, so
25
it matches fairly good the model of KIPI (except the part on merging
31
<h2>General Things to do to Implement a Plugin</h2>
31
it matches fairly good the model of KIPI.
37
<h2>General things to do to implement a KIPI plugin</h2>
33
39
Here is a list of things to do.
35
41
<li> Create a class that inherits KIPI::Plugin. In the constructor you
36
42
must create instances of KAction for your application. The topmost
37
actions should be given to the Plugin super class using
38
KIPI::Plugin::addAction().
43
actions should be given to the Plugin super class using KIPI::Plugin::addAction().
39
44
<li> As described in the tutorial <a href="http://www.ukuug.org/events/linux2004/programme/paper-JPedersen-2/index.html#understanding_loading">here</a>, you must call KDE macros
40
45
<tt>K_PLUGIN_FACTORY</tt> and <tt>K_EXPORT_PLUGIN</tt>.
41
46
<li> You also need to create a desktop file, as described <a href="http://www.ukuug.org/events/linux2004/programme/paper-JPedersen-2/index.html#makefile_am_client">here</a>
47
<li> You must write a rc file describing the gui of your plugin. For an
48
example look at the <a href="https://projects.kde.org/projects/kde/kdegraphics/libs/libkipi/repository/entry/tests/kxmlhelloworld/plugin/kipiplugin_kxmlhelloworldui.rc?rev=development%2F2.0.0">rc
49
file</a> of the KXMLHelloWorld plugin.
48
<h2>Retrieving Information from the Host Application</h2>
56
<h2>Retrieving information from the KIPI host application</h2>
50
58
The above was the required step to build the plugin. The following will
51
59
tell you about the functions with which you communicate with the host
54
62
The origin of all your communication with the host application is
55
63
\ref KIPI::Interface. You obtain a pointer to this by casting the parent
56
pointer given to your plugin during construction.
64
pointer given to your plugin during construction, or, beginning with libkipi
65
2.0.0, by calling interface() method from KIPI::Plugin class.
58
67
Selection of images can be obtained using
59
68
KIPI::Interface::currentSelection(), KIPI::Interface::currentAlbum() and
63
72
Finally to obtain information about individual images, call
64
73
KIPI::Interface::info(), which returns a KIPI::ImageInfo, with the
65
information. Note that Kipi-plugins provide a dedicated wrapper around KIPI::ImageInfo
66
to simplify item attribute management with host application. See
74
information. Note that Kipi-plugins provide a dedicated wrapper around KIPI::ImageInfo
75
to simplify item attribute management with host application. See
67
76
<a href="https://projects.kde.org/projects/extragear/graphics/kipi-plugins/repository/revisions/master/entry/common/libkipiplugins/tools/kpimageinfo.h">
68
77
here</a> for details.
70
79
When developing plugins, you should pay special attention to the fact the different
71
80
host applications may have different feature sets they
72
81
support. Information about what the host application support can be
73
obtained from KIPI::Interface::hasFeature(). See also extra settings that can be shared
74
by KIPI host application. Kipi-plugins provide a dedicated wrapper around KIPI::Interface to
75
simplify host settings management. See
82
obtained from KIPI::Interface::hasFeature(). See also extra settings that can be shared
83
by KIPI host application. Kipi-plugins provide a dedicated wrapper around KIPI::Interface to
84
simplify host settings management. See
76
85
<a href="https://projects.kde.org/projects/extragear/graphics/kipi-plugins/repository/revisions/master/entry/common/libkipiplugins/tools/kphostsettings.h">
77
here</a> and <a href="https://projects.kde.org/projects/extragear/graphics/kipi-plugins/repository/revisions/master/entry/common/libkipiplugins/tools/kpmetasettings.h">
86
KPHostSettings</a> and <a href="https://projects.kde.org/projects/extragear/graphics/kipi-plugins/repository/revisions/master/entry/common/libkipiplugins/tools/kpmetasettings.h">
87
KPMetaSettings</a> for details.
90
99
<li> KIPI::Interface::thumbnail() helps you load thumbnails of images from KIPI host thumbnail manager.
91
100
<li> KIPI::Interface::progress*() helps you dispatch progress information to KIPI host progress manager.
92
101
<li> <a href="https://projects.kde.org/projects/extragear/graphics/kipi-plugins/repository/revisions/master/show/tests">
93
kipicmd command line program</a> helps you to test your plugin without to have a KIPI host application available.
94
It emule a simplified KIPI interface and can run plugin as stand-alone application.
102
kipicmd command line program</a> helps you to test your plugin without to have a KIPI host application available.
103
It emulates a simplified KIPI interface and can run plugin as stand-alone application.
95
104
Look kipicmd command line documentation for details.
105
<li> Beginning with libkipi 2.0.0 you have a simple gui program,
106
<a href="https://projects.kde.org/projects/kde/kdegraphics/libs/libkipi/repository/show/tests?rev=development%2F2.0.0">kxmlkipicmd</a>,
107
which emulates a simplified KIPI interface with a menubar and a toolbar. This
108
way you can test the gui of your plugin.