brasero r1924 - in trunk: . src



Author: philippr
Date: Mon Feb 16 17:08:21 2009
New Revision: 1924
URL: http://svn.gnome.org/viewvc/brasero?rev=1924&view=rev

Log:
2009-02-16  Philippe Rouquier  <ykw localhost localdomain>

	When an image is detected while going through the files in burn:// and
	if the user wants to burn it, don't crash ... it won't help.

	* src/brasero-app.c (brasero_app_recent_open):
	* src/brasero-data-disc.c (brasero_data_disc_image_uri_cb),
	(brasero_data_disc_reset):
	* src/brasero-data-vfs.c (brasero_data_vfs_loading_node_result):
	* src/brasero-project-manager.c (brasero_project_manager_switch),
	(brasero_project_manager_type_changed_cb),
	(brasero_project_manager_new_empty_prj_cb),
	(brasero_project_manager_new_audio_prj_cb),
	(brasero_project_manager_new_data_prj_cb),
	(brasero_project_manager_new_video_prj_cb),
	(brasero_project_manager_new_copy_prj_cb),
	(brasero_project_manager_new_iso_prj_cb),
	(brasero_project_manager_data), (brasero_project_manager_audio),
	(brasero_project_manager_video), (brasero_project_manager_open_cb),
	(brasero_project_manager_recent_clicked_cb):
	* src/brasero-project-manager.h:
	* src/brasero-project.c (_wait_for_ready_state),
	(brasero_project_check_status), (brasero_project_switch),
	(brasero_project_set_none):
	* src/brasero-src-image.c (brasero_src_image_image_info_cb):
	* src/burn-task.c (brasero_task_set_track_output_size_default):
	* src/burn-track.c (brasero_track_get_image_size):
	* src/main.c (brasero_handle_burn_uri), (brasero_app_open_project),
	(brasero_app_parse_options):

Modified:
   trunk/ChangeLog
   trunk/src/brasero-app.c
   trunk/src/brasero-data-disc.c
   trunk/src/brasero-data-vfs.c
   trunk/src/brasero-project-manager.c
   trunk/src/brasero-project-manager.h
   trunk/src/brasero-project.c
   trunk/src/brasero-src-image.c
   trunk/src/burn-task.c
   trunk/src/burn-track.c
   trunk/src/main.c

Modified: trunk/src/brasero-app.c
==============================================================================
--- trunk/src/brasero-app.c	(original)
+++ trunk/src/brasero-app.c	Mon Feb 16 17:08:21 2009
@@ -1150,7 +1150,6 @@
 	}
 
 	/* Make sure it is no longer one shot */
-	brasero_project_manager_set_oneshot (BRASERO_PROJECT_MANAGER (priv->projects), FALSE);
 	brasero_project_manager_open_by_mime (BRASERO_PROJECT_MANAGER (priv->projects),
 					      uri,
 					      mime);

Modified: trunk/src/brasero-data-disc.c
==============================================================================
--- trunk/src/brasero-data-disc.c	(original)
+++ trunk/src/brasero-data-disc.c	Mon Feb 16 17:08:21 2009
@@ -732,32 +732,6 @@
 		brasero_file_filtered_remove (BRASERO_FILE_FILTERED (priv->filter), uri);
 }
 
