/* CC = gcc CFLAGS =-O2 -Wall `pkg-config gtk+-2.0 gthread-2.0 --cflags --libs` PROG = gthread all: $(PROG) clean: rm $(PROG) */ #include gpointer my_thread(gpointer data) { gint ret; GtkWidget *dialogue; dialogue = gtk_message_dialog_new( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK, "Message"); gdk_threads_enter(); g_print("Here !\n"); ret = gtk_dialog_run(GTK_DIALOG(dialogue)); gtk_widget_destroy(dialogue); gdk_threads_leave(); gtk_main_quit(); return NULL; } int main(int argc, char *argv[]) { GThread *g_thread; gtk_init(&argc, &argv); g_thread_init(NULL); gdk_threads_init(); g_thread = g_thread_create(my_thread, NULL, TRUE, NULL); gdk_threads_enter(); gtk_main(); gdk_threads_leave(); g_thread_join(g_thread); return 0; }