This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Help on creating plugin-based app

Tags: None
(comma "," separated)
job
Registered Member
Posts
18
Karma
0

Help on creating plugin-based app

Fri May 22, 2009 2:27 pm
I'm writing an application which I want to make plugin-based. The only documentation I can find about this is at http://techbase.kde.org/Development/Tut ... es/Plugins and this tutorial doesn't describe all aspects.

My questions are:
  • How exactly do I use those export macro's?
  • I believe I have to create a .desktop file for each plugin. What do I need to specify in those and what are the naming conventions?
  • How can I incorporate plugins in cmake?
  • How can I make sure others can write plugins without having to add them to my source code?
  • Do I need to make a new ServiceType for my plugins? If yes, how?

Any help would be greatly appreciated!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

RE: Help on creating plugin-based app

Fri May 22, 2009 11:11 pm
The export macros are usually added to the class definition in the Header:
Code: Select all
class APPLICATIONTYPE_EXPORT RandomClass : public AppClass


While you do not need to use desktop files, it is the usual and least hard coded way to do it.
Code: Select all
[Desktop Entry]                                                                             
Icon=view-list-tree                                                                         
Type=Service                                                                                 
X-KDE-ServiceTypes=SystemSettingsView                                                       
X-KDE-Library=classic_mode

Where X-KDE-ServiceType is your custom service type, and X-KDE-Library is the name of the .so file that contains the plugin code.

You do not need to do anything special for plugins in CMake.
In order to allow others to write plugins, you need to provide the following:
  1. An class that provides an interface to your application which all plugins subclass
  2. A service type for desktop files to easily locate the plugins desktop files

To make things easy, I recommend creating a service type, since it will allow you to locate all plugins for your app easily. ServiceTypes are installed to $KDEDIR/share/kde4/servicetypes/ and are desktop files containing the following:
Code: Select all
trunk@grace:~/manual-source/systemsettings/core> cat systemsettingsview.desktop
[Desktop Entry]
Type=ServiceType
X-KDE-ServiceType=SystemSettingsView
Name=System Settings View


Where X-KDE-ServiceType must be the same as the X-KDE-ServiceTypes field in your plugin desktop files.

If you need any pointers, look at how I did it for System Settings:
BaseMode ( plugin interface ) and SystemSettingsView service type declaration
System Settings icon view plugin


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]