-struct _BraseroDataDiscProjectSwitch {
-	gchar *uri;
-	BraseroDataDisc *disc;
-};
-typedef struct _BraseroDataDiscProjectSwitch BraseroDataDiscProjectSwitch;
-
-static gboolean
-brasero_data_disc_switch_to_image (gpointer data)
-{
-	GtkWidget *manager;
-	BraseroDataDiscPrivate *priv;
-	BraseroDataDiscProjectSwitch *callback_data = data;
-
-	priv = BRASERO_DATA_DISC_PRIVATE (callback_data->disc);
-
-	/* Clean up everything to avoid warning dialog */
-	brasero_data_project_reset (priv->project);
-
-	/* Tell project manager to switch */
-	manager = brasero_app_get_project_manager (brasero_app_get_default ());
-	brasero_project_manager_iso (BRASERO_PROJECT_MANAGER (manager),
-				     callback_data->uri);
-
-	return FALSE;
-}
-
 static BraseroBurnResult
 brasero_data_disc_image_uri_cb (BraseroDataVFS *vfs,
 				const gchar *uri,
@@ -768,8 +742,8 @@
 	gchar *string;
 	GtkWidget *button;
 	GtkWidget *dialog;
+	GtkWidget *manager;
 	BraseroDataDiscPrivate *priv;
-	BraseroDataDiscProjectSwitch *callback_data;
 
 	priv = BRASERO_DATA_DISC_PRIVATE (self);
 
@@ -806,10 +780,10 @@
 	if (answer != GTK_RESPONSE_YES)
 		return BRASERO_BURN_OK;
 
-	callback_data = g_new (BraseroDataDiscProjectSwitch, 1);
-	callback_data->disc = self;
-	callback_data->uri = g_strdup (uri);
-	g_idle_add (brasero_data_disc_switch_to_image, callback_data);
+	/* Tell project manager to switch. First function to avoid warnings */
+	brasero_data_project_reset (priv->project);
+	manager = brasero_app_get_project_manager (brasero_app_get_default ());
+	brasero_project_manager_iso (BRASERO_PROJECT_MANAGER (manager), uri);
 
 	return BRASERO_BURN_CANCEL;
 }
@@ -1410,7 +1384,9 @@
 	brasero_file_filtered_clear (BRASERO_FILE_FILTERED (priv->filter));
 	brasero_disc_size_changed (disc, 0);
 
-	gdk_window_set_cursor (GTK_WIDGET (disc)->window, NULL);
+	if (GTK_WIDGET (disc)->window)
+		gdk_window_set_cursor (GTK_WIDGET (disc)->window, NULL);
+
 	gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 0);
 }
 

Modified: trunk/src/brasero-data-vfs.c
==============================================================================
--- trunk/src/brasero-data-vfs.c	(original)
+++ trunk/src/brasero-data-vfs.c	Mon Feb 16 17:08:21 2009
@@ -693,6 +693,8 @@
 
 		result = brasero_data_vfs_emit_image_signal (self, uri);
 		if (result == BRASERO_BURN_CANCEL) {
+			/* recheck the node as a reset may have been done */
+			nodes = g_hash_table_lookup (priv->loading, registered);
 			for (iter = nodes; iter; iter = iter->next) {
 				BraseroFileNode *node;
 				guint reference;

Modified: trunk/src/brasero-project-manager.c
==============================================================================
--- trunk/src/brasero-project-manager.c	(original)
+++ trunk/src/brasero-project-manager.c	Mon Feb 16 17:08:21 2009
@@ -170,8 +170,6 @@
 	guint status_ctx;
 
 	GtkActionGroup *action_group;
-
-	guint oneshot:1;
 };
 
 #define BRASERO_PROJECT_MANAGER_CONNECT_CHANGED(manager, container)		\
@@ -526,12 +524,6 @@
 	||  manager->priv->type == BRASERO_PROJECT_TYPE_VIDEO) {
 		if (!brasero_project_confirm_switch (BRASERO_PROJECT (manager->priv->project)))
 			return;
-
-		if (manager->priv->oneshot) {
-			/* Here we may have to close brasero altogether */
-			gtk_widget_destroy (toplevel);
-			return;
-		}
 	}
 
 	if (manager->priv->status_ctx) {
@@ -606,12 +598,12 @@
 		if (toplevel)
 			gtk_window_set_title (GTK_WINDOW (toplevel), _("Brasero - New Image File"));
 
-		brasero_app_burn_image (brasero_app_get_default (), uri);
 		brasero_project_manager_switch (manager,
 						BRASERO_PROJECT_TYPE_INVALID,
 						NULL,
 						NULL,
 						TRUE);
+		brasero_app_burn_image (brasero_app_get_default (), uri);
 	}
 	else if (type == BRASERO_PROJECT_TYPE_COPY) {
 		brasero_layout_load (BRASERO_LAYOUT (manager->priv->layout), BRASERO_LAYOUT_NONE);
@@ -623,12 +615,12 @@
 		if (toplevel)
 			gtk_window_set_title (GTK_WINDOW (toplevel), _("Brasero - Disc Copy"));
 
-		brasero_app_copy_disc (brasero_app_get_default (), uri, NULL);
 		brasero_project_manager_switch (manager,
 						BRASERO_PROJECT_TYPE_INVALID,
 						NULL,
 						NULL,
 						TRUE);
+		brasero_app_copy_disc (brasero_app_get_default (), uri, NULL);
 	}
 }
 
