I've programmed a software gui using glade and gtk. The main window has an About button. When I click on the button for the first time, the GtkAboutDialogBox runs perfectly. The action area is correctly bound to the events. But when I close it and tries again to open the about dialog (without quiting from the main window), nothing comes up. And additionally the system thows
(tut:5424): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkDialog'
(tut:5424): Gtk-CRITICAL **: IA__gtk_dialog_run: assertion `GTK_IS_DIALOG (dialog)' failed
(tut:5424): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkWidget'
(tut:5424): Gtk-CRITICAL **: IA__gtk_widget_destroy: assertion `GTK_IS_WIDGET (widget)' failed
to the shell. What could be wrong with this code?
//tut.c
//gcc -o tut tut.c $(pkg-config --cflags --libs gtk+-2.0 gmodule-2.0)
#include <gtk/gtk.h>
GtkBuilder *builder;
GtkWidget *window,*window_cnb;
GtkAboutDialog *abtwindow;
GtkLabel *label;
GError *error = NULL;
void on_about_clicked() {
gtk_dialog_run( GTK_DIALOG(abtwindow) );
gtk_widget_destroy( GTK_WIDGET(abtwindow) );
}
int main( int argc,char **argv ) {
gtk_init( &argc, &argv );
builder = gtk_builder_new();
if( ! gtk_builder_add_from_file( builder, "my.glade", &error ) ) {
g_warning( "%s", error->message );
g_free( error );
return( 1 );
}
window = GTK_WIDGET( gtk_builder_get_object( builder, "window1" ) );
abtwindow = GTK_ABOUT_DIALOG( gtk_builder_get_object( builder, "aboutdialog1" ) );
label = GTK_LABEL( gtk_builder_get_object( builder, "label16" ) );
gtk_builder_connect_signals( builder, NULL );
g_object_unref( G_OBJECT( builder ) );
gtk_widget_show( window );
gtk_main();
return( 0 );
}
I use gtkbuilder. How can I fix it?