Tutorial: Write your own KFile Plugins

If you've ever wanted to get into KDE coding, but reading tens of thousands of lines of code to get familiar with one of the bigger programs was more time than you have, then you might want to check out the tutorial on KFile plugins that I've written.

For those not familiar, a KFile plugin is the meta-data magic that powers the "MetaInfo" tab when you display the properties of a file, and the Info List View in Konqueror. It's easy to write one, and there are a lot of file formats we don't have support for yet. This is a fun way to get into KDE development!

Dot Categories: 

Comments

by George Russell (not verified)

Plugins to display information on BibTex, Python, Java, and LyX files are available at http://dogma.freebsd-uk.eu.org/~grrussel/ . The code is small, simple and in need of a maintainer.

In general, textual formats are easy to support in konquerer plugins!

by Will Stephenson (not verified)

I've been using these for ages, they're very useful.

I'd assumed they'd be in kdeaddons by now, is there any reason they are not?

by Pieter (not verified)

I would be willing to do the work needed to bring these plugins into some KDE module (kdegraphics?). It seems a waste of time maintaining these modules outside the main source. If the code is not in the main distribution many users would not use the plugins (or even know they existed).

George if you want me to do this, contact me by email.

by George Russell (not verified)

Two reasons; the Java / Python plugins are hacks that do not parse Java / Python syntax but scan for keywords.

Secondly, the code has never been cleanly packaged and I no longer use KDE (its not up to scratch on OSX yet).

by Fred Schättgen (not verified)

Thanks for the tutorial, Brad :] Docs like that are more valuable
for KDE than the same amount of C++-code.

Wouldn't it be possible to use the meta info data for searching?
KDE should really provide an index based search function. The meta
data plugins could be utilized to collect data from non-textual files,
like jpeg with exif data, pdf etc. Many they could also be used for
full-text indexing.

In the end it should be something like an extended version of 'locate',
which is fast enough to use it just because one is too lazy to click
through several folders and with a UI not much more complex as google.

by Anonymous (not verified)

KFind already allows you to search the metainfo sections.

by kiriuja (not verified)

For the record, KPlayer 0.5, which is due out in just a few weeks, will come with a KFile plugin that shows metadata for any media file playable with MPlayer. One minor drawback is that it will only show metadata for file that have already been opened with KPlayer. http://kplayer.sf.net/

by Dominik Seichter (not verified)

Hi,

This is a very good tutorial and I hope it brings lot's of new file plugins to KDE.

Maybe you could add in the future a chapter how to use KFile plugins in your own application. For example my application, KRename (http://www.krename.net), uses KFile plugins to retrieve various meta informations from all kinds of files and remames them using this pieces of information. With little code I was able to add support for lot's of different file types.

CU Dom

by Brad Hards (not verified)

I'll look to add more usage details (on KFile and KFind, as they relate to the meta-data stuff) in a future version.

by John Metadata Freak (not verified)

Speaking of metadata, wouldn't it be nice if tooltips separated generic from metadata info somehow? Maybe a small horizontal line between both, or each inside a rectangle? Or at least some blank space?

by Anonymous (not verified)

Given the release of Ximian's Outlook Connector under the GPL (http://lwn.net/Articles/84494/), are there any plans to add Outlook/Exchange support to KMail and Kontact?

Just wondering...

by Thorsten Schnebeck (not verified)

Use the Exchange-server-resource of KDEPIM:

ls kdepim/kresources/
CVS Makefile Makefile.am Makefile.in egroupware exchange imap

I don't know how well evo-exchange-plugin works, but I think kdepim could benefit/learn from there implementation.

Bye

Thorsten

Novell To Release Ximian Connector Under GPL

The code is here:
http://ftp.ximian.com/pub/source/evolution/ximian-connector-1.4.7.tar.gz

Am I the only one who thinks that Kontact needs to incorporate this?

> Am I the only one who thinks that Kontact needs to incorporate this?

I think the kontact developers are already working on exchange support, and this will no doubt help them.,

by Art (not verified)

I need to things to become a happy KDE-full-time user.

a) A descent client/server groupware application. I'm wondering, why KDE PIM has no connector for OpenGroupware or Exchange (even if we hate it, it works)
b) A way to synchronize my Pocket PC running on Windows Mobile. I know there is synchronisation for Palm, but Pocket PC's are on the market and their market share is quite big.

From the day on, when KDE PIM can do groupware I'm switching. On the day, I get my Pocket PC synchronizing, I'm free. (All my Oracle tools work already under Linux :))

by Arun (not verified)

If I am writing a KFile plugin for say Java .class files, there are multiple mime types in use for them - application/java, application/java-byte-code, application/java-vm, application/x-java-class, application/x-java-byte-code - to name a few.

How do I register all of them as associated with the same plugin class? Is it by multiple calls to addMimeTypeInfo?

How about the .desktop file? Do I add multiple MimeType entries there?

by Arun (not verified)

I figured out the answers to the two questions myself.

In the .desktop, all the mime types need to be in the same MimeType entry like this:
MimeType=application/java;application/java-byte-code;application/java-vm;application/x-java;application/x-java-class;application/x-java-byte-code
I believe regular expressions are also allowed.

In the plugin class, multiple calls should be made to addMimeTypeInfo for each type and all the groups, items need to be added to each KFileMimeTypeInfo.

I have a small KFile plugin for .class files at http://arun.homeip.net/kdev/kfile_class_src.zip if anyone is interested.