bigger icons, tmpdir
[maemo-recorder] / src / maemo-recorder-ui.c
index 19aee13..6d95261 100644 (file)
@@ -41,7 +41,7 @@
 #define DEFAULT_REC_BLOCKSIZE "160"
 
 #define STOP_DELAY 500
-#define REC_UPDATE_INTERVAL 750
+#define REC_UPDATE_INTERVAL 500
 #define PLAY_UPDATE_INTERVAL 200
 
 /* MACROs */
@@ -55,7 +55,7 @@
 #define GST_TIME_MSECS(t) \
         (guint) (((GstClockTime)(t)) % GST_SECOND)
 
-#define RECORDER_APP_TITLE "Maemo Recorder"
+#define RECORDER_APP_TITLE "Recorder"
 #define RECORDER_MSG_READY _("Ready")
 #define RECORDER_MSG_STOPPED _("Stopped")
 #define RECORDER_MSG_PAUSED _("Paused")
@@ -97,9 +97,9 @@ static gboolean seekToZero(AppData *data, GstElement *pipeline);
 static void setLength(AppData *data, gdouble secs);
 static void setFormatString(AppData *data, AudioFormat afmt);
 static gboolean cbStopPlayback(AppData *data);
-static void cbStop(GtkWidget* widget, AppData *data);
-static void cbPlay(GtkWidget* widget, AppData *data);
-static void cbRec(GtkWidget* widget, AppData *data);
+static void cbStop(GtkWidget* widget, GdkEventButton *event, AppData *data);
+static void cbPlay(GtkWidget* widget, GdkEventButton *event, AppData *data);
+static void cbRec(GtkWidget* widget, GdkEventButton *event, AppData *data);
 static void cbNew(GtkWidget* widget, AppData *data);
 static void cbOpen(GtkWidget* widget, AppData *data);
 /*static void cbSave(GtkWidget* widget, AppData *data);*/
@@ -392,9 +392,9 @@ static gboolean destroyPipeline(AppData *data, PipeLineType type)
 
     ULOG_INFO("%s() - Stopping playback/recording", G_STRFUNC);
 
