These are initial, rough considerations for the implementation.
Thunar data will be presented by implementing the GtkTreeModel. On-top
of this, there will be the ExoIconView and the GtkTreeView (as list
view). The optional tree view pane needs a tree model backend as well, and
we need a unified design for the backend code.
Initial implementation ideas for certain aspects of the file manager. Some of them contain sample code already.
Its very important to reduce disk seeks (notably stat()s and file content
accesses). For the MIME detection, the file manager should probably even
skip the magic-detection and use only the glob-detection (problem here, is
that we need to grab the first 256 bytes anyways to detect if the file in
question is a text file, as the fallback).
When writing code, try to avoid bugs as much as possible. This includes, always
compiling with warnings enabled (-Wall) and let the compiler treat warnings
as errors (-Werror). Make heavy use of the
Message
Output and Debugging Functions provided by GLib. There are some other points
that can help to avoid bugs from day one (already proven to work in other projects
like xfce4-session - no critical implementation bugs during the 4.2 release phase! -
and Terminal), and I’ll write down some notes about this at a later time. Others
may also have some interesting tips, if so, feel free to send them to the
thunar-dev mailinglist.
Fortunately, the Shared MIME Database Specification is well-thought, so there’s
enough room for optimization on the implementors side. The most important point
is to optimize the common case - the glob-detection - as much as possible. The
most common case of a glob is *.EXT, an extension with 3 ASCII characters.
Here the comparison can be speed up using a 32bit integer for the comparison
instead of performing a comparison by character.
The filer repository contains samples of other optimizations.
ExoIconView can be optimized to avoid the time-consuming relayout calls.
This requires changing most of the internals (sample code exists).
Thunar should preload all mimetype icons and create a hash-table with mimetype → icon for easy lookup when loading a directory. This will add some memory overhead, but might add some speed.
A sample implementation of the many of the above requirements exists in the
CVS repository, the module name is filer. It should be noted, that this
is really just sample code, which should be considered of prototype quality,
but not production quality.
Some sample implementations are available online: