Re: Dynamic creation of GtkMenuBar from GModule



On Tue, Jan 30, 2007 at 10:12:15AM +0100, Alessandro Oliva wrote:
is it possible to access the variabile of a main program from a dynamic 
module ?

If modules want to add items to the menubar, your main
program should provide an API for that.

Moreover, often it's better when the interface is a bit
abstract, i.e. the module says `I can do these things,
here are the details' and the intergration is left on the
main program.

Technically you can:

1. Use libtool's -export-symbols (or -export-regexp) when
linking the main program to export a specific API.  You have
to try hard no to break the API then and/or implement your
own versioning scheme to express interface compatibility.

2. Use -export-dynamic to export everything.  This means
everything is also a part of the interface and modules are
essentialy tied to a particular version of the main program.
Again, you have to implement a version check that prevents
modules built for other versions of the prorgram from
loading, because you cannot tell whether they will work.

3. Move the functionality used by both the program and
modules to a shared library.  This means one more shared
object and possibly other complications, on the other hand
you can use the standard shared library versioning scheme to
express interface compatibility.

menuitem_test = gtk_menu_item_new_with_mnemonic ("_TEST");
gtk_widget_show (menuitem_test);
gtk_container_add (/top_menubar/, menuitem_test);


where /top_menubar/ is created in the main program

You can do something like this with 2., but avoid it unless
you need modules with deep knowledge of the main program and
don't care about thrid party modules.

Yeti


--
Whatever.



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