-    hildon_banner_show_information(GTK_WIDGET(data->mainView), NULL, RECORDER_MSG_STOPPED);         
-    gtk_entry_set_text(GTK_ENTRY(data->mainViewData.stateEntry), 
-                         RECORDER_MSG_STOPPED);  
+    //hildon_banner_show_information(GTK_WIDGET(data->mainView), NULL, RECORDER_MSG_STOPPED);         
+    gtk_label_set_text(GTK_LABEL(data->mainViewData.stateEntry), "");
+    gtk_widget_set_sensitive(data->buttonRec, TRUE);
 
     switch (type)
     {
@@ -456,12 +456,12 @@ static void pipelineStateChanged (GstElement *element,
                g_free(tmp);
                tmp = NULL;
                ULOG_INFO("%s() - Recording", G_STRFUNC);
-               gtk_entry_set_text(GTK_ENTRY(data->mainViewData.stateEntry), 
+               gtk_label_set_text(GTK_LABEL(data->mainViewData.stateEntry), 
                       RECORDER_MSG_RECORDING);
 
                gtk_widget_set_state(data->buttonRec, GTK_STATE_ACTIVE);
 
-               if (data->recUpdateId == 0 && gettimeofday(&data->recStartTv, NULL) == 0)
+               if (data->recUpdateId == 0)
                {
                    data->recUpdateId = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, REC_UPDATE_INTERVAL, (GSourceFunc) cbUpdateRecLength, data, NULL);
                }
@@ -473,7 +473,7 @@ static void pipelineStateChanged (GstElement *element,
                g_free(tmp);
                tmp = NULL;
                ULOG_INFO("%s() - Playing", G_STRFUNC);
-               gtk_entry_set_text(GTK_ENTRY(data->mainViewData.stateEntry), 
+               gtk_label_set_text(GTK_LABEL(data->mainViewData.stateEntry), 
                       RECORDER_MSG_PLAYING);  
                gtk_widget_set_state(data->buttonPlay, GTK_STATE_ACTIVE);
                /*
@@ -486,8 +486,7 @@ static void pipelineStateChanged (GstElement *element,
         case GST_STATE_READY:
             /* hildon_banner_show_information(GTK_WIDGET(data->mainView), NULL, "Ready..."); */
             ULOG_INFO("%s() - Ready", G_STRFUNC);
-            gtk_entry_set_text(GTK_ENTRY(data->mainViewData.stateEntry), 
-                     RECORDER_MSG_READY);  
+            gtk_label_set_text(GTK_LABEL(data->mainViewData.stateEntry), ""); 
             break;
 
         case GST_STATE_PAUSED:
@@ -500,7 +499,7 @@ static void pipelineStateChanged (GstElement *element,
               if (GST_IS_ELEMENT(data->playPipeline) && gst_element_query_position(data->playPipeline, &fmt, &pos) && pos != 0)
               {
                   hildon_banner_show_information(GTK_WIDGET(data->mainView), NULL, RECORDER_MSG_PAUSED);       
-                  gtk_entry_set_text(GTK_ENTRY(data->mainViewData.stateEntry), 
+                  gtk_label_set_text(GTK_LABEL(data->mainViewData.stateEntry), 
                          RECORDER_MSG_PAUSED);
               }
               gtk_widget_set_state(data->buttonRec, GTK_STATE_NORMAL);
@@ -564,9 +563,9 @@ static gboolean cbBus(GstBus *bus,
                  case APPSTATE_PLAYING:
                     /* stop playback after a short break*/
                     g_timeout_add(STOP_DELAY, (GSourceFunc)cbStopPlayback, data);
-                    hildon_banner_show_information(GTK_WIDGET(app->mainView), NULL, RECORDER_MSG_STOPPED);       
-                    gtk_entry_set_text(GTK_ENTRY(app->mainViewData.stateEntry), 
-                         RECORDER_MSG_STOPPED);  
+                    //hildon_banner_show_information(GTK_WIDGET(app->mainView), NULL, RECORDER_MSG_STOPPED);       
+                    gtk_label_set_text(GTK_LABEL(app->mainViewData.stateEntry), 
+                         "");  
 
                     break;
 
@@ -585,6 +584,7 @@ static gboolean cbBus(GstBus *bus,
              break;
         }
 
+        case GST_MESSAGE_ASYNC_DONE:
         case GST_MESSAGE_STATE_CHANGED: 
         {
             GstState old;
@@ -617,8 +617,7 @@ static void cbDestroy(GtkWidget* widget, GdkEvent *event, gpointer data)
     app = (AppData *) data;
 
     ULOG_DEBUG("delete_event");
-    if (!closeFile(app))
-        return;
+    closeFile(app);
 
     destroyPipelines(app);
     if (app->playPipeline)
@@ -653,6 +652,9 @@ static gboolean cbCheckPosition (AppData *data)
     if (gst_element_query_position(data->playPipeline, &fmt, &pos))
     {
         gdouble time = GST_TIME_TO_SECS(pos);
+        guint mins = 0;
+        gdouble secs;
+        gchar* tmp;
 
         ULOG_DEBUG("pos = %lld, time = %f", 
              pos,
@@ -663,6 +665,18 @@ static gboolean cbCheckPosition (AppData *data)
            GTK_ADJUSTMENT(data->mainViewData.adjustment),
            time);
         gtk_adjustment_value_changed(GTK_ADJUSTMENT(data->mainViewData.adjustment));
+        if (secs >= 60.0)
+        {
+            mins = secs / 60;
+            secs -= mins * 60.0;
+        }
+
+        tmp = g_strdup_printf("%02u:%02d", mins, (int)secs);
+
+        gtk_label_set_text(GTK_LABEL(data->mainViewData.ctime),
+                 tmp);
+        g_free(tmp);
+
     }
 
     if (APPSTATE_PLAYING == getAppState(data))
@@ -681,7 +695,12 @@ static void cbNew(GtkWidget* widget, AppData *data)
         return;
 
     /* remove pipelines if existing */
-    destroyPipelines(data);
+    if (APPSTATE_PLAYING == getAppState(data) || APPSTATE_RECORDING == getAppState(data)) {
+        cbStop(widget, NULL, data);
+        destroyPipelines(data);
+    }
+
+    setAppState(data, APPSTATE_READY);
     ULOG_DEBUG_F("cbNew");
     /* destroy tmp file */
 
@@ -694,12 +713,13 @@ static void cbNew(GtkWidget* widget, AppData *data)
     data->file_format = FORMAT_NONE;
 
     /* update display */
-    gtk_entry_set_text(GTK_ENTRY(data->mainViewData.fileNameEntry), 
+    gtk_label_set_text(GTK_LABEL(data->mainViewData.fileNameEntry), 
         RECORDER_FILE_UNTITLED);
     setLength(data, 0.0);
     /* update the display + scale */
     gtk_adjustment_set_value(GTK_ADJUSTMENT(data->mainViewData.adjustment),
               0);
+    gtk_label_set_text(GTK_LABEL(data->mainViewData.ctime), "00:00");
     gtk_widget_set_sensitive(data->buttonSave, FALSE);
     gtk_widget_set_sensitive(data->buttonSaveAs, FALSE);
     data->saved = TRUE;
@@ -724,6 +744,10 @@ static void cbOpen(GtkWidget* widget, AppData *data)
 
     if (!closeFile(data))
         return;
+    if (APPSTATE_PLAYING == getAppState(data) || APPSTATE_RECORDING == getAppState(data)) {
+        cbStop(widget, NULL, data);
+        destroyPipelines(data);
+    }
 
 #if 0
     /* create filter */
@@ -759,8 +783,15 @@ static void cbOpen(GtkWidget* widget, AppData *data)
         */
     }
 
-    if (NULL == selected) /* no file selected */
+    if (NULL == selected) 
+    { 
+        /* no file selected */
+        if (!g_file_test(getFileName(data), G_FILE_TEST_EXISTS))
+        {
+                cbNew(widget, data);
+        }
         return;
+    }
 
     ULOG_INFO("%s() - selected filename = '%s'", G_STRFUNC, selected);
 
@@ -773,7 +804,7 @@ static void cbOpen(GtkWidget* widget, AppData *data)
         /* update filenames */
         basename = g_path_get_basename(selected);
 
-        gtk_entry_set_text(GTK_ENTRY(data->mainViewData.fileNameEntry), selected);
+        gtk_label_set_text(GTK_LABEL(data->mainViewData.fileNameEntry), basename);
         g_free(basename);
 
         g_free(data->openFileName);
@@ -846,7 +877,7 @@ openURI(gpointer user_data)
         /* update filenames */
         basename = g_path_get_basename(selected);
         
-        gtk_entry_set_text(GTK_ENTRY(data->mainViewData.fileNameEntry), selected);
+        gtk_label_set_text(GTK_LABEL(data->mainViewData.fileNameEntry), basename);
         g_free(basename);
 
         g_free(data->openFileName);
@@ -893,7 +924,7 @@ static void openPlayPipeline( AppData *data )
         case FORMAT_PCM:
         case FORMAT_ILBC:
         case FORMAT_WAV:
-            destroyPipelines(data);
+            //destroyPipelines(data);
             //data->filter = data->file_format;
             createPipeline(data, PIPELINE_PLAY);
             break;
@@ -951,7 +982,6 @@ closeFile(AppData *data)
     note = hildon_note_new_confirmation_add_buttons(GTK_WINDOW(data->mainView), _("Save recording?"),
             _("Yes"), GTK_RESPONSE_YES,
             _("No"), GTK_RESPONSE_NO,
-            _("Cancel"), GTK_RESPONSE_CANCEL,
             NULL);
 
     i = gtk_dialog_run(GTK_DIALOG(note));
@@ -963,6 +993,9 @@ closeFile(AppData *data)
             return FALSE;
 
         case GTK_RESPONSE_NO:
+            if (data->saveFileName)
+                g_unlink(data->saveFileName);
+            data->saved = TRUE;
             return TRUE;
 
         case GTK_RESPONSE_YES:
@@ -980,7 +1013,7 @@ static const gchar *
 getFileName(AppData *data)
 {
     g_assert(data);
-    return gtk_entry_get_text(GTK_ENTRY(data->mainViewData.fileNameEntry));
+    return gtk_label_get_text(GTK_LABEL(data->mainViewData.fileNameEntry));
 
 }
 
@@ -1084,8 +1117,8 @@ static void cbSaveAs(GtkWidget* widget, AppData *data)
             data->openFileName = g_strdup(data->saveFileName);
         }
 
-        gtk_entry_set_text(GTK_ENTRY(data->mainViewData.fileNameEntry), 
-                 data->saveFileName);
+        gtk_label_set_text(GTK_LABEL(data->mainViewData.fileNameEntry), 
+                 basename);
         
         g_free(basename);
         data->saved = TRUE;
@@ -1101,15 +1134,41 @@ static void cbSaveAs(GtkWidget* widget, AppData *data)
     ULOG_DEBUG("%s() - end", G_STRFUNC);
 }
 
-static void cbRec(GtkWidget* widget, AppData *data) 
+static void cbRec(GtkWidget* widget, GdkEventButton *event, AppData *data) 
 {
     g_assert(NULL != data);
 
     ULOG_DEBUG("%s() - begin", G_STRFUNC);     
 
+    if (APPSTATE_RECORDING == getAppState(data))
+    {
+         if (GST_IS_ELEMENT(data->recPipeline))
+         {
+             gst_element_set_state(GST_ELEMENT(data->recPipeline), GST_STATE_PAUSED);
+             gtk_label_set_text(GTK_LABEL(data->mainViewData.stateEntry),
+                                              RECORDER_MSG_PAUSED);
+             hildon_banner_show_information(GTK_WIDGET(data->mainView), NULL, RECORDER_MSG_PAUSED);
+             setAppState(data, APPSTATE_PAUSED);
+         }
+         return;
+    }
+
+    if (APPSTATE_PAUSED == getAppState(data)) 
+    {
+         if (GST_IS_ELEMENT(data->recPipeline))
+         {
+             gst_element_set_state(GST_ELEMENT(data->recPipeline),
+                           GST_STATE_PLAYING);
+             setAppState(data, APPSTATE_RECORDING);
+             return;
+         }
+    }
+
     if (APPSTATE_READY != getAppState(data))
     {
         ULOG_WARN("%s() - state different than READY -> return", G_STRFUNC);
+        if (APPSTATE_RECORDING == getAppState(data))
+            cbStop(widget, NULL,data);
         return;
     }
 
@@ -1126,45 +1185,51 @@ static void cbRec(GtkWidget* widget, AppData *data)
     switch (data->filter)
     {
         case FORMAT_PCM:
-             data->saveFileName = g_strdup_printf("%s/%s", get_default_dir(), DEFAULT_TMP_FILE);
-             data->openFileName = g_strdup_printf("%s/%s", get_default_dir(), DEFAULT_TMP_FILE);
+             data->saveFileName = g_strdup_printf("%s/%s", DEFAULT_TMP_DIR, DEFAULT_TMP_FILE);
+             data->openFileName = g_strdup_printf("%s/%s", DEFAULT_TMP_DIR, DEFAULT_TMP_FILE);
              break;
 
          case FORMAT_PCMA:
-             data->saveFileName = g_strdup_printf("%s/%s", get_default_dir(), DEFAULT_TMP_PCMA_FILE);
-             data->openFileName = g_strdup_printf("%s/%s", get_default_dir(), DEFAULT_TMP_PCMA_FILE);
+             data->saveFileName = g_strdup_printf("%s/%s", DEFAULT_TMP_DIR, DEFAULT_TMP_PCMA_FILE);
+             data->openFileName = g_strdup_printf("%s/%s", DEFAULT_TMP_DIR, DEFAULT_TMP_PCMA_FILE);
              break;
              
          case FORMAT_PCMU:
-             data->saveFileName = g_strdup_printf("%s/%s", get_default_dir(), DEFAULT_TMP_PCMU_FILE);
-             data->openFileName = g_strdup_printf("%s/%s", get_default_dir(), DEFAULT_TMP_PCMU_FILE);
+             data->saveFileName = g_strdup_printf("%s/%s", DEFAULT_TMP_DIR, DEFAULT_TMP_PCMU_FILE);
+             data->openFileName = g_strdup_printf("%s/%s", DEFAULT_TMP_DIR, DEFAULT_TMP_PCMU_FILE);
              break;
 
          case FORMAT_WAV:
-             data->saveFileName = g_strdup_printf("%s/%s", get_default_dir(), DEFAULT_TMP_WAV_FILE);
-             data->openFileName = g_strdup_printf("%s/%s", get_default_dir(), DEFAULT_TMP_WAV_FILE);
+             data->saveFileName = g_strdup_printf("%s/%s", DEFAULT_TMP_DIR, DEFAULT_TMP_WAV_FILE);
+             data->openFileName = g_strdup_printf("%s/%s", DEFAULT_TMP_DIR, DEFAULT_TMP_WAV_FILE);
              break;
 
          case FORMAT_ILBC:
          default:
-             data->saveFileName = g_strdup_printf("%s/%s", get_default_dir(), DEFAULT_TMP_ILBC_FILE);
-             data->openFileName = g_strdup_printf("%s/%s", get_default_dir(), DEFAULT_TMP_ILBC_FILE);
+             data->saveFileName = g_strdup_printf("%s/%s", DEFAULT_TMP_DIR, DEFAULT_TMP_ILBC_FILE);
+             data->openFileName = g_strdup_printf("%s/%s", DEFAULT_TMP_DIR, DEFAULT_TMP_ILBC_FILE);
             break;
     }
 
+    g_mkdir(DEFAULT_TMP_DIR, 755);
+    
     ULOG_INFO("%s() - creating pipelines", G_STRFUNC);
     /* start recording */
     /* create related pipelines */
     if (createPipeline(data, PIPELINE_REC))
     {
         ULOG_INFO("%s() - starting recording", G_STRFUNC);
+        gchar *basename;
         /* start recording */
+        data->rectime = 0;
         gst_element_set_state(GST_ELEMENT(data->recPipeline), 
                            GST_STATE_PLAYING);
 
         /* update display */
-        gtk_entry_set_text(GTK_ENTRY(data->mainViewData.fileNameEntry), 
-            data->saveFileName);
+        basename = g_path_get_basename(data->saveFileName);
+        gtk_label_set_text(GTK_LABEL(data->mainViewData.fileNameEntry), 
+            basename);
+        g_free(basename);
 
         setAppState(data, APPSTATE_RECORDING);
         gtk_widget_set_sensitive(data->buttonSaveAs, TRUE);
@@ -1177,11 +1242,13 @@ static void cbRec(GtkWidget* widget, AppData *data)
         hildon_banner_show_information(GTK_WIDGET(data->mainView), GTK_STOCK_DIALOG_ERROR, _("Could not create pipeline"));
         setAppState(data, APPSTATE_READY);
     }
+
+    gtk_widget_set_sensitive(data->buttonPlay, FALSE);
+
     ULOG_DEBUG("%s() - end", G_STRFUNC);     
 }
 
-static void cbPlay(GtkWidget* widget, AppData *data) 
+static void cbPlay(GtkWidget* widget, GdkEventButton *event, AppData *data) 
 {
     const gchar * file = NULL;
      
@@ -1196,19 +1263,22 @@ static void cbPlay(GtkWidget* widget, AppData *data)
         return;
     }
 
-    openPlayPipeline(data);
-     
     if (APPSTATE_PLAYING == getAppState(data))
     {
          if (GST_IS_ELEMENT(data->playPipeline)) 
          {
              gst_element_set_state(GST_ELEMENT(data->playPipeline), GST_STATE_PAUSED);
-             setAppState(data, APPSTATE_READY);
+             setAppState(data, APPSTATE_PAUSED);
          }
          return;
     }
 
-    if (APPSTATE_READY != getAppState(data))
+    if (APPSTATE_PAUSED != getAppState(data)) {
+        openPlayPipeline(data);
+        setAppState(data, APPSTATE_READY);
+    }
+    
+    if (APPSTATE_READY != getAppState(data) && APPSTATE_PAUSED != getAppState(data))
     {
         ULOG_WARN("%s() - state different than PLAYING or READY -> return", G_STRFUNC);
         return;
@@ -1229,10 +1299,12 @@ static void cbPlay(GtkWidget* widget, AppData *data)
 
     g_timeout_add(PLAY_UPDATE_INTERVAL, (GSourceFunc)cbCheckPosition, data);
 
+    gtk_widget_set_sensitive(data->buttonRec, FALSE);
+
     ULOG_DEBUG("%s() - end", G_STRFUNC);
 }
 
-static void cbStop(GtkWidget* widget, AppData *data) 
+static void cbStop(GtkWidget* widget, GdkEventButton *event, AppData *data) 
 {
     g_assert(NULL != data);
 
@@ -1244,6 +1316,8 @@ static void cbStop(GtkWidget* widget, AppData *data)
     gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(data->buttonPlay), GTK_STOCK_MEDIA_PLAY);
     gtk_widget_set_state(data->buttonPlay, GTK_STATE_NORMAL);
     gtk_widget_set_state(data->buttonRec, GTK_STATE_NORMAL);
+    gtk_widget_set_sensitive(data->buttonPlay, TRUE);
+    gtk_widget_set_sensitive(data->buttonRec, TRUE);
 
     /* destroy related pipeline */
     switch(getAppState(data))
@@ -1255,6 +1329,7 @@ static void cbStop(GtkWidget* widget, AppData *data)
             gst_element_set_state(GST_ELEMENT(data->playPipeline), 
                      GST_STATE_PAUSED);
             /* flow through */
+        case APPSTATE_PAUSED:
         case APPSTATE_READY:
             /* seek to zero, but not for PCM pipeline */
             /* if (data->playPipelineType == PIPELINE_PLAY || seekToZero(data, GST_ELEMENT(data->playPipeline))) */
@@ -1263,8 +1338,9 @@ static void cbStop(GtkWidget* widget, AppData *data)
               gtk_adjustment_set_value( 
                    GTK_ADJUSTMENT(data->mainViewData.adjustment), 0);
               gtk_adjustment_value_changed(GTK_ADJUSTMENT(data->mainViewData.adjustment));
-              gtk_entry_set_text(GTK_ENTRY(data->mainViewData.stateEntry), 
-                         RECORDER_MSG_STOPPED);  
+              gtk_label_set_text(GTK_LABEL(data->mainViewData.ctime), "00:00");
+              gtk_label_set_text(GTK_LABEL(data->mainViewData.stateEntry), 
+                         "");  
             }
             break;
 
@@ -1298,83 +1374,6 @@ static void cbStop(GtkWidget* widget, AppData *data)
 
 /* ui construction functions */
 
-static GtkWidget* createToolBar(AppData *data)
-{
-     GtkToolbar* toolBar = NULL;
-     
-     GtkToolItem* new = NULL;
-     GtkToolItem* open = NULL;
-     GtkToolItem* save = NULL;
-     GtkToolItem* saveas = NULL;
-     GtkToolItem* sep = NULL;
-     GtkToolItem* play = NULL;
-     GtkToolItem* rec = NULL;
-     GtkToolItem* stop = NULL;
-     
-     /* create buttons */
-     new = gtk_tool_button_new_from_stock(GTK_STOCK_NEW); 
-     open = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN); 
-     save = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
-     data->buttonSave = GTK_WIDGET(save);
-     saveas = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE_AS);
-     data->buttonSaveAs = GTK_WIDGET(saveas);
-     gtk_widget_set_sensitive(data->buttonSave, FALSE);
-     gtk_widget_set_sensitive(data->buttonSaveAs, FALSE);
-     data->saved = TRUE;
-
-     gtk_tool_item_set_expand( GTK_TOOL_ITEM(new), TRUE );
-     gtk_tool_item_set_expand( GTK_TOOL_ITEM(open), TRUE );
-     gtk_tool_item_set_expand( GTK_TOOL_ITEM(saveas), TRUE );
-
-     rec = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_RECORD); 
-     data->buttonRec = GTK_WIDGET(rec);
-     play = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_PLAY); 
-     data->buttonPlay = GTK_WIDGET(play);
-     stop = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_STOP);
-     
-     gtk_tool_item_set_expand( GTK_TOOL_ITEM(rec), TRUE );
-     gtk_tool_item_set_expand( GTK_TOOL_ITEM(play), TRUE );
-     gtk_tool_item_set_expand( GTK_TOOL_ITEM(stop), TRUE );
-
-     /* create separator */
-     sep  = gtk_separator_tool_item_new();
-
-     /* create the toolbar itself */
-     toolBar = GTK_TOOLBAR(gtk_toolbar_new());
-
-     /* add items to toolbar */
-     gtk_toolbar_insert(toolBar, new, -1);
-     gtk_toolbar_insert(toolBar, open, -1);
-     gtk_toolbar_insert(toolBar, saveas, -1);
-     gtk_toolbar_insert(toolBar, sep,  -1);
-     gtk_toolbar_insert(toolBar, rec, -1);
-     gtk_toolbar_insert(toolBar, play, -1);
-     gtk_toolbar_insert(toolBar, stop, -1);
-
-     /* connect signals */
-     g_signal_connect(G_OBJECT(new), "clicked",
-              G_CALLBACK(cbNew), 
-              data);
-     g_signal_connect(G_OBJECT(open), "clicked",
-              G_CALLBACK(cbOpen), 
-              data);
-     g_signal_connect(G_OBJECT(saveas), "clicked",
-              G_CALLBACK(cbSaveAs), 
-              data);
-     g_signal_connect(G_OBJECT(rec), "clicked",
-              G_CALLBACK(cbRec), 
-              data);
-     g_signal_connect(G_OBJECT(play), "clicked",
-              G_CALLBACK(cbPlay), 
-              data);
-     g_signal_connect(G_OBJECT(stop), "clicked",
-              G_CALLBACK(cbStop), 
-              data);
-
-     return GTK_WIDGET(toolBar);
-
-}
-
 static void cbItemGroupChanged( gpointer data )
 {
     AppData* app = (AppData* ) data;
@@ -1417,16 +1416,36 @@ static void cbItemClose(GtkWidget *widget, gpointer data)
 static void createMenu( AppData *data )
 {
     HildonAppMenu *menu;
+    GtkWidget *button_new;
+    GtkWidget *button_open;
+    GtkWidget *button_save;
     GtkWidget *button_email;
 
     menu = HILDON_APP_MENU( hildon_app_menu_new() );
+    button_new = hildon_gtk_button_new(HILDON_SIZE_AUTO);
+    gtk_button_set_label( GTK_BUTTON(button_new), "New");
+    button_open = hildon_gtk_button_new(HILDON_SIZE_AUTO);
+    gtk_button_set_label( GTK_BUTTON(button_open), "Open");
+    button_save = hildon_gtk_button_new(HILDON_SIZE_AUTO);
+    gtk_button_set_label( GTK_BUTTON(button_save), "Save");
     button_email = hildon_gtk_button_new(HILDON_SIZE_AUTO);
     gtk_button_set_label( GTK_BUTTON(button_email), "Send via email");
+
+    hildon_app_menu_append( menu, GTK_BUTTON(button_new));
+    hildon_app_menu_append( menu, GTK_BUTTON(button_open));
+    hildon_app_menu_append( menu, GTK_BUTTON(button_save));
     hildon_app_menu_append( menu, GTK_BUTTON(button_email));
-   
+    g_signal_connect(G_OBJECT(button_new), "clicked",
+              G_CALLBACK(cbNew),
+              data);
+    g_signal_connect(G_OBJECT(button_open), "clicked",
+              G_CALLBACK(cbOpen),
+              data);
+    g_signal_connect(G_OBJECT(button_save), "clicked",
+              G_CALLBACK(cbSaveAs),
+              data); 
     g_signal_connect( G_OBJECT( button_email ), "clicked",
         GTK_SIGNAL_FUNC (cbEmailing), data);
-
     
     gtk_widget_show_all( GTK_WIDGET(menu));
 
@@ -1434,6 +1453,22 @@ static void createMenu( AppData *data )
 
     data->filter = get_default_filter();
 
+    setFormatString(data, data->filter);
+
+}
+
+gboolean
+cbScaleRelease(GtkWidget *widget, GdkEventButton *ev, gpointer data)
+{
+    AppData* app = (AppData* ) data;
+  
+    if (getAppState(app) == APPSTATE_RECORDING || NULL == app->playPipeline)
+        return FALSE;
+
+    seekToTime(app->playPipeline, gtk_adjustment_get_value(app->mainViewData.adjustment));
+  
+    return FALSE;
+
 }
 
 gboolean
@@ -1443,13 +1478,13 @@ evKeypress(GtkWidget *widget, GdkEventKey *ev, AppData *appdata)
   switch (ev->keyval)
   {
     case GDK_Return:
-      cbRec(widget, appdata);
+      cbRec(widget, NULL, appdata);
       return TRUE;
     case GDK_Right:
-      cbPlay(widget, appdata);
+      cbPlay(widget, NULL, appdata);
       return TRUE;
     case GDK_Escape:
-      cbStop(widget, appdata);
+      cbStop(widget, NULL, appdata);
       return TRUE;
     default:
       break;
@@ -1464,17 +1499,25 @@ gboolean maemo_recorder_ui_new(AppData *data)
     HildonProgram *app = NULL;
     HildonWindow *window = NULL;
     GtkWidget *hbox = NULL;
-    GtkWidget *vbox = NULL;
     GtkWidget *label = NULL;
-    GtkWidget *entry1 = NULL;
-    GtkWidget *entry2 = NULL;
-    GtkWidget *entry3 = NULL;
+    GtkWidget *ctime = NULL;
+    GtkWidget *etime = NULL;
+    GtkWidget *filename = NULL;
+    GtkWidget *format = NULL;
+    GtkWidget *state = NULL;
     GtkWidget *toolBar = NULL;
     GtkWidget *infohbox = NULL;
     GtkWidget *table = NULL;
     GtkWidget *scale = NULL;
     GtkObject *adjustment = NULL;
 
+    GtkWidget *rec = NULL;
+    GtkWidget *play = NULL;
+    GtkWidget *stop = NULL;
+    GtkWidget *recimage = NULL;
+    GtkWidget *playimage = NULL;
+    GtkWidget *stopimage = NULL;
+
     g_assert(NULL != data);
 
     app = HILDON_PROGRAM(hildon_program_get_instance());
@@ -1487,78 +1530,21 @@ gboolean maemo_recorder_ui_new(AppData *data)
 
     /* content for main view */
 
-    /* create vbox, divides control area and view area */
-    vbox = gtk_vbox_new(FALSE, 0);
-
     /* create hbox to divide control area */
     hbox = gtk_hbox_new(FALSE, HILDON_MARGIN_DEFAULT);
 
     /* create toolbar */
-    toolBar = createToolBar(data);
 
     /* create table for labels */
-    table = gtk_table_new (4, 2, FALSE);
-    gtk_table_set_homogeneous(GTK_TABLE(table), FALSE);
+    table = gtk_table_new (6, 6, TRUE);
+    gtk_table_set_homogeneous(GTK_TABLE(table), TRUE);
 
     gtk_table_set_row_spacings (GTK_TABLE (table), 4);
     gtk_table_set_col_spacings (GTK_TABLE (table), HILDON_MARGIN_TRIPLE);
 
-    label = gtk_label_new_with_mnemonic(_("Filename:"));
-    gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
-    gtk_table_attach_defaults (GTK_TABLE (table),
-            label,
-            0, 1, 0, 1);
-
-    entry1 = gtk_entry_new();
-    gtk_entry_set_has_frame(GTK_ENTRY(entry1), FALSE);
-    gtk_entry_set_text(GTK_ENTRY (entry1), _(RECORDER_FILE_UNTITLED));
-    gtk_entry_set_editable(GTK_ENTRY(entry1), FALSE);
-    gtk_table_attach_defaults(GTK_TABLE (table), entry1, 1, 2, 0, 1);
-    gtk_label_set_mnemonic_widget(GTK_LABEL (label), entry1);
-
-    label = gtk_label_new_with_mnemonic (_("Length:"));
-    gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
-    gtk_table_attach_defaults (GTK_TABLE (table),
-            label,
-            0, 1, 1, 2);
-
-    entry2 = gtk_entry_new ();
-    gtk_entry_set_has_frame(GTK_ENTRY(entry2), FALSE);
-    gtk_entry_set_text (GTK_ENTRY (entry2), "0:00.00");
-    gtk_entry_set_editable(GTK_ENTRY(entry2), FALSE);
-    gtk_table_attach_defaults (GTK_TABLE (table), entry2, 1, 2, 1, 2);
-    gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry2);
-
-    /* audio format field */
-    label = gtk_label_new_with_mnemonic(_("Format:"));
-    gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
-    gtk_table_attach_defaults (GTK_TABLE (table),
-            label,
-            0, 1, 2, 3);
-
-    entry3 = gtk_entry_new();
-    gtk_entry_set_has_frame(GTK_ENTRY(entry3), FALSE);
-    gtk_entry_set_width_chars(GTK_ENTRY(entry3), 40);
-    gtk_entry_set_text (GTK_ENTRY (entry3), RECORDER_FMT_STRING_NONE);
-    gtk_entry_set_editable(GTK_ENTRY(entry3), FALSE);
-    data->mainViewData.formatEntry = GTK_WIDGET(entry3);
-    
-    gtk_table_attach_defaults (GTK_TABLE (table), entry3, 1, 2, 2, 3);
-    gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry3);
-
-    label = gtk_label_new_with_mnemonic(_("State:"));
-    gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
-    gtk_table_attach_defaults (GTK_TABLE (table),
-            label,
-            0, 1, 3, 4);
-
-    entry3 = gtk_entry_new ();
-    gtk_entry_set_has_frame(GTK_ENTRY(entry3), FALSE);
-    gtk_entry_set_text (GTK_ENTRY (entry3), RECORDER_MSG_READY);
-    gtk_entry_set_editable(GTK_ENTRY(entry3), FALSE);
-    gtk_table_attach_defaults (GTK_TABLE (table), entry3, 1, 2, 3, 4);
-    gtk_label_set_mnemonic_widget(GTK_LABEL (label), entry3);
-
+    filename = gtk_label_new(_(RECORDER_FILE_UNTITLED));
+    format = gtk_label_new(RECORDER_FMT_STRING_NONE);
+    state = gtk_label_new("");
     adjustment = gtk_adjustment_new (0.00,
                   0.00,
                   100.00,
@@ -1566,36 +1552,73 @@ gboolean maemo_recorder_ui_new(AppData *data)
                   0.01,
                   0);
 
