[gtk+osx] Re: Gtk-osx-developer digest, Vol 1 #141 - 1 msg
Status: Beta
Brought to you by:
jralls
From: KieSoft <ad...@ki...> - 2005-07-22 08:10:57
|
> >When user presses a button at my app, it starts a long operation. But I need > >allow UI to work (update stat and other information). Linux version of my > >app calls following code every few milliseconds: > > > >while(gtk_events_pending()) gtk_main_iteration(); > > > >That works on Linux but does not work with GTK-OSX. Can you advice anything? > > > >Looking forward to hearing from you soon, > > > >Best regards, > >Igor > > > > > > > Sounds like you may want to use fork() and leave one process or thread > in that loop and kill it when you no longer need it. An even better > solution would be a fork() in conjunction with a semaphore. The problem that my operation must show information at GtkDialog. GTK is not thread-safe, so I cannot access GtkDialog safely from another thread. When I do the operation at the main thread, GUI locks up. To allow UI be updated I call while(gtk_events_pending()) gtk_main_iteration(); every second. That works on Linux but with MAC-OSX gtk_events_pending() always returns FALSE. I tried 3 ways: 1. while(gtk_events_pending()) gtk_main_iteration(); 2. while (g_main_iteration(FALSE)) ; 3. while (gdk_events_pending()) { GdkEvent* ev = gdk_event_get(); // This does not block if (ev) { // Sometimes there is a NULL event, why? gtk_main_do_event(ev); gdk_event_free(ev); } } // while None of above work. Can you advice me something? Looking forward to hearing from you soon, Best regards, Igor |