using gtk_init from libraries



Is it safe to call gtk_init (0, NULL) multiple times from a library, or do 
I need to add some state to test if t has already been called?

Is there a way build a libtool-style library (call it library foo) such
that the linked against version of gtk/glib functions will always be
called by an app bar that links against foo and also staticly (or 
dynamicly) against a different version of glib/gtk?

Background on why I want to do these things:

I've got a little library I call scratchplot that draws simple plots given
a library call like this 'sp_basic_plot (int count, double *x, double
*y)'.  This lets programmers working on scientific apps take a quick look
at their data when needed.  It brings development with things like the GNU
Scientific Library close to Matlab ease (or past it if you know C and want
to interface with things like Gtk :).

At the moment I call gtk_init and gtk_main once per sp_basic_plot call, 
creating a window with a delete event callback that calls gtk_main_quit().
This way the program stops each plot until the plot is dismissed.  I 
intend to add some other widgets to let the plot be scaled and otherwise 
explored at run time.

Is this a generally correct approach, or an abuse of gtk_init?

Also, you can see why I would like the library to not break when it gets 
linked together with different versions of glib.  But at the moment, I had 
to change my app to use dynamic linking with version scratchplot was 
linked against rather than static linking with a different version of glib 
which it had used previously.  I couldn't find any way to get around this 
problem.

Thanks,
Britton




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