+    ctime = gtk_label_new("00:00");
+    etime = gtk_label_new("00:00");
     scale = gtk_hscale_new(GTK_ADJUSTMENT(adjustment));
+    gtk_scale_set_draw_value(scale, FALSE);
+    gtk_box_pack_start(hbox, ctime, FALSE, FALSE, HILDON_MARGIN_DOUBLE);
+    gtk_box_pack_end(hbox, etime, FALSE, FALSE, HILDON_MARGIN_DOUBLE);
+    gtk_box_pack_end(hbox, scale, TRUE, TRUE, HILDON_MARGIN_DOUBLE);
+    gtk_box_set_homogeneous(hbox, FALSE);
       
-/*     gtk_table_attach_defaults (GTK_TABLE (table),
-                label,
-                0, 3, 2, 3);
-*/
+    gtk_table_attach_defaults(table, filename,
+                    1, 4, 1, 2);
+    gtk_table_attach_defaults(table, format,
+                    1, 4, 2, 3);
+    gtk_table_attach_defaults(table, state,
+                    1, 4, 3, 4);
+    gtk_table_attach_defaults(table, hbox,
+                    0, 5, 5, 6);
+
+
+    recimage = gtk_image_new_from_file(REC_ICON);
+    rec = gtk_event_box_new();
+    data->buttonRec = GTK_WIDGET(rec);
+    gtk_container_add(rec, recimage);
+    playimage = gtk_image_new_from_file(PLAY_ICON);
+    play = gtk_event_box_new();
+    data->buttonPlay = GTK_WIDGET(play);
+    gtk_container_add(play, playimage);
+    stopimage = gtk_image_new_from_file(STOP_ICON);
+    stop = gtk_event_box_new();
+    gtk_container_add(stop, stopimage);
+
+    gtk_table_attach_defaults(table, rec,
+                    5, 6, 4, 6);
+    gtk_table_attach_defaults(table, play,
+                    5, 6, 2, 4);
+    gtk_table_attach_defaults(table, stop,
+                    5, 6, 0, 2);
+
+
     /* connect signals */
