[Glade-users] Closing a dialog window



On Sun, 2005-01-30 at 15:58 +0000, Keith Sharp wrote:
On Sun, 2005-01-30 at 15:55 +0000, Keith Sharp wrote:
On Sun, 2005-01-30 at 14:06 +0000, Chris Morrison wrote:
On Sat, 2005-01-29 at 20:52 +0000, Keith Sharp wrote:
On Sat, 2005-01-29 at 12:34 +0000, Chris Morrison wrote:

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

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?

g_signal_connect ((gpointer) closebutton, "clicked", G_CALLBACK
(on_closebutton_clicked), NULL);

The last parameter of this function is for extra data you want to pass
to the callback, in your case this would the pointer to your window.
You need to change this code to somethings like:

GtkDialog *dialog;

/* Create and setup dialog here */

g_signal_connect (closebutton, "clicked", G_CALLBACK (on_closebutton_clicked), window);

This should of course be:

g_signal_connect (closebutton, "clicked", G_CALLBACK (on_closebutton_clicked), dialog);

Keith.

Cheers,

I suppose I should stop being lazy and get used to using libglade,
especially as Glade 3 will (hopefully) be out soon, and is supposed to
be able to plug into Anjuta 2 which will (hopefully) be out soon as
well.

The only reason I used Glade is because I cannot figure out how the
autoconf monster works.

Chris






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]