static long int timerStartTime = 0;
static long int timerSave = 0;
-
-//
-// Timer callback
-//
-gint stopish_timeout_cb( gpointer data )
-{
- GtkLabel *timerLabel;
- char formatBuffer[128];
- char *tempString;
-
- if ( !data )
- return -1;
-
- timerLabel = ( GtkLabel * ) data;
-
- // print to screen
- tempString = stopish_get_time_string( );
- sprintf( formatBuffer, "<span font_family=\"monospace\" "
- "size=\"70000\" weight=\"ultrabold\">"
- "%s</span>", tempString );
- free( tempString );
- gtk_label_set_markup( GTK_LABEL( timerLabel ), formatBuffer );
-
- return TRUE;
-}
+//Preferences
+static int timerPrecision = TIMER_PRECISION_MINUTE;
char *stopish_get_time_string( void )
h = m / 60;
m = m % 60;
- // rollover once we hit one day
- if ( h > 24 ) {
+ if ( timerPrecision == TIMER_PRECISION_MINUTE && m > 60 ) {
+ // rollover once we hit one hour
+ stopish_set_time_start( stopish_current_time( ) );
+ h = m = s = ss = 0;
+ }
+ else if ( timerPrecision == TIMER_PRECISION_HOUR && h > 24 ) {
+ // rollover once we hit one day
stopish_set_time_start( stopish_current_time( ) );
h = m = s = ss = 0;
}
timeBuffer = malloc( 64 );
- sprintf( timeBuffer, "%.02d:%.02d:%.02d.%.1d",
- h, m, s, ss );
+ if ( timerPrecision == TIMER_PRECISION_MINUTE )
+ sprintf( timeBuffer, "%.02d:%.02d.%.1d",
+ m, s, ss );
+ else
+ sprintf( timeBuffer, "%.02d:%.02d:%.02d.%.1d",
+ h, m, s, ss );
return timeBuffer;
}
return ( s * 10 + us );
}
+
+
+void stopish_timer_set_precision( int setting )
+{
+ timerPrecision = setting;
+}
+
+
+int stopish_timer_get_precision( void )
+{
+ return timerPrecision;
+}