[Glade-users] Closing a dialog window
Keith Sharp
kms@passback.co.uk
Sat, 29 Jan 2005 20:52:48 +0000
On Sat, 2005-01-29 at 12:34 +0000, Chris Morrison wrote:
> Hi all,
>
> This is probably more of a GNOME programming question than a Glade one
> but here goes.
>
> I am writing a small program in Glade that displays a dialog window on
> the screen with a Close button. Clicking the close button closes the
> dialog and ends the program.
>
> I have placed the following code in the signal handler for the Close
> button's click event.
>
> void on_closebutton_clicked(GtkButton *button, gpointer window_ptr)
> {
> GtkDialog *window = GTK_DIALOG(window_ptr);
> gtk_widget_destroy(GTK_WIDGET(window));
> }
>
> However, when I click on the Close button nothing happens and the
> following message is displayed in the terminal window.
>
> (my-program:5534): Gtk-CRITICAL **: file gtkwidget.c: line 1911
> (gtk_widget_destroy): assertion `GTK_IS_WIDGET (widget)' failed
>
> I am a newbie to Linux programming as you can tell, I have just migrated
> from Micro$oft Windoze.
>
> Any pointers (no pun intended) would be appreciated.
Two things:
1) How are you connecting the callback, which you show above, to the
object and the signal? I assume you have a call to g_signal_connect
somewhere in your code. Can you show us some more of your code?
2) Consider using gtk_dialog_run () and then just check the return code,
there is an example in the API docs:
http://developer.gnome.org/doc/API/2.0/gtk/GtkDialog.html#gtk-dialog-run
Keith.