-    g_signal_connect(G_OBJECT(adjustment), "value-changed", G_CALLBACK(cbUserSeek), data);
-    g_signal_connect(G_OBJECT(scale), "format-value", G_CALLBACK(cbFormatSeekbarValue), data);
+    g_signal_connect(G_OBJECT(scale), "button-release-event", G_CALLBACK(cbScaleRelease), data);
     g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(cbDestroy), data);
     g_signal_connect(G_OBJECT(window), "key-press-event",
             G_CALLBACK(evKeypress), data);
 
+     g_signal_connect(G_OBJECT(rec), "button-release-event",
+              G_CALLBACK(cbRec),
+              data);
+     g_signal_connect(G_OBJECT(play), "button-release-event",
+              G_CALLBACK(cbPlay),
+              data);
+     g_signal_connect(G_OBJECT(stop), "button-release-event",
+              G_CALLBACK(cbStop),
+              data);
+
+
     /* packing the view */
-    gtk_container_add (GTK_CONTAINER(window), vbox);
-    infohbox = gtk_hbox_new(FALSE, 0);
-    gtk_box_pack_start (GTK_BOX(infohbox), table, FALSE, TRUE, 0);
-    gtk_box_pack_start (GTK_BOX(vbox), infohbox, FALSE, TRUE, 0);
-    gtk_box_pack_start (GTK_BOX(vbox), scale, FALSE, FALSE, 0);
-/*    gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 0); */
+    gtk_container_add(GTK_CONTAINER(window), table);
     
