[Glade-devel] libglade usage
- From: taf2 lehigh edu (Todd Fisher)
- Subject: [Glade-devel] libglade usage
- Date: Tue, 30 Dec 2003 17:29:53 -0500
Olexiy Avramchenko wrote:
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.
<...>
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.
Your window is just realized before glade_xml_signal_autoconnect()
call. Possible solutions:
1. (the nice one) Test your main window widget with
GTK_WIDGET_REALIZED() macro.
2. (the worse and untested) Set "Visible" flag ("Common" tab in
"Properties" notebook) to FALSE, get a pointer to your window (with
call like 'glade_xml_get_widget(xml, "window1")') and call
gtk_widget_show_all() on it before gtk_main().
Olexiy
I have a work around for my problem that i'd like to share. basically it
involves
creating the window manually and only reading in the part of the glade file
that i want to embed into my application.
int main( int argc, char **argv )
{
App app;
GtkWidget *hero_win;
GtkWidget *glade_widget_hook;
gtk_init( &argc, &argv );
/* load the interface */
app.xml = glade_xml_new( "gui.glade", "vbox1", NULL );
if( app.xml == NULL ){
g_error( "Failed to initialize glade_xml file" );
return 1;
}
/* connect the signals in the interface */
glade_xml_signal_autoconnect_with_data( app.xml, &app );
glade_widget_hook = glade_xml_get_widget( app.xml, "vbox1" );
hero_win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title( GTK_WINDOW( hero_win ), "HERO" );
gtk_container_add( GTK_CONTAINER( hero_win ), glade_widget_hook );
g_signal_connect ((gpointer) hero_win, "destroy",
G_CALLBACK (on_hero_win_destroy),
&app );
g_signal_connect ((gpointer) hero_win, "realize",
G_CALLBACK (on_hero_win_realize),
&app );
gtk_widget_show( hero_win );
/* start the event loop */
gtk_main();
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]