Destroy the widget if the other widget is destroyed



Hi,

I've written a file selection function (almost the same like the one in the GTK tutorial).
My ok_button_callback tries to open the file and in the case of no succes it gives an error message (almost the same like in tha API reference -> GtkDialog). There is a signal (emitted by the file selection) connected to this dialog to destroy it if the file selection is destroyed. 


The code:
void quick_message (GtkWidget* widget, gchar *message)
{
  GtkWidget *dialog, *label, *button;

  dialog = gtk_dialog_new ();
  label = gtk_label_new (message);
  button = gtk_button_new_with_label ("  OK  ");
  gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10);
  gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
                             GTK_SIGNAL_FUNC (gtk_widget_destroy), 
                             GTK_OBJECT (dialog));
  gtk_signal_connect_object (GTK_OBJECT (widget), "destroy",
                             GTK_SIGNAL_FUNC (gtk_widget_destroy), 
                             GTK_OBJECT (dialog));
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), button);
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), label);

  gtk_widget_show_all (dialog);
}


It works, but sometimes (very rarely) gives a "Gtk-CRITICAL **: file gtkwidget.c: line 1388 (gtk_widget_destroy): assertion `GTK_IS_WIDGET (widget)' failed" error.
It causes no problem, everything works fine and I can do that many times without any error.
What is the problem?
What is the best way to do the job?

Thanks
Tamás



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