-    hildon_window_add_toolbar(window, GTK_TOOLBAR(toolBar)); 
-
     /* store needed widgets */
     data->app = app;
     data->mainView = window;
-    data->mainViewData.toolBar = GTK_WIDGET(toolBar);
-    data->mainViewData.fileNameEntry = GTK_WIDGET(entry1);
-    data->mainViewData.lengthEntry = GTK_WIDGET(entry2);
-    data->mainViewData.stateEntry = GTK_WIDGET(entry3);
+    data->mainViewData.fileNameEntry = GTK_WIDGET(filename);
+    data->mainViewData.formatEntry = GTK_WIDGET(format);
+    data->mainViewData.lengthEntry = GTK_WIDGET(etime);
+    data->mainViewData.ctime = GTK_WIDGET(ctime);
+    data->mainViewData.stateEntry = GTK_WIDGET(state);
     data->mainViewData.adjustment = GTK_OBJECT(adjustment);
 
     /* show the app */
@@ -1680,7 +1703,7 @@ setFormatString(AppData *data, AudioFormat afmt)
     gint bits = 8;
 
     g_assert(data);
-    g_assert(GTK_IS_ENTRY(data->mainViewData.formatEntry));
+    g_assert(GTK_IS_LABEL(data->mainViewData.formatEntry));
 
     switch (afmt)
     {
@@ -1705,12 +1728,12 @@ setFormatString(AppData *data, AudioFormat afmt)
             bits = PCM_WIDTH;
             break;
         default:
-            gtk_entry_set_text(GTK_ENTRY(data->mainViewData.formatEntry), RECORDER_FMT_STRING_NONE);
+            gtk_label_set_text(GTK_LABEL(data->mainViewData.formatEntry), RECORDER_FMT_STRING_NONE);
             return;
     }
 
