Re: Displaying intermediate button images.
- From: Rich Burridge <Rich Burridge Sun COM>
- To: tvb gnome org, gbreland mozillanews org
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Displaying intermediate button images.
- Date: Mon, 26 Sep 2005 14:40:15 -0700
Thanks to Greg and Tristan.
You should read a little of this:
http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html
The problem is that you are hijacking the mainloop, in GTK+ programming,
you must let GTK+ operate (and do stuff like; update the display ;-p)...
so that means no `while (1)' and no `sleep (1)', instead; try timeout
functions which will call your desired callback at an interval
(see g_timeout_add on the page mentioned above).
Okay, I've read this web page and for the life of me, I can't see a
way to write a simple/elegant routine that does this, within the context of
my larger application.
Let me tell you that the real code is part of an Othello game. Each square
on the othello board is a button. It's either displaying a white
piece, a black piece or nothing. For a valid move, the "clicked" callback
needs to "toggle" a few times, each of the pieces that the new move is
going to convert (from white to black (or vica versa)). Then it's going
to do the final update of the whole board area, update scores, and so on.
I'd really like to do this from within the callback routine for the
"clicked" action.
What I've found seems to work is if I adjust my reve_speed() routine to
look like:
void
reve_sleep(unsigned x) /* Suspend execution for interval in microseconds. */
{
struct timeval st_delay;
while (gtk_events_pending()) {
gtk_main_iteration();
}
st_delay.tv_usec = x;
st_delay.tv_sec = 0;
select(32, NULL, NULL, NULL, &st_delay);
}
I'm going to go with that for now.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]