Re: Use a GtkMessageBox in a GThread under Win32





On Tue, 2005-01-04 at 16:31, Frédéric COIFFIER wrote:
Hello,

I would like to use a modal message box in a thread to indicate the end of a 
treatment.
I develop my application under Windows. I made the following code in the 
GThread :

    wnd->_end_dialog = gtk_message_dialog_new (GTK_WINDOW(wnd->_window),
                                  GTK_DIALOG_DESTROY_WITH_PARENT,
                                  GTK_MESSAGE_INFO,
                                  GTK_BUTTONS_OK,
                                  "The dump file was correctly saved as '%s'",
                                  filename.data());

    gtk_dialog_run (GTK_DIALOG (wnd->_end_dialog));
    gtk_widget_destroy (wnd->_end_dialog);

But when gtk_dialog_run is called, the windows freeze when the message box 
appears.
I tried to use gdk_threads_enter() and gdk_threads_enter() before and after 
the previous code but in this case, the message box doesn't appear.

I think I have a correct GThread initialisation in main() :

 g_thread_init (NULL);
 gdk_threads_init();

I also find the following message about a similar problem :
http://mail.gnome.org/archives/gtk-app-devel-list/2003-May/msg00171.html
but I use gtk-2.4.x and glib-2.4.x

Does anyone have a solution to make that ?

Regards,
Frédéric



Hi,

gtk_dialog_run() blocks all execution until the user responds, so don't
use it.  Just show the dialog and use a callback function to evaluate
user response and to ultimately destroy the dialog.

Bob Caryl
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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