-    str = g_strdup_printf("%s, %d %s, %d Hz, %d %s", format, channels, _("ch"), rate, bits, _("bits"));
-    gtk_entry_set_text(GTK_ENTRY(data->mainViewData.formatEntry), str);
+    str = g_strdup_printf("%s, %d %s, %d kHz, %d %s", format, channels, _("ch"), rate/1000, bits, _("bits"));
+    gtk_label_set_text(GTK_LABEL(data->mainViewData.formatEntry), str);
     g_free(str);
 }
 
@@ -1736,12 +1759,12 @@ static void setLength(AppData *data, gdouble secs)
         secs -= mins * 60.0;
     }
 
-    tmp = g_strdup_printf("%u:%05.2f", mins, secs);
+    tmp = g_strdup_printf("%02u:%02d", mins, (int)secs);
 
     /*
     ULOG_INFO("Setting length to %s", tmp);
     */
-    gtk_entry_set_text(GTK_ENTRY(data->mainViewData.lengthEntry), 
+    gtk_label_set_text(GTK_LABEL(data->mainViewData.lengthEntry), 
                  tmp);
     g_free(tmp);
 }
@@ -1832,15 +1855,7 @@ static gboolean cbStopPlayback(AppData *data)
     ULOG_INFO("Stopping playback");
    
     g_assert(data != NULL);
