? nautilus-cd-burner-2.9.5.tar.gz
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/ChangeLog,v
retrieving revision 1.345
diff -p -u -r1.345 ChangeLog
--- ChangeLog	27 Jan 2005 02:02:03 -0000	1.345
+++ ChangeLog	27 Jan 2005 18:52:05 -0000
@@ -1,3 +1,13 @@
+2005-01-27  William Jon McCann  <mccann@jhu.edu>
+
+	* nautilus-cd-burner.c (burn_cd): Report errors during make_iso
+	and remove incorrect error message.  (Closes #164432)
+
+	* make-iso.c (nautilus_burn_iso_error_quark) 
+	(nautilus_burn_make_iso_cancel, mkisofs_stderr_read) 
+	(nautilus_burn_make_iso): Add GError to make_iso to be able to
+	report errors back to the user.
+
 2005-01-26  William Jon McCann  <mccann@jhu.edu>
 
 	* make-iso.c (mkisofs_stderr_read): Watch for mkisofs error messages
Index: make-iso.c
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/make-iso.c,v
retrieving revision 1.43
diff -p -u -r1.43 make-iso.c
--- make-iso.c	27 Jan 2005 02:02:03 -0000	1.43
+++ make-iso.c	27 Jan 2005 18:52:05 -0000
@@ -50,6 +50,16 @@
 #include "mkdtemp.h"
 #endif
 
+GQuark
+nautilus_burn_iso_error_quark (void)
+{
+	static GQuark quark = 0;
+	if (!quark)
+		quark = g_quark_from_static_string ("nautilus_burn_iso_error");
+
+	return quark;
+}
+
 static gboolean
 make_iso_get_free_space (const char       *filename,
 			 GnomeVFSFileSize *size)
@@ -76,6 +86,7 @@ struct mkisofs_output {
 	int         result;
 	int         pid;
 	const char *filename;
+	GError     *error;
 	gboolean    debug;
 };
 
@@ -90,13 +101,14 @@ static struct mkisofs_output *mkisofs_ou
 void
 nautilus_burn_make_iso_cancel (void)
 {
-	if (mkisofs_output_ptr)
-		{
-			kill (mkisofs_output_ptr->pid, SIGINT);
-			unlink (mkisofs_output_ptr->filename);
-
-			g_main_loop_quit (mkisofs_output_ptr->loop);
-		}
+	if (mkisofs_output_ptr) {
+		kill (mkisofs_output_ptr->pid, SIGINT);
+		unlink (mkisofs_output_ptr->filename);
+		mkisofs_output_ptr->error = g_error_new_literal (NAUTILUS_BURN_ISO_ERROR, 
+								 NAUTILUS_BURN_ISO_ERROR_GENERAL,
+								 _("The operation was cancelled by the user."));
+		g_main_loop_quit (mkisofs_output_ptr->loop);
+	}
 }
 
 static void
@@ -528,13 +540,18 @@ mkisofs_stderr_read (GIOChannel   *sourc
 		if (strstr (line, "Incorrectly encoded string")) {
 			nautilus_burn_progress_set_fraction (1.0);
 			g_main_loop_quit (mkisofs_output->loop);
+			mkisofs_output->error = g_error_new_literal (NAUTILUS_BURN_ISO_ERROR,
+								     NAUTILUS_BURN_ISO_ERROR_GENERAL,
+								     _("Incorrectly encoded string."));
 			mkisofs_output->result = NAUTILUS_BURN_RECORDER_RESULT_ERROR;
 		}
 
 		if (strstr (line, "No space left on device")) {
-			/* TODO: return a sensible error message to the user */
 			nautilus_burn_progress_set_fraction (1.0);
 			g_main_loop_quit (mkisofs_output->loop);
+			mkisofs_output->error = g_error_new_literal (NAUTILUS_BURN_ISO_ERROR,
+								     NAUTILUS_BURN_ISO_ERROR_GENERAL,
+								     _("There is no space left on the device."));
 			mkisofs_output->result = NAUTILUS_BURN_RECORDER_RESULT_ERROR;
 		}
 
@@ -542,6 +559,9 @@ mkisofs_stderr_read (GIOChannel   *sourc
 			/* TODO: get filename from error message */
 			nautilus_burn_progress_set_fraction (1.0);
 			g_main_loop_quit (mkisofs_output->loop);
+			mkisofs_output->error = g_error_new_literal (NAUTILUS_BURN_ISO_ERROR,
+								     NAUTILUS_BURN_ISO_ERROR_GENERAL,
+								     _("File too large for filesystem."));
 			mkisofs_output->result = NAUTILUS_BURN_RECORDER_RESULT_ERROR;
 		}
 
@@ -567,7 +587,8 @@ nautilus_burn_make_iso (const char *file
 			const char *label,
 			gboolean    warn_low_space,
 			gboolean    use_joliet,
-			gboolean    debug)
+			gboolean    debug,
+			GError    **error)
 {
 	GnomeVFSURI          *uri;
 	char                 *filelist = NULL;
@@ -576,7 +597,7 @@ nautilus_burn_make_iso (const char *file
 	GList                *l;
 	int                   stdout_pipe, stderr_pipe;
 	int                   i;
-	GError               *error;
+	GError               *sub_error;
 	const char           *argv [20]; /* Shouldn't need more than 20 arguments */
 	struct mkisofs_output mkisofs_output;
 	GIOChannel           *channel;
@@ -585,13 +606,17 @@ nautilus_burn_make_iso (const char *file
 	char                 *dirname;
 	int                   exit_status, res;
 	guint64               iso_size;
-	GtkWidget            *dialog;
 	GnomeVFSFileSize      size;
 
-	if (label) {
-		g_return_val_if_fail (strlen (label) < 32, NAUTILUS_BURN_RECORDER_RESULT_ERROR);
+	if (label && (strlen (label) > 32)) {
+		g_set_error (error,
+			     G_FILE_ERROR,
+			     0,
+			     _("The label for the image is too long."));
+		return NAUTILUS_BURN_RECORDER_RESULT_ERROR;
 	}
 
+	mkisofs_output.error = NULL;
 	mkisofs_output.debug = debug;
 
 	dirname = g_strdup_printf ("iso-%s.XXXXXX", g_get_user_name ());
@@ -602,7 +627,10 @@ nautilus_burn_make_iso (const char *file
 	mkisofs_output.result = NAUTILUS_BURN_RECORDER_RESULT_ERROR;
 
 	if (state.tmpdir == 0) {
-		g_warning ("Unable to create temp dir\n");
+		mkisofs_output.error = g_error_new (NAUTILUS_BURN_ISO_ERROR,
+						    NAUTILUS_BURN_ISO_ERROR_GENERAL,
+						    _("Unable to create temporary directory: %s."),
+						    g_strerror (errno));
 		goto cleanup;
 	}
 	
@@ -614,6 +642,10 @@ nautilus_burn_make_iso (const char *file
 
 	state.graft_file = fopen (filelist, "w");
 	if (state.graft_file == NULL) {
+		mkisofs_output.error = g_error_new (NAUTILUS_BURN_ISO_ERROR, 
+						    NAUTILUS_BURN_ISO_ERROR_GENERAL,
+						    _("Unable to create temporary file: %s."),
+						    g_strerror (errno));
 		goto cleanup;
 	}
 	
@@ -626,17 +658,9 @@ nautilus_burn_make_iso (const char *file
 	state.remove_files = g_list_prepend (state.remove_files, g_strdup (filelist));
 
 	if (!state.found_file) {
-		dialog = gtk_message_dialog_new (nautilus_burn_progress_get_window (),
-						 GTK_DIALOG_DESTROY_WITH_PARENT,
-						 GTK_MESSAGE_ERROR,
-						 GTK_BUTTONS_CLOSE,
-						 _("No files selected"));
-		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-							  _("There are no files to write to disc."));
-		gtk_window_set_title (GTK_WINDOW (dialog),
-				      _("No files selected"));
-		gtk_dialog_run (GTK_DIALOG (dialog));
-		gtk_widget_destroy (dialog);
+		mkisofs_output.error = g_error_new_literal (NAUTILUS_BURN_ISO_ERROR, 
+							    NAUTILUS_BURN_ISO_ERROR_GENERAL,
+							    _("There are no files to write to disc."));
 		mkisofs_output.result = NAUTILUS_BURN_RECORDER_RESULT_ERROR;
 		goto cleanup;
 	}
@@ -658,7 +682,7 @@ nautilus_burn_make_iso (const char *file
 	argv [i++] = "-print-size";
 	argv [i++] = NULL;
 
-	error = NULL;
+	sub_error = NULL;
 
 	if (debug) {
 		g_print ("launching command: ");
@@ -676,10 +700,12 @@ nautilus_burn_make_iso (const char *file
 			   &stdout_data,
 			   &stderr_data,
 			   &exit_status,
-			   &error)) {
-		g_warning ("mkisofs command failed: %s\n", error->message);
-		g_error_free (error);
-		/* TODO: Better error handling */
+			   &sub_error)) {
+		mkisofs_output.error = g_error_new (NAUTILUS_BURN_ISO_ERROR, 
+						    NAUTILUS_BURN_ISO_ERROR_GENERAL,
+						    _("Could not run sub process: %s."),
+						    sub_error->message);
+		g_error_free (sub_error);
 		mkisofs_output.result = NAUTILUS_BURN_RECORDER_RESULT_ERROR;
 		goto cleanup;
 	}
@@ -693,6 +719,9 @@ nautilus_burn_make_iso (const char *file
 				goto retry;
 			} else {
 				mkisofs_output.result = NAUTILUS_BURN_RECORDER_RESULT_ERROR;
+				mkisofs_output.error = g_error_new_literal (NAUTILUS_BURN_ISO_ERROR, 
+									    NAUTILUS_BURN_ISO_ERROR_GENERAL,
+									    _("The operation was cancelled by the user."));
 				goto cleanup;
 			}
 		}
@@ -711,18 +740,10 @@ nautilus_burn_make_iso (const char *file
 	} else if (iso_size > size) {
 		g_free (dirname);
 		if (warn_low_space) {
-			dialog = gtk_message_dialog_new (nautilus_burn_progress_get_window (),
-							 GTK_DIALOG_DESTROY_WITH_PARENT,
-							 GTK_MESSAGE_ERROR,
-							 GTK_BUTTONS_CLOSE,
-							 _("Not enough space"));
-			gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-								  "Not enough space to store disc image (%ld MiB needed)",
-								  (unsigned long)iso_size / 1048576);
-			gtk_window_set_title (GTK_WINDOW (dialog),
-					      _("Not enough space"));
-			gtk_dialog_run (GTK_DIALOG (dialog));
-			gtk_widget_destroy (dialog);
+			mkisofs_output.error = g_error_new (NAUTILUS_BURN_ISO_ERROR, 
+							    NAUTILUS_BURN_ISO_ERROR_GENERAL,
+							    _("The selected location does not have enough space to store the disc image (%ld MiB needed)."),
+							    (unsigned long)iso_size / 1048576);
 			mkisofs_output.result = NAUTILUS_BURN_RECORDER_RESULT_ERROR;
 		} else {
 			mkisofs_output.result = NAUTILUS_BURN_RECORDER_RESULT_RETRY;
@@ -761,7 +782,7 @@ nautilus_burn_make_iso (const char *file
 	nautilus_burn_progress_set_text (_("Creating CD image"));
 	nautilus_burn_progress_set_fraction (0.0);
 	nautilus_burn_progress_set_image_spinning (TRUE);
-	error = NULL;
+	sub_error = NULL;
 	if (!g_spawn_async_with_pipes  (NULL,
 					(char **)argv,
 					NULL,
@@ -771,9 +792,12 @@ nautilus_burn_make_iso (const char *file
 					/*stdin*/NULL,
 					&stdout_pipe,
 					&stderr_pipe,
-					&error)) {
-		g_warning ("mkisofs command failed: %s\n", error->message);
-		g_error_free (error);
+					&sub_error)) {
+		mkisofs_output.error = g_error_new (NAUTILUS_BURN_ISO_ERROR, 
+						    NAUTILUS_BURN_ISO_ERROR_GENERAL,
+						    _("Command failed: %s"),
+						    sub_error->message);
+		g_error_free (sub_error);
 		mkisofs_output.result = NAUTILUS_BURN_RECORDER_RESULT_ERROR;
 		goto cleanup;
 	} else {
@@ -818,6 +842,15 @@ nautilus_burn_make_iso (const char *file
 	g_free (tempdir);
 	nautilus_burn_progress_set_image_spinning (FALSE);
 
+	if (mkisofs_output.result == NAUTILUS_BURN_RECORDER_RESULT_ERROR) {
+		if (!mkisofs_output.error)
+			mkisofs_output.error = g_error_new_literal (NAUTILUS_BURN_ISO_ERROR,
+								    NAUTILUS_BURN_ISO_ERROR_GENERAL,
+								    _("Unknown error"));
+
+		g_propagate_error (error, mkisofs_output.error);
+	}
+
 	return mkisofs_output.result;
 }
 
@@ -940,7 +973,9 @@ nautilus_burn_verify_iso (const char *fi
 	return TRUE;
 
  bail:
-	*error = g_error_new_literal (0, 0, _("Not a valid CD image."));
+	*error = g_error_new_literal (NAUTILUS_BURN_ISO_ERROR,
+				      NAUTILUS_BURN_ISO_ERROR_GENERAL,
+				      _("Not a valid CD image."));
 
 	return FALSE;
 }
Index: make-iso.h
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/make-iso.h,v
retrieving revision 1.13
diff -p -u -r1.13 make-iso.h
--- make-iso.h	13 Dec 2004 23:52:38 -0000	1.13
+++ make-iso.h	27 Jan 2005 18:52:05 -0000
@@ -26,11 +26,21 @@
 
 G_BEGIN_DECLS
 
+#define NAUTILUS_BURN_ISO_ERROR nautilus_burn_iso_error_quark ()
+
+GQuark nautilus_burn_iso_error_quark (void);
+
+typedef enum {
+	NAUTILUS_BURN_ISO_ERROR_INTERNAL,
+	NAUTILUS_BURN_ISO_ERROR_GENERAL
+} NautilusBurnIsoError;
+
 int      nautilus_burn_make_iso        (const char *filename,
 					const char *label,
 					gboolean    warn_low_space,
 					gboolean    use_joliet,
-					gboolean    debug);
+					gboolean    debug,
+					GError    **error);
 void     nautilus_burn_make_iso_cancel (void);
 gboolean nautilus_burn_verify_iso      (const char *filename,
 					char      **name,
Index: nautilus-cd-burner.c
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/nautilus-cd-burner.c,v
retrieving revision 1.103
diff -p -u -r1.103 nautilus-cd-burner.c
--- nautilus-cd-burner.c	27 Jan 2005 02:02:03 -0000	1.103
+++ nautilus-cd-burner.c	27 Jan 2005 18:52:05 -0000
@@ -744,6 +744,7 @@ burn_cd (const NautilusBurnDrive *drive,
 {
 	NautilusBurnRecorderWriteFlags flags;
 	GList                         *tracks;
+	GError                        *error = NULL;
 	char                          *filename, *str;
 	int                            fd;
 	int                            res = NAUTILUS_BURN_RECORDER_RESULT_ERROR;
@@ -824,7 +825,7 @@ burn_cd (const NautilusBurnDrive *drive,
 		if (filename != NULL) {
 			gboolean check_space = (drive->type == NAUTILUS_BURN_DRIVE_TYPE_FILE);
 			/* Don't warn on low space unless the user selected this file specifically */
-			res = nautilus_burn_make_iso (filename, label, check_space, TRUE, debug);
+			res = nautilus_burn_make_iso (filename, label, check_space, TRUE, debug, &error);
 		} else {
 			res = NAUTILUS_BURN_RECORDER_RESULT_RETRY;
 		}
@@ -835,21 +836,22 @@ burn_cd (const NautilusBurnDrive *drive,
 			fd = g_mkstemp(filename);
 			close (fd);
 
-			res = nautilus_burn_make_iso (filename, label, FALSE, TRUE, debug);
+			res = nautilus_burn_make_iso (filename, label, FALSE, TRUE, debug, &error);
 			if (res == NAUTILUS_BURN_RECORDER_RESULT_RETRY) {
 				g_free (filename);
 				filename = g_build_filename (g_get_home_dir (), ".image.iso.XXXXXX", NULL);
 				fd = g_mkstemp(filename);
 				close (fd);
 
-				res = nautilus_burn_make_iso (filename, label, TRUE, TRUE, debug);
+				res = nautilus_burn_make_iso (filename, label, TRUE, TRUE, debug, &error);
 			}
 		}
 
 		if (res != NAUTILUS_BURN_RECORDER_RESULT_FINISHED) {
 			/* User cancelled or we had an error. */
 			if (res == NAUTILUS_BURN_RECORDER_RESULT_ERROR) {
-				ncb_hig_show_error_dialog (_("File image creation failed"), _("Incorrectly named files were to be added to the CD"), NULL);
+				ncb_hig_show_error_dialog (_("File image creation failed"), error->message, NULL);
+				g_error_free (error);
 			}
 			cancel = CANCEL_NONE;
 			goto out;
