Gtk Refresh Problem



Hey people,

I am developing this GUI in GTK+ and it seems gtk doesnt refresh the GUI
until a callback function returns. I saw some newsgroup and found that
other people have also had this problem.
I tried to fix this problem by running a separate whic practically does
following:

while(CALL_BACK_FUNCTION_IS_RUNNING)  {
  gtk_widget_show_all(MainWindow);//MainWindow is a pointer to the main
                                  // program window
  while (gtk_events_pending()) {
    gtk_main_iteration();
  }
  usleep(2000000); //sleep for 2 seconds so that thread doesnt hog the CPU
}
This solution worked for me until I started getting this error:

GLib-WARNING **: g_main_context_prepare(): main loop already active in
another thread

And then the program freezes.

I tried to solve this problem by running the callback function in a
separate thread, thinking that main thread will return and will
automatically refresh the GUI. But my program crashed right at the start
saying 'bad implementation' and stuff. I dont know how to fix this
problem. I would be very thankful if anyone can suggest a solution to
this problem.


regards,
Bharat

--------------------------------------------------------------------------------





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