@@ -637,66 +629,49 @@
 					 BraseroProjectType type,
 					 BraseroProjectManager *manager)
 {
-	manager->priv->oneshot = FALSE;
 	brasero_project_manager_switch (manager, type, NULL, NULL, TRUE);
 }
 
 static void
 brasero_project_manager_new_empty_prj_cb (GtkAction *action, BraseroProjectManager *manager)
 {
-	manager->priv->oneshot = FALSE;
 	brasero_project_manager_switch (manager, BRASERO_PROJECT_TYPE_INVALID, NULL, NULL, TRUE);
 }
 
 static void
 brasero_project_manager_new_audio_prj_cb (GtkAction *action, BraseroProjectManager *manager)
 {
-	manager->priv->oneshot = FALSE;
 	brasero_project_manager_switch (manager, BRASERO_PROJECT_TYPE_AUDIO, NULL, NULL, TRUE);
 }
 
 static void
 brasero_project_manager_new_data_prj_cb (GtkAction *action, BraseroProjectManager *manager)
 {
-	manager->priv->oneshot = FALSE;
 	brasero_project_manager_switch (manager, BRASERO_PROJECT_TYPE_DATA, NULL, NULL, TRUE);
 }
 
 static void
 brasero_project_manager_new_video_prj_cb (GtkAction *action, BraseroProjectManager *manager)
 {
-	manager->priv->oneshot = FALSE;
 	brasero_project_manager_switch (manager, BRASERO_PROJECT_TYPE_VIDEO, NULL, NULL, TRUE);
 }
 
 static void
 brasero_project_manager_new_copy_prj_cb (GtkAction *action, BraseroProjectManager *manager)
 {
-	manager->priv->oneshot = FALSE;
 	brasero_project_manager_switch (manager, BRASERO_PROJECT_TYPE_COPY, NULL, NULL, TRUE);
 }
 
 static void
 brasero_project_manager_new_iso_prj_cb (GtkAction *action, BraseroProjectManager *manager)
 {
-	manager->priv->oneshot = FALSE;
 	brasero_project_manager_switch (manager, BRASERO_PROJECT_TYPE_ISO, NULL, NULL, TRUE);
 }
 
 void
-brasero_project_manager_audio (BraseroProjectManager *manager,
-			       GSList *uris)
-{
-	brasero_project_manager_switch (manager,
-					BRASERO_PROJECT_TYPE_AUDIO,
-					uris,
-					NULL,
-					TRUE);
-}
-
-void
 brasero_project_manager_data (BraseroProjectManager *manager,
-			      GSList *uris)
+			      GSList *uris,
+			      gboolean burn)
 {
 	gchar *burn_URI = NULL;
 
@@ -706,9 +681,8 @@
 		uris = g_slist_prepend (NULL, burn_URI);
 	}
 
-	if (manager->priv->oneshot) {
-		brasero_project_set_data (BRASERO_PROJECT (manager->priv->project),
-					  uris);
+	if (burn) {
+		brasero_project_set_data (BRASERO_PROJECT (manager->priv->project), uris);
 		brasero_project_burn (BRASERO_PROJECT (manager->priv->project));
 	}
 	else
@@ -717,7 +691,7 @@
 						uris,
 						NULL,
 						TRUE);
-	
+
 	if (burn_URI) {
 		g_slist_free (uris);
 		g_free (burn_URI);
@@ -725,14 +699,37 @@
 }
 
 void
