The recent thread about a GnomeURIEntry ended without a real conclusion
about autocompletion.

I have decided to take Galeon's autocompletion classes, clean them up a
bit and post them here. I'm looking for a sponsor to add this to LibEgg,
if there is interest.

The current code is here:

And a patch for the makefiles:

If there is interest in developing this I'll continue cleaning up the
code and documenting it. I have written a small README (attached), but I
don't think that it makes a lot of sense yet.

I think that having this as part of libgnomeui is a good idea, to avoid
code duplication and inconsistencies between Galeon, Nautilus... and any
other Gnome app or component that needs autocompletion (like the future
file selection dialog).

The test program provides autcompletions using GnomeVFS.

I want to hear about any problem with respect to accessibility or
usability. Also, the api can be improved.


Ricardo Fernández Pascual
ric users sourceforge net
Murcia. España.
* The Egg Autocompletion framework

** Introduction

This set of classes provide everything needed to add autocompletion
functionality to GnomeEntry.

This is based in the URL entry of Galeon. That entry has proved to be
useful already in Galeon 1 and it was rewritten and improved for
Galeon 2. It is already used in Galeon 2. Some changes have been made
to allow easy keyboard navigation and possibly more changes will be
made to improve its usability and accessibility.

The design allows enough flexibility so that the same widget could be
used as a generic file entry box, an URI entry (as it is used in
galeon) or anything else that could have autocompletion. It's very
easy to implement new autocompletion sources. Here, I provide one that
uses GnomeVFS to explore filesystems, but there are another two
already implemented in Galeon (based on history and bookmarks).

This design has proved to scale enough well to handle huge history
files in Galeon with reasonable interactive performance.

** Overview of the classes

You will need to look at the header files (at least) to make sense of

*** EggAutocompletionSource (interface)

An autocompletion source is anything that can provide suggestions to
the user. Galeon history is an autocompletion source, and the
filesystem is another example. The EggFilesystemAutocompletion
implements this interface using GnomeVFS.

An EggAutocompletionSource is notified when the autocompletion key
(what the user is typing) changes. It can then search for matches in
the background, like the EggFilesystemAutocompletion.

Implementors should not do the matching here, the class
EggAutocompletion will do it correctly.

When EggAutocompletion needs to build a list of completions it will
call egg_autocompletion_source_foreach for all its sources. That
function should be as fast as possible, otherwise the interface will
be sluggish. That function should call the provided callback for
possible completion.

The EggAutocompletionSource must warn the EggAutocompletion when the
set of completions changes, especially when the strings passed are
modified or freed (otherwise things will crash).

*** EggAutocompletionEntry

This is the widget that will have the autocompletion. It implements
GtkEditable, so it can be easy manipulated as any other entry.

The user has to create a EggAutocompletionEntry and a
EggAutocompletion and the call

It allows to enable or disable the autocompletion (automatically
adding text to the entry) and enable or disable showing the list of
possible completions. If both things are disabled it acts as a
standard GnomeEntry.

*** EggAutocompletion

This class does the matching and sorting of completions. The
EggAutocompletionEntry sets the key and it and the
EggAutocompletionWindow requests completions when needed.

It can automatically add some prefixes when matching entries. For
example, in galeon it adds "http://"; and other prefixes.

It can use one or several completion sources at the same time.

Matches are sorted by score (and then alphabetically). The scoring
function is calculated by the EggAutocompletionSource. For example, in
Galeon it is based in how old the history item is or how often it is

*** EggAutocompletionWindow

This class shows a list of available completions and allows selecting
one of them. It's used by the EggLocationEntry and it is not supposed
to be used alone.

*** EggFilesystemAutocompletion

This class implements an autocompletion source using GnomeVFS. It
builds a list of possible completions in the background using
asynchronous operations.

It can have a base URI to start searching and it allows filtering
files using a callback.

 LocalWords:  autocompletion filesystems  http EggLocationEntry GnomeEntry
 LocalWords:  EggAutocompletionEntry EggAutocompletion GnomeVFS filesystem
 LocalWords:  EggAutocompletionSource EggFilesystemAutocompletion foreach
 LocalWords:  GtkEditable EggAutocompletionWindow LocalWords

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]