[gnome-media] Use names based on date insetad of wort "Untitled".



commit 8ccd7a9b2bb4ca31fc2056c705411b14c9ed21b9
Author: Alexey Fisher <bug-track fisher-privat net>
Date:   Mon Jul 12 13:18:56 2010 +0200

    Use names based on date insetad of wort "Untitled".
    
    Use names based on date insetad of wort "Untitled".
    For example:
    was - Untitled.ogg
    now - 2009-09-21-190728.ogg
    Also remove window name update from gsr-window.c, it didn't worked correctly
    before and now it is use less.
    
    Fixes-Bug: https://bugzilla.gnome.org/show_bug.cgi?id=595867
    Signed-off-by: Oleksij Rempel <bug-track fisher-privat net>

 grecord/src/gnome-recorder.c |   19 +-------------
 grecord/src/gsr-window.c     |   53 +++++++++++++++++++----------------------
 grecord/src/gsr-window.h     |    1 +
 3 files changed, 28 insertions(+), 45 deletions(-)
---
diff --git a/grecord/src/gnome-recorder.c b/grecord/src/gnome-recorder.c
index 9ae952c..c6c7b7e 100644
--- a/grecord/src/gnome-recorder.c
+++ b/grecord/src/gnome-recorder.c
@@ -124,29 +124,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 8fc94bf..ed12b0a 100644
--- a/grecord/src/gsr-window.c
+++ b/grecord/src/gsr-window.c
@@ -801,17 +801,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)
 {
@@ -1704,16 +1693,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);
 
@@ -1732,20 +1743,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;
 }
 
@@ -2127,7 +2124,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, "<shift><control>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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]