diff options
author | Unia <jthidskes@live.nl> | 2013-04-07 16:19:58 +0200 |
---|---|---|
committer | Unia <jthidskes@live.nl> | 2013-04-07 16:19:58 +0200 |
commit | f62f1dc7a5c410fa0cd7fc3d30a9131822faf836 (patch) | |
tree | d78a420519c4774496bd05db9c8d2544e49f72bd | |
parent | 26498481fa75d3910579a04740935c91e93f9c25 (diff) |
hours:minutes:seconds display implemented
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | gstopwatch.c | 12 |
2 files changed, 8 insertions, 5 deletions
@@ -34,7 +34,6 @@ ToDo * Display text like gnome-clocks? * Laps -* Hours:Minutes:Seconds display * Font size depend on window size License diff --git a/gstopwatch.c b/gstopwatch.c index fd9a3f4..283fe47 100644 --- a/gstopwatch.c +++ b/gstopwatch.c @@ -8,12 +8,16 @@ GTimer *timer; GtkWidget *timer_display; gboolean update_progress_bar (void) { - char output[100]; + gchar output[100]; + gint hours, minutes, seconds = -1; gulong gulong; - gdouble time_elapsed; - time_elapsed = g_timer_elapsed (timer, &gulong); - sprintf(output, "%.2f", time_elapsed); + seconds = g_timer_elapsed (timer, &gulong); + hours = seconds / 3600; + seconds -= 3600 * hours; + minutes = seconds / 60; + seconds -= 60 * minutes; + sprintf(output, "%02d:%02d:%02d", hours, minutes, seconds); gtk_label_set_text(GTK_LABEL(timer_display), output); return TRUE; |