Skip to content

Writing Plugins for KDE Applications

Thursday, 25 January 2001  |  Numanee

In the first of what we hope to be an exciting series, Richard Moore has published a tutorial on how to write KPart plugins for KDE 2. In this tutorial, Richard gives us a glimpse into the power of KParts by demonstrating how simple it is to extend Konqueror with a plugin. In particular, he implements a plugin for HTML Validation, but the same mechanism could have just as easily been used to write a plugin for convenient Babelfish translation of the current webpage, or indeed something much more fancy. In general, once you understand what's here you should be able to write plugins for pretty much any application or component in KDE. The full tutorial can be found on the KDE Developer Site. This story was amended and republished at 04:00 PM. Update: 01/26 04:35 PM by N: Kurt Granroth has made available various modifications to the htmlvalidator example and, best of all, has implemented a nifty BabelFish plugin. See his article for details, download the plugins here. Update: 01/28 07:55 PM by I: As yet more proof of the power and simplicity of KParts-based plugins, Carsten Pfeiffer has created another plugin, which allows easy configuration (from a light drop-down menu) of Java, JavaScript, cookies and image loading. Thanks, Rich, Kurt and Carsten.

Comments:

Re: Writing Plugins for KDE Applications - Shawn Gordon - 2001-01-25

Way to go Richard, this is very cool.

Re: Writing Plugins for KDE Applications - Richard Moore - 2001-01-25

I aim to please ;-)

Re: Writing Plugins for KDE Applications - KDE User - 2001-01-26

One word: Amazing. I just downloaded and compiled the source code. Works like a charm. I got a new toolbar with the ABC spellcheck icon on it. The toolbar even magically goes away in FileManager mode. It's a wonderful feeling to run a browser that is as easily extendable as this. How do I add the icon ABC automatically to the main toolbar? I tried editing plugin_htmlvalidator.rc by changing mainToolBar to Main Toolbar but that didn't work. One funny thing is that the source code is only a few lines long but the Makefile stuff is hundreds of kilobytes. :-)

Re: Writing Plugins for KDE Applications - Richard Moore - 2001-01-26

> How do I add the icon ABC automatically to the > main toolbar? I tried editing > plugin_htmlvalidator.rc by changing mainToolBar > to Main Toolbar but that didn't work. The easiest way to do this is to use the standard edit toolbar dialog - the new action is fully integrated with the app framework. The size of the build system is because it uses the standard KDE scripts - I think the simplicity makes it worth the size. The same scripts can build everything from plugins to complete applications. This is perhaps a slight example of over-engineering for a 100 line program... Rich.

Re: Writing Plugins for KDE Applications - KDE User - 2001-01-26

Well, I know about that, but can I make it go to the standard toolbar by default when the user installs the plugin?

Re: Writing Plugins for KDE Applications - Nicholas Hagen - 2001-01-26

Makefiles are usually (esp KDE) automatically generated and so contain a lot of extra features, targets, etc. Theoretically, they prolly could be cut down, but it's not needed. Now a few lines of source code and a beautiful browser with extensible features is what is wonderful as that is a great combonation that I love to see. Keep up the work KDE!

Re: Writing Plugins for KDE Applications - Chucky / Outmax! - 2001-01-26

I'm pleased to see that I had to wait for KDE 2, but not for a bad WM ! It's really great ! It's perhaps more easy to add parts to the "explorer" under KDE in C++, than under Windows, with VB ;-) I wish a long life to the KDE Project !

Re: Writing Plugins for KDE Applications - Soknet - 2001-01-26

Amen!

Re: Writing Plugins for KDE Applications - Gunnar Johannesmeyer - 2001-01-26

Thats true... great work.

Re: Writing Plugins for KDE Applications - steve_qui - 2001-01-26

Gnome what is your answer yet?

Re: Writing Plugins for KDE Applications - ac - 2001-01-26

Writing Bonobo components is just as easy.

Re: Writing Plugins for KDE Applications - ac - 2001-01-26

Dispite how you guys all hate CORBA because it's "complex" and "bloated" and "slow", Gnome's implementation is not. It's a fact, so face it.

Re: Writing Plugins for KDE Applications - Thomas - 2001-01-26

? ? ? o.k. .... we face it :)

Re: Writing Plugins for KDE Applications - kde-rules - 2001-01-26

