Dialog Boxes - help



I'm writing a function that pops up a modal dialog with some
text and buttons ( a la the Windows MessageBox function ). By itself
it works fine, but what do I need to do to make sure it interfaces
correctly with its parent window? I need to prevent the parent window
from receiving delete events or else it wreaks
havoc on my application. Here is what I have so far:

guint message_box(GtkWidget *parent, ...)
{
	GtkWidget *dialog;
	...

	dialog=gtk_dialog_new();

	gtk_widget_set_parent(dialog, parent);

	/* To which GTK+ responds:

	Gtk-CRITICAL **: file gtkwidget.c: line 3308 (gtk_widget_set_parent):
assertion
	`!GTK_WIDGET_TOPLEVEL (widget)' failed.  */

	gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));

	...

	gtk_widget_show(dialog);
	gtk_grab_add(dialog);
	
	gtk_main();	/* Wait for user to click a button */
	
	/* Signal handler calls gtk_grab_remove(dialog),
gtk_widget_destroy(dialog), and
	gtk_main_quit(), and sets up the return value */

	return result;
}


Am I anywhere close to doing this "right"?

Thanks,
Mark



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