marlin r1306 - in trunk: marlin src



Author: iain
Date: Sat Oct 11 13:44:43 2008
New Revision: 1306
URL: http://svn.gnome.org/viewvc/marlin?rev=1306&view=rev

Log:
Destroy save pipeline when it is finished
Use giosrc for loading


Modified:
   trunk/marlin/ChangeLog
   trunk/marlin/marlin-load-pipeline.c
   trunk/src/ChangeLog
   trunk/src/marlin-window.c

Modified: trunk/marlin/marlin-load-pipeline.c
==============================================================================
--- trunk/marlin/marlin-load-pipeline.c	(original)
+++ trunk/marlin/marlin-load-pipeline.c	Sat Oct 11 13:44:43 2008
@@ -491,6 +491,24 @@
 	return TRUE;
 }
 
+static GstElement *
+make_source (void)
+{
+	char *srcs[] = { "giosrc", "gnomevfssrc", "filesrc", NULL };
+	int i;
+
+	for (i = 0; srcs[i]; i++) {
+		GstElement *src;
+
+		src = gst_element_factory_make (srcs[i], "src");
+		if (src) {
+			return src;
+		}
+	}
+
+	return NULL;
+}
+
 static void
 marlin_load_pipeline_init (MarlinLoadPipeline *pipeline)
 {
@@ -502,7 +520,10 @@
 
 	priv->sinks = g_ptr_array_new ();
 
-	priv->src = gst_element_factory_make ("gnomevfssrc", "src");
+	priv->src = make_source();
+	if (priv->src == NULL) {
+		g_warning ("No source available for load pipeline.");
+	}
 	priv->decoder = gst_element_factory_make ("decodebin", "decoder");
 	g_signal_connect (G_OBJECT (priv->decoder), "unknown-type",
 			  G_CALLBACK (unknown_type_cb), pipeline);

Modified: trunk/src/marlin-window.c
==============================================================================
--- trunk/src/marlin-window.c	(original)
+++ trunk/src/marlin-window.c	Sat Oct 11 13:44:43 2008
@@ -2915,10 +2915,7 @@
 
 	pipeline = marlin_load_pipeline_new (operation);
 	lod->pipeline = (MarlinPipeline *) pipeline;
-#if 0
-	g_signal_connect (G_OBJECT (pipeline), "shutdown",
-			  G_CALLBACK (load_pipeline_shutdown), lod);
-#endif
+
 	g_object_set (G_OBJECT (pipeline),
 		      "filename", filename,
 		      "sample", window->priv->sample,
@@ -2951,7 +2948,7 @@
 
 	text = g_strdup_printf (_("Saving %s"), filename);
 	g_free (filename);
-	
+
 	tmp = g_strdup_printf ("<span weight=\"bold\">%s</span>\n%s",
 			       _("Saving file"), text);
 	g_free (text);
@@ -2960,7 +2957,7 @@
 									 GTK_WINDOW (window),
 									 tmp, NULL);
 	g_free (tmp);
-	
+
 	/* Show the window immediatly */
 	gtk_widget_show (GTK_WIDGET (window->priv->save_progress_window));
 }
@@ -2972,7 +2969,7 @@
 	MarlinWindow *window = sod->window;
 	MarlinWindowPrivate *priv = window->priv;
 	MarlinPipeline *pipeline;
-	
+
 	gtk_widget_destroy (GTK_WIDGET (priv->save_progress_window));
 	window->priv->save_progress_window = NULL;
 
@@ -2981,7 +2978,7 @@
 
 	/* Reset the time of last save */
 	window->priv->last_save = time (NULL);
-	
+
 	g_object_set (G_OBJECT (priv->sample),
 		      "dirty", FALSE,
 		      NULL);
@@ -2996,6 +2993,11 @@
 	}
 
 	gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
+	g_object_unref (pipeline);
+
+	g_free (sod->filename);
+	g_free (sod->temp_filename);
+	g_free (sod);
 }
 
 static void
@@ -3005,11 +3007,16 @@
 	MarlinWindow *window = sod->window;
 	MarlinWindowPrivate *priv = window->priv;
 	MarlinPipeline *pipeline = sod->pipeline;
-	
+
 	gtk_widget_destroy (GTK_WIDGET (priv->save_progress_window));
 	priv->save_progress_window = NULL;
 
 	gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
+	g_object_unref (pipeline);
+
+	g_free (sod->filename);
+	g_free (sod->temp_filename);
+	g_free (sod);
 }
 
 static void
@@ -3017,23 +3024,10 @@
 		gboolean paused,
 		struct _save_op_data *sod)
 {
-	gst_element_set_state (GST_ELEMENT (sod->pipeline), 
+	gst_element_set_state (GST_ELEMENT (sod->pipeline),
 			       paused ? GST_STATE_PAUSED : GST_STATE_PLAYING);
 }
 
-static void
-save_shutdown (MarlinPipeline *pipeline,
-	       struct _save_op_data *sod)
-{
-	g_print ("Save shutdown\n");
-
-	g_object_unref (G_OBJECT (pipeline));
-
-	g_free (sod->filename);
-	g_free (sod->temp_filename);
-	g_free (sod);
-}
-
 /* FIXME: Pass this as MarlinBaseWindow? */
 typedef void (* options_dialog) (GtkWindow *window, MarlinPipeline *pipeline);
 struct _maps {
@@ -3150,8 +3144,6 @@
 	}
 
 	sod->pipeline = (MarlinPipeline *) pipeline;
-	g_signal_connect (G_OBJECT (pipeline), "shutdown",
-			  G_CALLBACK (save_shutdown), sod);
 
 	if (encoder != NULL) {
 		/* Caller has supplied an encoder, so the parameters have
@@ -3280,12 +3272,12 @@
 	GtkWidget *overwrite;
 	char *text;
 	char *backup;
-	
+
 	/* Ask to overwrite */
 	text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n%s",
 				_("The file '%s' already exists."),
 				_("Do you want to make a backup called '%s' first?"));
-	
+
 	backup = g_strdup_printf ("%s~", name);
 	overwrite = gtk_message_dialog_new_with_markup (window,
 							GTK_DIALOG_MODAL,
@@ -3293,10 +3285,10 @@
 							GTK_BUTTONS_NONE,
 							text, name, backup);
 	g_free (text);
-	
+
 	/* Naughty */
 	gtk_label_set_line_wrap (GTK_LABEL (GTK_MESSAGE_DIALOG (overwrite)->label), FALSE);
-	
+
 	gtk_dialog_add_button (GTK_DIALOG (overwrite),
 			       _("Overwrite File"),
 			       GTK_RESPONSE_NO);
@@ -3306,30 +3298,30 @@
 	gtk_dialog_add_button (GTK_DIALOG (overwrite),
 			       _("Backup File"),
 			       GTK_RESPONSE_YES);
-	
+
 	switch (gtk_dialog_run (GTK_DIALOG (overwrite))) {
 	case GTK_RESPONSE_YES:
 		gtk_widget_destroy (overwrite);
-		
+
 		if (marlin_file_copy (name, backup, NULL) == FALSE) {
 			g_warning ("Error making backup...Not saving so that there is no data loss");
 			g_free (backup);
 			return FALSE;
 		}
-		
+
 		g_free (backup);
 		return TRUE;
-		
+
 	case GTK_RESPONSE_NO:
 		gtk_widget_destroy (overwrite);
 		g_free (backup);
-		
+
 		return TRUE;
-		
+
 	default:
 		gtk_widget_destroy (overwrite);
 		g_free (backup);
-		
+
 		return FALSE;
 	}
 }
@@ -3341,35 +3333,35 @@
 {
 	GtkWidget *overwrite;
 	char *text;
-	
+
 	/* Ask to overwrite */
 	text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n%s",
 				_("The file '%s' already exists."),
 				_("There is not enough space to create a backup.\nDo you want to overwrite the file?"));
-	
+
 	overwrite = gtk_message_dialog_new (window,
 					    GTK_DIALOG_MODAL,
 					    GTK_MESSAGE_QUESTION,
 					    GTK_BUTTONS_NONE,
 					    text, name);
 	g_free (text);
-	
+
 	/* Naughty */
 	gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (overwrite)->label), TRUE);
 	gtk_label_set_line_wrap (GTK_LABEL (GTK_MESSAGE_DIALOG (overwrite)->label), FALSE);
-	
+
 	gtk_dialog_add_button (GTK_DIALOG (overwrite),
 			       GTK_STOCK_CANCEL,
 			       GTK_RESPONSE_CANCEL);
 	gtk_dialog_add_button (GTK_DIALOG (overwrite),
 			       _("Overwrite File"),
 			       GTK_RESPONSE_YES);
-	
+
 	switch (gtk_dialog_run (GTK_DIALOG (overwrite))) {
 	case GTK_RESPONSE_YES:
 		gtk_widget_destroy (overwrite);
 		return TRUE;
-		
+
 	default:
 		gtk_widget_destroy (overwrite);
 		return FALSE;
@@ -3383,7 +3375,7 @@
 	if (g_file_test (name, G_FILE_TEST_EXISTS) == FALSE) {
 		return TRUE;
 	}
-	
+
 	if (g_file_test (name, G_FILE_TEST_IS_DIR)) {
 		GtkWidget *isdir;
 		char *text;



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