LOL!!!!!!!!!!!!!!!!!

Re: Writing Plugins for KDE Applications - kdeguy - 2001-01-26

oh, stop this nonesense. bonobo is pretty good.

Re: Writing Plugins for KDE Applications - brandon - 2001-01-30

GNOME has bonobo, KDE has kparts. Deal with it. I'm sure there are advantages and disadvantages to both. What's the point it starting a GNOME vs. KDE war every time a GNOME or KDE technology is in a news item? Whatever works for you, use it! Might as well just end this thread, because it'll never accomplish anything claiming which technology is better. -Brandon

Re: Writing Plugins for KDE Applications - Helmut Zechmann - 2001-01-26

I have tried out the libhtmlvalidatorplugin form the tutorial. After installation there was no entry for the plugin in the tools menu of konqueror. After I changed the line kpartgui name="htmlvalidator" library="libhtmlvalidatorplugin" to kpartgui name="htmlvalidator" library="libhtmlvalidatorplugin" <B>version="1"</B> in plugin_htmlvalidatior.rc it worked.

Re: Writing Plugins for KDE Applications - KDE User - 2001-01-26

Strange. For me I didn't have a problem with KDE 2.1 beta2 as it worked out of the box. Perhaps Rich knows what's going on.

Changes to example + Babelfish plugin - Kurt Granroth - 2001-01-26

After reading Rich's excellent tutorial, I was inspired to hack around for a bit. I downloaded the tutorial and starting cleaning things up. For instance: <p> <ul> <li>BUGFIX: Put the ToolBar container outside of the MenuBar container. This was why the action created it's own toolbar instead of appending to an existing one.</li> <li>BUGFIX: Put the toolbar action inside of "extraToolBar" instead of "mainToolBar" since that's what the extra toolbar is for.</li> <li>CLEANUP: Got rid of a lot of the old KDE 1.x 'configure' and 'automake' stuff and replaced with new and improved KDE 2.x stuff.</li> <li>OTHER: Created a 16x16 and 22x22 icon just for the validator</li> <li>OTHER: Changed some references of 'spellcheck' to 'htmlvalidator'</li> <li>OTHER: Changed '"&amp;Validate Web Page (plugin)"' to 'i18n("&amp;Validate Web Page")' since no other plugin claims to be a plugin AND it's always good practice to use i18n.</li> </ol> <p> But while I was doing that, I wondered how easy it would be to create a plugin to do page translation as suggested in the above article. The result was the 'babelfish' plugin. It puts a KActionMenu list of all of BabelFish's translations (English to French, etc) in the menubar and toolbar. It's pretty slick. <p> I'm not 100% sure what to do with all this so for now, I just put it up on the web for anybody to get:<br> <a href="http://devel-home.kde.org/~granroth/plugins-0.2.tar.bz2">http://devel-home.kde.org/~granroth/plugins-0.2.tar.bz2</a>

Re: Changes to example + Babelfish plugin - Richard Bos - 2001-01-26

<p>thanks a lot for your quick improved sources. The ones provided by Richard let my konqueror crash. Really excellent</p> <p>Just wundering would another plugin be able to interact with the <a href=http://dot.kde.org/979681957>KDE.com Offers Free Docbook Compilation Service</a>?<br><br> </p>

Re: Changes to example + Babelfish plugin - Rob kaper - 2001-01-27

<i>I'm not 100% sure what to do with all this so for now, I just put it up on the web for anybody to get:</i> <p> Seems to me that these might not look bad in CVS or perhaps at www.konqueror.org. Or even better, just like kde.themes.org offers themes, there should be a repository for handy plugins once more follow, no?

Re: Changes to example + Babelfish plugin - Marcus Camen - 2001-01-27

I suggest to put at least the Babelfish plugin in CVS (after the freeze) for KDE 2.2

Re: Writing Plugins for KDE Applications - Michael - 2001-01-26

Would it make sense to write a cd-writer plugin for konquerer? Or how should something like this look like?

No, it would NOT make sense - Moritz Moeller-Herrmann - 2001-01-27

