Modality



Y'all:

I'm trying to understand how to create a modal dialog ... it was my
understanding that this was done with gtk_grab_add():



#include <gtk/gtk.h>

int main(int argc, char* argv[])
{
	gtk_init(&argc, &argv);

	GtkWidget* window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	GtkWidget* window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);

	gtk_window_set_title(GTK_WINDOW(window1), "Window1");
	gtk_window_set_title(GTK_WINDOW(window2), "Window2");

	gtk_widget_show(window1);
	gtk_widget_show(window2);

	gtk_grab_add(window2);

	gtk_main();

	return 0;
}


... so my intent here is that window2 should capture all input / prevent you
from bringing window1 to the top of the Z order, etc.  But it doesn't work.
Do I have the wrong technique, or does "modal" mean something different in
Gtk?

Timster



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