Re: keeping track of time.
- From: John Vetterli <jvetterli linux ca>
- To: Gtk AppDev Mailing List <gtk-app-devel-list gnome org>
- Subject: Re: keeping track of time.
- Date: Tue, 20 Sep 2005 11:43:06 -0400 (EDT)
On Mon, 19 Sep 2005, oracle nine wrote:
I am writing billiards management program under gtk2 on Linux. Each billiards
table is represented by a widget that will toggle the table open or closed.
While a table is open, I want to insert a label that displays how much time
has elapsed.
I want the application to be aware of clock ticks with are resolution of 1
second. How could I implement this functionality efficiently. Would it be
best to create an interval timer (itimer) every second? Or is there a gtk
handler for time that would be better suited to this task. gtk_main () is
essentially a message queue. Searches have yielded few results that make
sense to me. And a few people have told me that gtk timers are less accurate.
Use g_timeout_add to execute a callback function periodically.
http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html
The interval may not be terribly accurate, but if I understand your needs,
this is not important. The callbacks would only cause the widget to be
updated, not for calculating the time elapsed. The time elapsed can
always be calculated by comparing the current system time and the start
time (see "man 2 time").
JV
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]