The seahorse 'registry'



Sorry for not explaining this as I added it, but I wanted to explain
what the seahorse registry (common/seahorse-registry.[ch]) is and why we
use it. Hopefully this'll take the voodoo out :)

We're trying to make seahorse more componentized. One benefit of that
would be so that the PGP support (for instance) is optional. It also
helps with coding sanity when things are more loosely coupled, and
different components don't call each other's code (only the common code).

In order to accomplish this, we need a way for higher level components
(eg: pgp, ssh, pkcs11, gkr) to register things like commands with lower
level components (eg: the key manager window).

In order to prevent a proliferation of register and unregister functions
which let components register callbacks with certain parts of the UI,
I've added the registry.

The registry allows GObject, GType, and functions to be registered with
a set of category strings (GQuarks really) that identify the
functionality of the component.

Here's a concrete example:

 * The "New..." window needs to be able to build a list of things
   that are createable (pgp keys, gkr keyrings, ssh keys).

 * On startup the different components in seahorse register actions with
   the categories like the following. This is usually done from the
   class_init functions of the different bits that want to register
   themselves.

   "pgp", "generator"

 * When the "New..." window opens, it asks the registry for all the
   objects that have "generator" and adds those to its window.

Some other little caveats are...

The class_init method of a class isn't called until the class is first
used. This is why you might see code like the following: (in
seahorse_gkr_module_init)

   g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_GKR_SOURCE));

All this does is load the class, and cause its class_init function to
run. The class then has a chance to register itself with the registry
wherever possible.

As another example, you'll notice that Sources (objects that load keys
etc...) register themselves with the registry in different ways.

Cheers,

Stef





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