[Glade-devel] libglade usage

todd taf2@lehigh.edu
Thu, 08 Jan 2004 19:31:18 -0500


This is a multi-part message in MIME format.
--------------030009000109030009010703
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

James Henstridge wrote:

> 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.
>
James,
the problem is in libglade because of the order in which it creates 
widgets and connects signals the realize signal is sent before it is
connected.  The problem is easily solved as I showed above.

-todd

--------------030009000109030009010703
Content-Type: text/x-vcard; charset=utf8;
 name="taf2.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="taf2.vcf"

begin:vcard
fn:Todd Fisher
n:Fisher;Todd
email;internet:taf2@lehigh.edu
x-mozilla-html:FALSE
version:2.1
end:vcard


--------------030009000109030009010703--