-
-    ret = gst_element_set_state(GST_ELEMENT(data->playPipeline), 
-                        GST_STATE_PAUSED);
-    if (seekToZero(data, GST_ELEMENT(data->playPipeline)))
-    {
-        gtk_adjustment_set_value( 
-           GTK_ADJUSTMENT(data->mainViewData.adjustment), 0);
-        gtk_adjustment_value_changed(GTK_ADJUSTMENT(data->mainViewData.adjustment));
-    }
+    destroyPipelines(data);
     setAppState(data, APPSTATE_READY);
     gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(data->buttonPlay), GTK_STOCK_MEDIA_PLAY);
     gtk_widget_set_state(data->buttonPlay, GTK_STATE_NORMAL);
@@ -1850,13 +1865,12 @@ static gboolean cbStopPlayback(AppData *data)
 
 static void cbUserSeek(GtkAdjustment *adjustment, gpointer data)
 {   
-    /*ULOG_INFO("cbUserSeek");*/
     AppData *app;
 
     g_return_if_fail(data != NULL);
     app = (AppData *) data;
 
-    if (getAppState(app) != APPSTATE_READY || NULL == app->playPipeline)
+    if (getAppState(app) != APPSTATE_READY && getAppState(app) != APPSTATE_PAUSED || NULL == app->playPipeline)
         return;
 
     seekToTime(app->playPipeline, gtk_adjustment_get_value(adjustment));
@@ -1885,22 +1899,13 @@ static gboolean cbUpdateRecLength(AppData *data)
     gdouble secs;
     gchar *tmp;
 
-    if (gettimeofday(&tv, NULL) != 0)
-        return FALSE;
-
-    secs = tv.tv_sec - data->recStartTv.tv_sec;
-    secs += ((tv.tv_usec - data->recStartTv.tv_usec) / 1000000.0);
+    data->rectime += REC_UPDATE_INTERVAL/1000.0;
 
-    if (secs >= 60.0)
-    {
-        mins = secs / 60;
-        secs -= mins * 60.0;
-        tmp = g_strdup_printf("%u:%05.2f", mins, secs);
-    }
-    else
-        tmp = g_strdup_printf("%0.2f", secs);
+    mins = data->rectime / 60;
+    secs = data->rectime - (mins * 60.0);
+    tmp = g_strdup_printf("%02u:%02d", mins, (int)secs);
 
-    gtk_entry_set_text(GTK_ENTRY(data->mainViewData.lengthEntry), 
+    gtk_label_set_text(GTK_LABEL(data->mainViewData.lengthEntry), 
                  tmp);
     g_free(tmp);