[Glade-devel] g_module plugins (was: [glade3, patch] load library module before calling *_get_type ())



On Fri, 2004-01-09 at 17:28, ext bighead users sourceforge net wrote:
Hey

Tommi Komulainen <tommi komulainen nokia com> writes:

module = g_module_load (g_module_build_path (MODULES, library));
if (!module)
    module = g_module_load (g_module_build_path (NULL, library));


Ok I'll go on a tangent here. So if I can open up any lib like that, this
could be the basis of C based plugins?

Well, umm, that's pretty much how browser, xmms, or any other plugins
work.  You just need to define known entry points to the library,
knowing the name of a function you can get a pointer to the function
which you can then call (provided that you also know the signature.)

In gobject case, the known entry point is <foo>_get_type().  Knowing
<foo> you can make the call to get the object GType, with which you can
then create new instances, query names of all properties and signals,
and probably something else I'm forgetting.

It's quite straightforward, really.


-- 
Tommi Komulainen <tommi komulainen nokia com>




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