Re: GTK Modal dialog



My dialog is GtkDialog, not the window :-(

Unfortunately, Linux version (gcc 3.3.3, Fedora Core 2 with gtk 2.4.7) works kind of OK,
but Win32 version does not work OK (Visual C++ 6.0 with SP6, gtk 2.4.9).

On Linux my dialog does not fall through to the bottow of the window z-order when I click on its parent window. On Windows, this is exactly what happens (mybe it is a bug in gtk_window_set_keep_above API ?).

But even on Linux, I don't have a proper modal feeling, my dialog stays on top, but I can achieve loosing main window (fall through on the bottom) while dialog stays on top and focused. Really strange, smells like bug to me.

To clear any misunderstanding my code looks like this:

   dialog1 = gtk_dialog_new ();
   gtk_window_set_modal (GTK_WINDOW (dialog1), TRUE);
   gtk_window_set_skip_pager_hint (GTK_WINDOW (dialog1), TRUE);
   gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog1), TRUE);
gtk_window_set_type_hint (GTK_WINDOW (dialog1), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_transient_for(GTK_WINDOW (dialog1), GTK_WINDOW(window1)); //set parent
   gtk_window_set_keep_above(GTK_WINDOW (dialog1), TRUE);
gtk_window_set_position(GTK_WINDOW (dialog1), GTK_WIN_POS_CENTER_ON_PARENT);

g_signal_connect (dialog1, "destroy", GTK_SIGNAL_FUNC (gtk_main_quit), NULL);

   //show dialog
   gtk_widget_show(dialog1);
   gtk_grab_add(dialog1);    //disable everything except this dialog

   //block in modal state
   //gtk_main();
   GMainLoop *loop = g_main_new (FALSE);
   GDK_THREADS_LEAVE ();
   g_main_run (loop);  // Loop will block here
   GDK_THREADS_ENTER ();
//cleanup
   gtk_grab_remove(dialog1);
   gtk_widget_destroy(dialog1);

Anyway, I am stuck with this, any help is welcome.

I've read that gnome_dialog_run() does exactly what I need, but I must use GTK only.
It seems really strange that GTK does not have this already implemented.

Best regards,
 Miroslav Rajcic

Carlo wrote:

Miroslav Rajcic ha scritto lo scorso 07/10/2004 19.42:

Andrei Yurkevich wrote:

Miroslav Rajcic wrote:


I've already tried this, bur it just doesn't work on Windows version. On GTK my code seems to be
working OK.

I too have got (almost) crazy trying to give to a standard GtkWindow a "modal" behaviour, but the only way to achieve this is to use a GtkDialog.






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