From 2c57c527ded4c22792d14500582d9833fcc6946d Mon Sep 17 00:00:00 2001 From: Michael Cronenworth Date: Wed, 9 Dec 2009 22:50:04 -0600 Subject: [PATCH] Add 4th line of history. Gradually shrink history font size. --- src/stopish.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/stopish.c b/src/stopish.c index a201cd4..9b8b494 100644 --- a/src/stopish.c +++ b/src/stopish.c @@ -29,6 +29,7 @@ static GtkWidget *timerLabel = NULL; static GtkWidget *timerHistoryLabel1 = NULL; static GtkWidget *timerHistoryLabel2 = NULL; static GtkWidget *timerHistoryLabel3 = NULL; +static GtkWidget *timerHistoryLabel4 = NULL; static GSList *historyList = NULL; static int stopishMode = STOPISH_MODE_START; static int timerHandle = -1; @@ -119,9 +120,10 @@ static GtkWindow *stopish_new( void ) // main timer timerLabel = gtk_label_new( NULL ); + gtk_widget_set_size_request( timerLabel, -1, 150 ); gtk_label_set_markup( GTK_LABEL( timerLabel ), "00:00:00.0" ); - gtk_container_add( GTK_CONTAINER( vBox0 ), timerLabel ); + gtk_box_pack_start( GTK_BOX( vBox0 ), timerLabel, FALSE, FALSE, 0 ); // history area timerHistoryLabel1 = gtk_label_new( NULL ); @@ -130,6 +132,8 @@ static GtkWindow *stopish_new( void ) gtk_box_pack_start( GTK_BOX( vBox0 ), timerHistoryLabel2, FALSE, FALSE, 0 ); timerHistoryLabel3 = gtk_label_new( NULL ); gtk_box_pack_start( GTK_BOX( vBox0 ), timerHistoryLabel3, FALSE, FALSE, 0 ); + timerHistoryLabel4 = gtk_label_new( NULL ); + gtk_box_pack_start( GTK_BOX( vBox0 ), timerHistoryLabel4, FALSE, FALSE, 0 ); label = gtk_label_new( NULL ); gtk_container_add( GTK_CONTAINER( vBox0 ), label ); @@ -199,6 +203,7 @@ static void reset_cb( GtkButton* button, gpointer data ) { GSList *tempList; char *tempString; + char formatString[64]; if ( stopishMode == STOPISH_MODE_RESUME ) stopish_timer_resume( ); @@ -217,15 +222,28 @@ static void reset_cb( GtkButton* button, gpointer data ) ( char * ) historyList->data ); tempList = historyList; tempList = g_slist_next( tempList ); - if ( tempList ) - gtk_label_set_text( GTK_LABEL( timerHistoryLabel2 ), - ( char * ) tempList->data ); + if ( tempList ) { + sprintf( formatString, "%s", + ( char * ) tempList->data ); + gtk_label_set_markup( GTK_LABEL( timerHistoryLabel2 ), + formatString ); + } tempList = g_slist_next( tempList ); - if ( tempList ) - gtk_label_set_text( GTK_LABEL( timerHistoryLabel3 ), - ( char * ) tempList->data ); + if ( tempList ) { + sprintf( formatString, "%s", + ( char * ) tempList->data ); + gtk_label_set_markup( GTK_LABEL( timerHistoryLabel3 ), + formatString ); + } + tempList = g_slist_next( tempList ); + if ( tempList ) { + sprintf( formatString, "%s", + ( char * ) tempList->data ); + gtk_label_set_markup( GTK_LABEL( timerHistoryLabel4 ), + formatString ); + } - // remove the history time after the 3rd + // remove the history time after the 4th tempList = g_slist_next( tempList ); if ( tempList ) { tempString = tempList->data; -- 1.7.9.5