+brasero_project_manager_audio (BraseroProjectManager *manager,
+			       GSList *uris,
+			       gboolean burn)
+{
+	if (burn) {
+		brasero_project_set_audio (BRASERO_PROJECT (manager->priv->project), uris);
+		brasero_project_burn (BRASERO_PROJECT (manager->priv->project));
+	}
+	else
+		brasero_project_manager_switch (manager,
+						BRASERO_PROJECT_TYPE_AUDIO,
+						uris,
+						NULL,
+						TRUE);
+}
+
+void
 brasero_project_manager_video (BraseroProjectManager *manager,
-			       GSList *uris)
+			       GSList *uris,
+			       gboolean burn)
 {
-	brasero_project_manager_switch (manager,
-					BRASERO_PROJECT_TYPE_VIDEO,
-					uris,
-					NULL,
-					TRUE);
+	if (burn) {
+		brasero_project_set_video (BRASERO_PROJECT (manager->priv->project), uris);
+		brasero_project_burn (BRASERO_PROJECT (manager->priv->project));
+	}
+	else
+		brasero_project_manager_switch (manager,
+						BRASERO_PROJECT_TYPE_VIDEO,
+						uris,
+						NULL,
+						TRUE);
 }
 
 void
@@ -958,7 +955,6 @@
 	uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser));
 	gtk_widget_destroy (chooser);
 
-	manager->priv->oneshot = FALSE;
 	brasero_project_manager_open_uri (manager, uri);
 	g_free (uri);
 }
@@ -968,18 +964,10 @@
 					   const gchar *uri,
 					   BraseroProjectManager *manager)
 {
-	manager->priv->oneshot = FALSE;
 	brasero_project_manager_open_uri (manager, uri);
 }
 
 void
