A default plugin module infrastructure



I started working on making input method implementations
loadable modules, and realized that I was going to have
to cut and paste several hundred lines of code from
gtkthemes.c, and even duplicate some API for the modules.

Not liking that, I came up with the following GtkModule
abstraction.

The simplifications it offers over using GtkTypePlugin
directly are:

 - Handles refcounting
 - Does checking for pathological cases (module can't be
   reloaded, or module does not register the same types
   when reloaded)
 - Provides an easy way for a module to register the
   types it provides without having to handle callback
   functions.
   
   (Right now, this interface, gtk_module_register_type()
   is limited to GtkObject style types, but it could be
   extended to handle GValueTable and interfaces as well.)

It could also be extended to handle the loading and unloading of
the modules via GModule itself, though I avoided doing that in
the first cut, since its not clear to me that all types of
modules will want to look for GModules in the same manner.

(For instance, for the input method modules, I plan to keep a
flat file which caches the results of querying them, so that it
isn't necessary to dlopen() every module on startup of every GTK+
program. This is quite different from the way that theme
engines work.)

Note that currently, there is nothing at all GTK+ specific
about this, so you could imagine calling it GTypePluginSimple
and putting it into gobject.

Anyways, I'd like your reaction on this - asumming that we
continue to suport unloading modules, I think we need to have
something like this, either public or internal to GTK+.

Regards,
                                        Owen

[ Since I know you are going to object to it, the reason
  why gtk_module_ref() can fail and return FALSE is so
  that failure to load a module can be handled intelligently
  when loading the module directly rather than through
  the type system. See gtk_theme_engine_get(). ]

Attachment: gtkmodule.c
Description: Binary data

Attachment: gtkmodule.h
Description: Binary data

Attachment: gtkthemes.c
Description: Binary data



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