What you want is called UDF, half implemented for linux already. (packet-cd available here: http://packet-cd.sourceforge.net) You can the use cdrom-RWs like floppies. What do you need a cd writer pluginsfor? For music CDs you can't use file manager anyways, you need more settings, than you can put into a plugin.

Re: No, it would NOT make sense (but Apple...) - Jason Katz-Brown - 2001-01-28

Um, apple has implemented it where the cdr is an icon on desktop, u open it, makes a normal window, u drag stuff on to it, then u throw icon in trash and it asks u if u want to burn it. Sounds kinda stupid tho, i agree with Moritz Moeller-Herrmann :) Jason

Re: YES I think it would make sense - Michael - 2001-01-29

I want to have a filemanager, were I can do the following: * I drag the cdrom-icon onto the cd-rw icon and the CD gets copied. * I drag a file onto the cd-rw folder and it asks whether I want to create a music/data cd. And this has to be done in the filemanager: * it's about files * you have a filemanger, which replaces netscape, ghostview,... but can't even get along with /cdrw,.... that can't be! It has to satiesfy all my needs related to the filetree!

Re: Writing Plugins for KDE Applications - Kirby - 2001-01-27

Excellent. And it looks way better than the ugly Gnome UI.

Yeah right - Anonymous - 2001-01-27

So Gnome looks ugly? Ha! Have you seen this yet: http://www.jaded.org/screenshots/2001_01_21_041006_shot.jpg

Re: Yeah right - Anonymous - 2001-01-27

<p>OK, that's a nice screenshot. All right, very nice. But it has one serious flaw; the maximize/minimize/close buttons in inactive windows looks disabled (grey). There is no reason they should be -- you can use them, can't you?</p> <p>And Gnome's triangular back/forward buttons <em>are</em> ugly. And so are KDE's blue arrows...</p>

Re: Yeah right - Spark - 2001-01-29

no, there is no need to make the buttons active. with the same reason you could draw everything of the border active, but that would be quite senseless. ;) i like it that way.

Re: Yeah right - KDE User - 2001-01-27

That's very nice. Their panel is looking more and more like Kicker. In fact the whole desktop looks very much like KDE now except the icons look more multimedia-ish if you know what I mean. Are there any themes like this for KDE?

Re: Yeah right - not me - 2001-01-28

That's a very nice window border theme in that shot. It reminded me that I have not seen ANY kwm themes out there. Have I been looking in the wrong places, or are there really no themes out there except for the ones that come with KDE? I've seen some widget themes on kde.themes.org, but no window manager themes.

Re: Yeah right - Joe KDE User - 2001-01-31

Hm, I assumed you would post a screenshot making gnome look good, but you just posted something pretty ugly. The windowmanager sucks (who wants their close box near maximise/minimise, that's asking for trouble), the gtk 'theme' is less than inspired, and the panel looks like a chintzy kicker ripoff. I would be ashamed to have that as my desktop.

Re: Writing Plugins for KDE Applications - robert - 2001-01-28

Try using a theme on the ugly GNOME UI.

Re: Writing Plugins for KDE Applications - gis - 2001-01-28

Thanks Rich,<br><br> due to your nice tutorial I finally implemented qwertz' suggestion to configure Java/Javascript/Cookies/Image loading in a small dropdown menu, so you don't have to open the config-dialog for those often-changed settings. <br><br> Grab the plugin <a href="http://devel-home.kde.org/~pfeiffer/khtmlsettingsplugin-0.1.tgz">here</a>. For the cookie settings to work, you need a current kdelibs snapshot (beta2 is not sufficient), but the other settings should work just fine with 2.0. <br><br> Cheers,<br> Carsten

Re: Writing Plugins for KDE Applications - guran - 2001-01-29

Thanks to you programmers, what a nice world you create. An old man's wish; a plugin that brows' all the man-, info- and docu pages. Beatiful thanks guran

Re: Writing Plugins for KDE Applications - caatje - 2001-01-29

khelpcenter can do that IIRC.

Re: Writing Plugins for KDE Applications - steve - 2001-01-29

please try.... open konqueror typ in the url-field man:mount it's a cool feature......

Re: Writing Plugins for KDE Applications - Spark - 2001-01-29

hey, that even works with galeon! :) gnome and kde both rock.

Re: Writing Plugins for KDE Applications - anon - 2001-01-30

Anyone knows any __SIMPLE__ example of plugin app + ex. plugin? or is willing to write one?

factory name - jimmy - 2005-04-15

Is it necessary for the plugin's factory method to be called 'create ()'?