The fileicons package provides a simple and convenient way to display file information with an icon in a Tk GUI. When loaded, the package will retrieve icons for specific file extensions and/or type (directories, executable files, etc.). The package is also easily extended if you want to ship a different icon theme than the base packages. The fileicons package allows developers to provide a richer GUI without taking the trouble to assemble their own icon/mimetype theme.
The fileicons package is called by the invocation package require fileicons, and defines two commands:
fileicons::setTheme {theme}: The fileicons::setTheme command loads a specific icon theme, and takes a theme name as an argument. The package ships with two base themes, "kde" and "tango".
fileicons::getImage {filename}: The fileicons::getImage command fetches the icon for a specific file, and takes a file path name as an argument. If an icon for the specific file type or extension is contained in the theme, that icon will be displayed. If not, a generic file icon will be displayed.
The most common use case for the fileicons package would likely be in file system displays, for instance with the BWidgets listbox or tree widgets, or the Tablelist display.
Defining your own themes to use with the fileicons package is easy:
All images should be 16x16 .gif files.
Create a directory with the theme name.
Choose images from your theme to represent a directory, a generic file, and an executable file; save these in .gif format under the names "folder.gif," "file-generic.gif," and "executable.gif." Copy these images to the top level of your theme directory.
Create a subdirectory called "mime." Place all other images from your theme in this directory. These images should be saved under names that correspond to standard file extensions and specialized extensions that you want to display. For instance, an image that displays an icon for a .jpeg file should be saved as "jpeg.gif" and an image that displays an icon for a .doc file should be saved as "doc.gif." You can save as many or as few images as you want in the mime directory; the fileicons package will display a default "file-generic" image for any file type that is not otherwise included in the package. However, if you want to be reasonably comprenhensive, you should include a larger number of images in the mime directory. You should also try to be consistent in choosing images for similar file types; for instance, it makes sense to use a photo-style image for .tiff, .jpeg, .gif, .png, and other image-type files.
To see how the fileicons package works, download the package and install on your auto_path. Then run the "demo-tango.tcl" or "demo-kde.tcl" scripts. (The demos require BWidgets to be installed, but the fileicons package itself does not have any external dependencies.)
The fileicons package is licensed under the same license as Tcl/Tk itself. See http://www.tcl.tk/software/tcltk/license.html for the current license.
The "kde" icon theme, derived from the KDE Classic (hicolor/locolor) theme, is freely reusable under these terms: "The images inside this directory are COMPLETELY FREE for commercial and non-commercial use." For more detail, see http://kde-artists.org/node/110. Some icons in this theme are also derived from the "BlueSphere" icon set (http://svgicons.sourceforge.net), which is available under a BSD-style license.
The "tango" icon theme, derived from the Tango Icon project (http://tango.freedesktop.org/Tango_Desktop_Project), are licensed under a Creative Commons Attribution-Sharealike license (http://creativecommons.org/licenses/by-sa/2.5/).
| Copyright (C) 2006 Kevin Walzer. All rights reserved. All trademarks are the properties of their respective holders. |