Updating (showing) the widgets of a dialog in a g_thread
- From: Andrew Smith <asmith15 littlesvr ca>
- To: gtk-app-devel-list gnome org
- Subject: Updating (showing) the widgets of a dialog in a g_thread
- Date: Sat, 22 Sep 2007 22:49:56 -0400
Hi
I have the following setup:
gpointer thread1(gpointer data)
{
run_long_function();
return NULL;
}
gpointer thread2(gpointer data)
{
GtkWidget* dialog;
gdk_threads_enter();
dialog = gtk_message_dialog_new(GTK_WINDOW(win_main),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "asd");
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
gtk_widget_show(dialog);
gdk_threads_leave();
while (thread1 is running)
{
gdk_threads_enter();
//!! I want to make sure the dialog is shown
// the following does not help
while (gtk_events_pending())
gtk_main_iteration();
gdk_threads_leave();
usleep(500000);
}
gdk_threads_enter();
gtk_widget_destroy(dialog);
gdk_threads_leave();
return NULL;
}
I start the two threads using g_thread_create() and the while in
thread2() loops while thread1() executes (this is good). But the widgets
in the dialog aren't shown until the loop ends and the dialog is closed
(this is not good).
I would like to be able to click a cancel button while thread1() executes.
Help?
Thanks in advance.
Andrew
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]