Re: GTK Modal dialog



  ...
  if (gProject) {
    /* activating progress window
     */
    dlg = create_winProgress ();
    gtk_window_set_title (GTK_WINDOW (dlg), "Simulating...");
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER_ON_PARENT);
    gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
    gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (parent));
    gtk_widget_show (dlg);

    if (fTcalc) {
      g_free (fTcalc);
    }
    fTcalc = FTCSSolver (dlg);

    gtk_widget_destroy (dlg);
  }
  else {
  ...

Apparently, it is exactly what I do, except for the fact that my modal contains a progressbar and has been generated by Glade2; but, while your code works as expected, my dialog *is not modal* (by focusing the parent window, the dialog goes under it).

John Cupitt ha scritto lo scorso 08/10/2004 15.33:

This test program woks for me on windows and linux with gtk+-2.4.9.
But maybe I misunderstand your problem?

- the dialog does not appear on the taskbar
- when the dialog is open the main window button does not work (so you
can never have more than one dialog)
- the dialog is always above the main window

-------------------
#include <gtk/gtk.h>

static void
dialog_button_click( GtkWidget *widget, GtkWidget *dialog )
{
        gtk_widget_destroy( dialog );
} static void
window_button_click( GtkWidget *widget, GtkWidget *parent_window )
{
        GtkWidget *dialog;
        GtkWidget *button;

        dialog = gtk_window_new( GTK_WINDOW_TOPLEVEL );
        button = gtk_button_new_with_label( "done" );
        g_signal_connect( G_OBJECT( button ), "clicked",
                G_CALLBACK( dialog_button_click ), dialog );
        gtk_container_add( GTK_CONTAINER( dialog ), button );

        gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
        gtk_window_set_transient_for( GTK_WINDOW( dialog ),
                GTK_WINDOW( parent_window ) );
        gtk_window_set_position( GTK_WINDOW( dialog ),
                GTK_WIN_POS_CENTER_ON_PARENT );

        gtk_widget_show_all( dialog );
}

int
main( int argc, char **argv )
{ GtkWidget *window;
        GtkWidget *button;

        gtk_init (&argc, &argv);

        window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
        button = gtk_button_new_with_label( "click to open dialog" );
        g_signal_connect( G_OBJECT( button ), "clicked",
                G_CALLBACK( window_button_click ), window );
        gtk_container_add( GTK_CONTAINER( window ), button );
        gtk_widget_show_all( window );

        gtk_main();

        return( 0 );
}
----------------
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list





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