ThumbCreators

Introduction

Sometimes, a user may go searching for a document containing particular items of content which reside in a file of uncertain type. The document may have a complex structure or binary encoding which makes it difficult to searching for using text based tools; or perhaps the content type is not well-supported in search tools. In such cases, it is often more convenient for the user to browse directories of files, looking for familiar filenames or groups of files. However, the approach becomes impractical when the user is faced with a large number of similar files, as the user may need to individually open and view each file in turn to determine whether it is relevant.

Many file managers are now able to alleviate this problem by providing icon-size previews of the contents of files in a directory display. Konqueror can display such thumbnail previews of common image, media and document types and, fortunately for those of us interested in less mainstream formats, the infrastructure of KDE allows us to create plugins to display these, too.

Requirements

One of the simpler forms of KDE plugin, a ThumbCreator plugin requires only the basic items to be present:

For a Python ThumbCreator, the source code will be accommodated in a directory created in either the $KDEDIR/share/apps directory or the $HOME/.kde/share/apps directory.

Constructing a ThumbCreator

The build process will, as usual, take care of the library construction, requiring only that the developer takes care to specify the name of the Python class which is used to generate images.

Examples

Two simple examples are provided to demonstrate this type of component:

ShellPreview

This example is hardwired to execute a particular utility using a system call; by default the sk2ppm tool is used to convert Sketch/Skencil drawings into .ppm files for display as thumbnails. Fortunately, the QImage object passed to the ThumbCreator is able to interpret this file format.

SpritesPreview

Requiring more computational effort than the previous example, this ThumbCreator reads Acorn (or RISC OS) Spritefiles and prepares an arbitrary image found within for use as a thumbnail.

Unfortunately, due to unresolved dynamic linking issues, the Python Imaging Library is not available for use in this environment, leaving the component to generate a .ppm file from within Python. Hopefully, this sort of problem will be resolved for future releases.

You will need to have installed the spritefile module to be able to use this component; this can be found at

    http://www.boddie.org.uk/david/Projects/Python/Spritefile/