diff --git a/grecord/src/gnome-recorder.c b/grecord/src/gnome-recorder.c index c3eed34..31ba50e 100644 --- a/grecord/src/gnome-recorder.c +++ b/grecord/src/gnome-recorder.c @@ -123,29 +123,14 @@ gsr_add_recent (gchar *filename) } -/* Also referenced from gsr-window.c */ -gint gsr_sample_count = 1; - GtkWidget * gsr_open_window (const char *filename) { GtkWidget *window; - char *utf8_name; - char *name; + gchar *name; if (filename == NULL) { - /* Translator comment: untitled here implies that - * there is no active sound sample. Any newly - * recorded samples will be saved to disk with this - * name as default value. */ - if (gsr_sample_count == 1) { - utf8_name = g_strdup (_("Untitled")); - } else { - utf8_name = g_strdup_printf (_("Untitled-%d"), gsr_sample_count); - } - name = g_filename_from_utf8 (utf8_name, -1, NULL, NULL, NULL); - g_free (utf8_name); - ++gsr_sample_count; + name = gsr_generate_filename (); } else { name = g_strdup (filename); } diff --git a/grecord/src/gsr-window.c b/grecord/src/gsr-window.c index df92ef3..091216d 100644 --- a/grecord/src/gsr-window.c +++ b/grecord/src/gsr-window.c @@ -800,17 +800,6 @@ file_save_as_cb (GtkAction *action, } static void -file_save_cb (GtkAction *action, - GSRWindow *window) -{ - if (!window->priv->has_file) { - file_save_as_cb (NULL, window); - } else { - do_save_file (window, window->priv->filename); - } -} - -static void run_mixer_cb (GtkAction *action, GSRWindow *window) { @@ -1705,16 +1694,38 @@ record_eos_msg_cb (GstBus * bus, GstMessage * msg, GSRWindow * window) window->priv->has_file = TRUE; } -extern int gsr_sample_count; +gchar* +gsr_generate_filename (void) +{ + struct tm *ptr; + time_t tm; + + gchar *date = g_malloc (18); + tm = time (NULL); + ptr = localtime (&tm); + strftime (date, 18, "%Y-%m-%d-%H%M%S", ptr); + + return date; +} static gboolean record_start (gpointer user_data) { GSRWindow *window = GSR_WINDOW (user_data); - gchar *name; + gchar *title; g_assert (window->priv->tick_id == 0); + g_free (window->priv->filename); + window->priv->filename = gsr_generate_filename (); + gtk_label_set_text (GTK_LABEL (window->priv->name_label), + window->priv->filename); + title = g_strdup_printf (_("%s — Sound Recorder"), + window->priv->filename); + gtk_window_set_title (GTK_WINDOW (window), title); + + g_free (title); + window->priv->get_length_attempts = 16; window->priv->tick_id = g_timeout_add (200, (GSourceFunc) record_tick_callback, window); @@ -1733,20 +1744,6 @@ record_start (gpointer user_data) window->priv->record_id = 0; - /* Translator comment: untitled here implies that - * there is no active sound sample. Any newly - * recorded samples will be saved to disk with this - * name as default value. */ - if (gsr_sample_count == 1) { - name = g_strdup (_("Untitled")); - } else { - name = g_strdup_printf (_("Untitled-%d"), gsr_sample_count); - } - ++gsr_sample_count; - gtk_window_set_title (GTK_WINDOW(window), name); - - g_free (name); - return FALSE; } @@ -2128,7 +2125,7 @@ static const GtkActionEntry menu_entries[] = { "FileOpen", GTK_STOCK_OPEN, NULL, NULL, N_("Open a file"), G_CALLBACK (file_open_cb) }, { "FileSave", GTK_STOCK_SAVE, NULL, NULL, - N_("Save the current file"), G_CALLBACK (file_save_cb) }, + N_("Save the current file"), G_CALLBACK (file_save_as_cb) }, { "FileSaveAs", GTK_STOCK_SAVE_AS, NULL, "S", N_("Save the current file with a different name"), G_CALLBACK (file_save_as_cb) }, { "RunMixer", GTK_STOCK_EXECUTE, N_("Open Volu_me Control"), NULL, diff --git a/grecord/src/gsr-window.h b/grecord/src/gsr-window.h index 6b5a67e..2506a5e 100644 --- a/grecord/src/gsr-window.h +++ b/grecord/src/gsr-window.h @@ -57,5 +57,6 @@ GtkWidget* gsr_window_new (const char *filename); void gsr_window_close (GSRWindow *window); gboolean gsr_window_is_saved (GSRWindow *window); gboolean gsr_discard_confirmation_dialog (GSRWindow *window, gboolean closing); +gchar* gsr_generate_filename (void); #endif