Re: gtk_timeout_add / SIGALRM with gtk



Hello,
I took some time this morning to put together this example application that uses gthreads and gtk+ together. I tested it on win98, winxp, kernel 2.4.22 and kernel 2.6.5. both 98 and kernel 2.4 seem to have some issues with the way i'm using g_cond_wait but g_cond_timed_wait seems to have fixed those issues. Let me know if this example is helpful and if you find any errors in it. Thanks,
todd

Colin Thomas wrote:

Hello.

I am developing an application which is basically a lots of buttons, no
drawing areas. When one button is depressed, the application runs a
compute intensive job for 20 minutes. While this is happening though the
main screen does not refresh, and slowly becomes obiterated.

I have tried three possible solutions.

One using a SIGALRM running each second to force a gtk_widget_draw(MainWindow, NULL), then reset the alarm for another
second.
########################################################
i.e.
void pathRepaintTopDaemon (int sig)
{
gtk_widget_draw(pTOPWindow, NULL);
alarm(1);
}
and in main code prior to gtk_main()

signal(SIGALRM, pathRepaintTopDaemon);
alarm(1);

#########################################################

This seems to happily refresh every second, until the big button is
depressed and the compute intensive job starts, when it appears never to
get a piece of the action....

I have also tried using
#########################################################
gint Repaint (void * v)
{
gtk_widget_draw(pTOPWindow, NULL);
return 1;
}

with gtk_timeout_add(500, Repaint , 0);
prior to gtk_main().
#########################################################

This again seems to suffer the same fate.

I have also seem references to
 while(gtk_events_pending() )
 {
          gtk_main_iteration();
 }

Which I have tried along with gtk_main(), and again seems not to pick up
the timeout or allow for refreshing which the app is in full steam.

Apart from setting up a thread just to run a gtk_widget_draw in the background, what would be the "preferred" solution to this
problem of keeping menu/widgets refreshed while the application is busy?

I look forward to your collective wisdom.

Best regards


Colin Thomas


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