-brasero_project_manager_set_oneshot (BraseroProjectManager *manager,
-				     gboolean oneshot)
-{
-	manager->priv->oneshot = oneshot;
-}
-
-void
 brasero_project_manager_empty (BraseroProjectManager *manager)
 {
 	brasero_project_manager_switch (manager, BRASERO_PROJECT_TYPE_INVALID, NULL, NULL, TRUE);

Modified: trunk/src/brasero-project-manager.h
==============================================================================
--- trunk/src/brasero-project-manager.h	(original)
+++ trunk/src/brasero-project-manager.h	Mon Feb 16 17:08:21 2009
@@ -59,19 +59,19 @@
 GType brasero_project_manager_get_type ();
 GtkWidget *brasero_project_manager_new ();
 
-void
-brasero_project_manager_set_oneshot (BraseroProjectManager *manager,
-				     gboolean oneshot);
 
 void
 brasero_project_manager_audio (BraseroProjectManager *manager,
-			       GSList *uris);
+			       GSList *uris,
+			       gboolean burn);
 void
 brasero_project_manager_data (BraseroProjectManager *manager,
-			      GSList *uris);
+			      GSList *uris,
+			      gboolean burn);
 void
 brasero_project_manager_video (BraseroProjectManager *manager,
-			       GSList *uris);
+			       GSList *uris,
+			       gboolean burn);
 void
 brasero_project_manager_copy (BraseroProjectManager *manager,
 			      const gchar *device,

Modified: trunk/src/brasero-project.c
==============================================================================
--- trunk/src/brasero-project.c	(original)
+++ trunk/src/brasero-project.c	Mon Feb 16 17:08:21 2009
@@ -159,6 +159,8 @@
 
 	guint status_ctx;
 
+	GtkWidget *project_status;
+
 	/* header */
 	GtkWidget *burn;
 
@@ -709,7 +711,9 @@
 	gint initial;
 
 	project = g_object_get_data (G_OBJECT (dialog), "Project");
-	if (project->priv->oversized) {
+	if (project->priv->oversized
+	|| !project->priv->current
+	|| !project->priv->project_status) {
 		gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
 		return FALSE;
 	}
@@ -776,10 +780,12 @@
 
 	/* we are not ready to create tracks presumably because
 	 * data or audio has not finished to explore a directory
-	 * or get the metadata of a song or a film */
+	 * or get the metadata of a song or a film
+	 */
 
 	/* This dialog can run as a standalone window when run from nautilus
-	 * to burn burn:// URI contents. */
+	 * to burn burn:// URI contents.
+	 */
 	dialog = brasero_app_dialog (brasero_app_get_default (),
 				     _("Please wait until the estimation of the project size is completed."),
 				     GTK_BUTTONS_CANCEL,
@@ -837,11 +843,17 @@
 			    (GSourceFunc) _wait_for_ready_state,
 		            dialog);
 
+	project->priv->project_status = dialog;
 	answer = gtk_dialog_run (GTK_DIALOG (dialog));
 	g_source_remove (id);
 
 	gtk_widget_destroy (dialog);
 
+	if (!project->priv->project_status)
+		return BRASERO_DISC_CANCELLED;
+
+	project->priv->project_status = NULL;
+
 	if (answer != GTK_RESPONSE_OK)
 		return BRASERO_DISC_CANCELLED;
 	else if (project->priv->oversized)
@@ -974,6 +986,16 @@
 {
 	GtkAction *action;
 	GConfClient *client;
+	
+	if (project->priv->project_status) {
+		gtk_widget_hide (project->priv->project_status);
+		gtk_dialog_response (GTK_DIALOG (project->priv->project_status),
+				     GTK_RESPONSE_CANCEL);
+		project->priv->project_status = NULL;
+	}
+
+	if (project->priv->current)
+		brasero_disc_reset (project->priv->current);
 
 	if (project->priv->chooser) {
 		gtk_widget_destroy (project->priv->chooser);
@@ -985,9 +1007,6 @@
 	project->priv->merging = 0;
 	project->priv->modified = 0;
 
-	if (project->priv->current)
-		brasero_disc_reset (project->priv->current);
-
 	if (project->priv->project) {
 		g_free (project->priv->project);
 		project->priv->project = NULL;
@@ -1147,6 +1166,18 @@
 	GtkAction *action;
 	GtkWidget *status;
 
+	if (project->priv->project_status) {
+		gtk_widget_hide (project->priv->project_status);
+		gtk_dialog_response (GTK_DIALOG (project->priv->project_status),
+				     GTK_RESPONSE_CANCEL);
+		project->priv->project_status = NULL;
+	}
+
+	if (project->priv->chooser) {
+		gtk_widget_destroy (project->priv->chooser);
+		project->priv->chooser = NULL;
+	}
+
 	if (project->priv->project) {
 		g_free (project->priv->project);
 		project->priv->project = NULL;

Modified: trunk/src/brasero-src-image.c
==============================================================================
--- trunk/src/brasero-src-image.c	(original)
+++ trunk/src/brasero-src-image.c	Mon Feb 16 17:08:21 2009
@@ -259,7 +259,6 @@
 	const gchar *mime;
 
 	priv = BRASERO_SRC_IMAGE_PRIVATE (dialog);
-
 	if (error) {
 		brasero_src_image_set_track (dialog,
 					     BRASERO_IMAGE_FORMAT_NONE,

Modified: trunk/src/burn-task.c
==============================================================================
--- trunk/src/burn-task.c	(original)
+++ trunk/src/burn-task.c	Mon Feb 16 17:08:21 2009
@@ -394,6 +394,8 @@
 
 	brasero_task_ctx_get_current_track (BRASERO_TASK_CTX (self), &track);
 	brasero_track_get_type (track, &input);
+	BRASERO_BURN_LOG_TYPE (&input, "Track type");
+
 	if (input.type == BRASERO_TRACK_TYPE_IMAGE) {
 		BraseroBurnResult result;
 		gint64 sectors = 0;

Modified: trunk/src/burn-track.c
==============================================================================
--- trunk/src/burn-track.c	(original)
+++ trunk/src/burn-track.c	Mon Feb 16 17:08:21 2009
@@ -1030,6 +1030,7 @@
 			return BRASERO_BURN_ERR;
 
 		path = brasero_track_get_localpath (image->image);
+
 		if (!brasero_image_format_get_iso_size (path, blocks, size, error)) {
 			g_free (path);
 			return BRASERO_BURN_ERR;
@@ -1043,6 +1044,7 @@
 		gchar *path;
 
 		path = brasero_track_get_image_source (track, FALSE);
+
 		if (!path)
 			return BRASERO_BURN_ERR;
 

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Mon Feb 16 17:08:21 2009
@@ -157,12 +157,12 @@
 	function (BRASERO_PROJECT_MANAGER (manager_MACRO), uri);	\
 }
 
-#define BRASERO_PROJECT_OPEN_LIST(manager_MACRO, function, uris)		\
+#define BRASERO_PROJECT_OPEN_LIST(manager_MACRO, function_MACRO, uris_MACROS, burn_MACRO)	\
 {										\
 	GSList *list = NULL;							\
 	gchar **iter;								\
 	/* convert all names into a GSList * */					\
-	for (iter = uris; iter && *iter; iter ++) {				\
+	for (iter = uris_MACROS; iter && *iter; iter ++) {				\
 		gchar *uri;							\
 		GFile *file;							\
 		file = g_file_new_for_commandline_arg (*iter);			\
@@ -172,7 +172,7 @@
 	}									\
 	/* reverse to keep the order of files */				\
 	list = g_slist_reverse (list);						\
-	function (BRASERO_PROJECT_MANAGER (manager_MACRO), list);		\
+	function_MACRO (BRASERO_PROJECT_MANAGER (manager_MACRO), list, burn_MACRO);		\
 	g_slist_foreach (list, (GFunc) g_free, NULL);				\
 	g_slist_free (list);							\
 }
@@ -261,8 +261,7 @@
 	list = g_slist_reverse (list);
 	brasero_app_create_mainwin (app);
 	manager = brasero_app_get_project_manager (app);
-	brasero_project_manager_set_oneshot (BRASERO_PROJECT_MANAGER (manager), TRUE);
-	brasero_project_manager_data (BRASERO_PROJECT_MANAGER (manager), list);
+	brasero_project_manager_data (BRASERO_PROJECT_MANAGER (manager), list, TRUE);
 
 	g_slist_foreach (list, (GFunc) g_free, NULL);
 	g_slist_free (list);
@@ -296,7 +295,6 @@
 		return FALSE;
 
 	manager = brasero_app_get_project_manager (app);
-	brasero_project_manager_set_oneshot (BRASERO_PROJECT_MANAGER (manager), TRUE);
 	brasero_project_manager_open_project (BRASERO_PROJECT_MANAGER (manager), track, uri, burn);
 
 	return TRUE;
@@ -343,7 +341,6 @@
 
 	if (nb > 1) {
 		brasero_app_create_mainwin (app);
-
 		brasero_app_alert (app,
 				   _("Incompatible command line options used."),
 				   _("Only one option can be given at a time"),
@@ -383,17 +380,17 @@
 	else if (audio_project) {
 		brasero_app_create_mainwin (app);
 		manager = brasero_app_get_project_manager (app);
-		BRASERO_PROJECT_OPEN_LIST (manager, brasero_project_manager_audio, files);
+		BRASERO_PROJECT_OPEN_LIST (manager, brasero_project_manager_audio, files, FALSE);
 	}
 	else if (data_project) {
 		brasero_app_create_mainwin (app);
 		manager = brasero_app_get_project_manager (app);
-		BRASERO_PROJECT_OPEN_LIST (manager, brasero_project_manager_data, files);
+		BRASERO_PROJECT_OPEN_LIST (manager, brasero_project_manager_data, files, FALSE);
 	}
 	else if (video_project) {
 		brasero_app_create_mainwin (app);
 		manager = brasero_app_get_project_manager (app);
-	    	BRASERO_PROJECT_OPEN_LIST (manager, brasero_project_manager_video, files);
+	    	BRASERO_PROJECT_OPEN_LIST (manager, brasero_project_manager_video, files, FALSE);
 	}
 	else if (copy_project) {
 		gchar *device = NULL;
@@ -459,11 +456,11 @@
 
 			/* Fallback if it hasn't got a suitable URI */
 			if (type == BRASERO_PROJECT_TYPE_INVALID) {
-				BRASERO_PROJECT_OPEN_LIST (manager, brasero_project_manager_data, files);
+				BRASERO_PROJECT_OPEN_LIST (manager, brasero_project_manager_data, files, FALSE);
 			}
 		}
 		else
-			BRASERO_PROJECT_OPEN_LIST (manager, brasero_project_manager_data, files);
+			BRASERO_PROJECT_OPEN_LIST (manager, brasero_project_manager_data, files, FALSE);
 	}
 	else {
 		brasero_app_create_mainwin (app);



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