Re: Non-Blocking GUI developement



You can use threads, but anytime you modify a widget our call a gtk
display routine, you need to wrap it in g_thread_enter() and
g_thread_leave().

See the documentation here:
http://www.gtk.org/faq/#AEN482

Bryan

On Wed, 2007-01-24 at 09:27 -0500, Melvin Newman wrote:
> First off I am a noob with GTK+. 
> 
> Basically I am writing a program that is to interface with a server
> program over a network. As such this client program has effectively 2
> parts, 1) the backend code that connects to the server and handles all
> the data communications, 2) the front end GUI that presents the code
> to the user. 
> 
> The problem that I am running into is that I cant get the gui to
> update in a timely manner (a problem that allot of us GTK noobs seem
> to have, but one which no one answers clearly). I have tried the
> following at key places in my code: 
> 
> while(gtk_events_pending())
>         gtk_main_iteration();
> 
> And while this does update the gui, the user still has no control over
> it. For example if the user select file->exit, the menu drops down but
> the exit button has no effect. Can GTK+ run multiple signal handlers
> concurrently? 
> 
> In my first write of this program I used pthreads however I did it in
> a very very unsafe manner and the client program would frequently
> crash because both gtk_main() and my thread where doing gui
> operations. 
> 
> My main question therefore is, how do I write a responsive gui that
> can communicate in  real time over the backend networking code? Is
> pthread the way to go? If so, how do I guarantee that the pthread code
> will work on a single processor/core machine? My last pthread code ran
> ok on my dual proc desktop, but died on my single proc laptop. 
> 
> Thank you very much for any help you can provide this noob. 
> 
> Sincerely
> Melvin
> _______________________________________________
> 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]