Re: Adding Dictionary Sources to gnome-dictionary
- From: Emmanuele Bassi <ebassi gmail com>
- To: gnome-utils-list gnome org
- Subject: Re: Adding Dictionary Sources to gnome-dictionary
- Date: Sun, 15 May 2011 11:21:03 +0100
On 2011-05-12 at 16:09, Erick Pérez wrote:
> I'm writing because I want to help develop gnome-dictionary module
> inside gnome-utils package, and I've reading code, and devhelp
> documentation but I feel I still missing something.
> Is there any other documentation available, any diagrama, anything at
> all, that can clear me the things a little bit.
> For example If I want to add a new source, should I create a new
> gobject implementing GDictContext, or a new GDictSource ?
> or I should write a new GDictSource that calls internally a new class
> implementing GDictContext ?
> How the pieces fit together ?
> How GDictSource GDictContext, GDicClientContext fits together ?
the current design of libgdict is as follows:
• GdictContext is an interface for communicating with dictionary
services. the only implementation is GdictClientContext, which
implements the DICTD client protocol for querying dictionary
• GdictSource is an object mapping to a source definition file;
a Source is responsible for creating a GdictContext from a
source definition file, and for storing changes in the context
properties to that file. the Source has a "transport" — the type
of communication method for querying and retrieving definitions
and matches from a given service. the only existing transport
currently is "dictd". if a new GdictContext implementation is
added to libgdict then a new transport enumeration value must
be added to GdictSource.
if you want to add a new type of dictionary source, you'll have to
create a new object implementing the GdictContext API, i.e.:
• get_databases() — an asynchronous method that should return
immediately, and emit the ::database-found signal for each
found database, or emit the ::error signal in case of error;
• get_strategies() — an asynchronous method that should return
immediately, and emit the ::strategy-found signal for each
found strategy, or emit the ::error signal in case of error;
• match_word() — an asynchronous method that should return
immediately, and emit the ::match-found signal for each
match found, given the database and the matching strategy,
or emit the ::error signal in case of error;
• define_word() — and asynchronous method that should return
immediately, and emit the ::definition-found signal for each
definition found in the given database, or emit the ::error
signal in case of error.
the implementation should be wholly asynchronous, and either use
threads or the GLib main loop to perform potentially blocking
operations. all signals should be emitted in the main loop, to allow
widgets to display the data retrieved.
once an implementation is done, a new GdictSourceTransport enumeration
should be added, and GdictSource should be modified to handle its
serialization and deserialization to and from a key/value file; also,
GdictSource should be modified to create a GdictContext for the given
the rest of the Gdict library uses only the GdictSource and GdictContext
API, so that's all that should be needed; the only bit in the Dictionary
application that knows about GdictContext implementations is the
SourceDialog, because it has to show widgets for the properties. it
should really be re-written to use GParamSpec* and generic property
introspection code instead.
in reality, though, the whole libgdict should be deprecated; the plan
for 3.2 is to drop the DICTD protocol and use Wikipedia and Wiktionary
instead, given that there aren't nearly enough dictionaries and
dictionary servers kept up to date and covering the amount of languages
Gnome is translated into — and Wikipedia is the only project big enough
and open enough to give us decent results. the way Wikipedia works for
non-web clients like a browser is through a RESTful API that returns
results for search queries; we can then use a WebKitGtk view to display
those results, as well as directly render Wikipedia pages from the
to return to your predicament: what kind of new dictionary source are
you planning to add?
] [Thread Prev