[Glade-devel] libglade usage
James Henstridge
james@daa.com.au
Thu, 08 Jan 2004 11:41:32 +0800
On 28/12/2003 4:58 AM, Todd Fisher wrote:
> I have a very simple libglade application. I used glade-2.0.1 to
> generate a
> .glade file which contains a gtkWindow and a GtkButton nothing else.
> It defines
> two signal handlers. A realize and destroy signal for the
> GtkWindow. when i use the following as my main applicaion the realize
> signal handler is not
> called.
> #include <gtk/gtk.h>
> #include <glade/glade.h>
>
> void realize( GtkWidget *widget, gpointer null )
> {
> printf( "hello\n" );
> }
> int main( int argc, char **argv )
> {
> GladeXML *xml;
>
> gtk_init( &argc, &argv );
> /* load the interface */
> xml = glade_xml_new( "gui.glade", NULL, NULL );
> if( xml == NULL ){
> g_error( "Failed to initialize glade_xml file" );
> return 1;
> }
> /* connect the signals in the interface */
> glade_xml_signal_autoconnect( xml );
>
>
> /* start the event loop */
> gtk_main();
> return 0;
> }
> compiling it with gcc -Wall -g `pkg-config libglade-2.0 --cflags
> --libs` testapp.c
>
> I expect to run the program see my window pop up and see hello printed
> at the terminal.
> I get no Gtk Warnings or Errors instead. I think its important to
> have this realize signal
> handler called because I want to initialize my application here.
>
> any ideas? Am i misuing the api? is this a bug in libglade?
>
> I've tested this with the lastest unstable release of libglade and a
> fairly recent cvs version and
> noticed the same behavoir.
Libglade's autoconnect function looks up function names in the global
symbol table. By default, functions in the main executable do not
appear there, so would not normally be visible.
The flags returned by "pkg-config --libs libglade-2.0" should include a
linker flag to export the apps symbols for use by things like
autoconnect() (for linux systems, the flag is -Wl,--export-dynamic).
If that all looks okay, check to see whether the handler names match
up. Is the signal handler name (as opposed to signal name) for your
"realize" signal really "realize"? (and not "on_window1_realize" or
similar?).
James.
--
Email: james@daa.com.au
WWW: http://www.daa.com.au/~james/