Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/ChangeLog,v
retrieving revision 1.329
diff -p -u -r1.329 ChangeLog
--- ChangeLog	4 Jan 2005 19:00:54 -0000	1.329
+++ ChangeLog	5 Jan 2005 23:30:03 -0000
@@ -1,0 +1,12 @@
+2005-01-05  William Jon McCann  <mccann@jhu.edu>
+
+	* nautilus-cd-burner.c (ncb_hig_dialog):
+	Use gtk_message_dialog_format_secondary_text API.
+	(ask_for_media, insert_media_request_cb, burn_cd, main):
+	Ask the user to replace the in-drive media if data size is bigger
+	than media size (and he hasn't the gconf overburn set). If
+	difference is only 5 MiBs show a button to overburn it.  Also show
+	the required size in the insert disc dialog.
+	Based on patch from Fernando Herrera  <fherrera@onirica.com>
+	(Closes: #135985)
+
Index: nautilus-cd-burner.c
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/nautilus-cd-burner.c,v
retrieving revision 1.91
diff -p -u -r1.91 nautilus-cd-burner.c
--- nautilus-cd-burner.c	16 Dec 2004 13:04:48 -0000	1.91
+++ nautilus-cd-burner.c	5 Jan 2005 23:30:03 -0000
@@ -41,7 +41,9 @@
 #include "nautilus-cd-burner.h"
 #include "make-iso.h"
 
-#define MAX_ISO_NAME_LEN 32
+#define MAX_ISO_NAME_LEN  32
+#define RESPONSE_OVERBURN 1
+#define SUGGEST_OVERBURN  5 * 1024 * 1024
 
 enum {
 	CANCEL_NONE,
@@ -78,7 +80,8 @@ ncb_hig_dialog (GtkMessageType type,
 					GTK_DIALOG_DESTROY_WITH_PARENT,
 					type,
 					GTK_BUTTONS_NONE,
-					"<b>%s</b>\n%s", title_esc, reason_esc);
+					title_esc);
+	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (error_dialog), reason_esc);
 	gtk_window_set_title (GTK_WINDOW (error_dialog), title_esc);
 	g_free (title_esc);
 	g_free (reason_esc);
@@ -86,7 +89,7 @@ ncb_hig_dialog (GtkMessageType type,
 	gtk_container_set_border_width (GTK_CONTAINER (error_dialog), 5);
 	gtk_dialog_set_default_response (GTK_DIALOG (error_dialog),
 					 GTK_RESPONSE_OK);
-	gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (error_dialog)->label), TRUE);
+
 	gtk_window_set_modal (GTK_WINDOW (error_dialog), TRUE);
 
 	return error_dialog;
@@ -291,31 +294,36 @@ progress_changed_cb (NautilusBurnRecorde
 	nautilus_burn_progress_set_fraction (fraction);
 }
 
-static gboolean
-insert_media_request_cb (NautilusBurnRecorder *cdrecorder,
-			 gboolean              is_reload,
-			 gboolean              can_rewrite,
-			 gboolean              busy_cd,
-			 gpointer              data)
+static int  
+ask_for_media (gboolean is_reload,
+	       gboolean can_rewrite,
+	       gboolean busy_cd,
+	       gboolean ask_overburn,
+	       int      required_size)
 {
 	GtkWidget  *dialog, *parent;
-	const char *msg, *title;
+	char       *msg;
+	const char *title;
 	int         res;
 
 	if (busy_cd) {
-		msg = N_("Please make sure another application is not using the drive.");
+		msg = g_strdup (_("Please make sure another application is not using the drive."));
 		title = N_("Drive is busy");
 	} else if (!is_reload && can_rewrite) {
-		msg = N_("Please put a rewritable or blank disc into the drive.");
+		msg = g_strdup_printf (_("Please put a rewritable or blank disc, with at least %d MiB free, into the drive."),
+				       required_size);
 		title = N_("Insert rewritable or blank disc");
 	} else if (!is_reload && !can_rewrite) {
-		msg = N_("Please put a blank disc into the drive.");
+		msg = g_strdup_printf (_("Please put a blank disc, with at least %d MiB free, into the drive."),
+				       required_size);
 		title = N_("Insert blank disc");
 	} else if (can_rewrite) {
-		msg = N_("Please replace the disc in the drive with a rewritable or blank disc.");
+		msg = g_strdup_printf (_("Please replace the disc in the drive with a rewritable or blank disc, with at least %d MiB free."),
+				       required_size);
 		title = N_("Reload rewritable or blank disc");
 	} else {
-		msg = N_("Please replace the disc in the drive a blank disc.");
+		msg = g_strdup_printf (_("Please replace the disc in the drive with a blank disc, with at least %d MiB free."),
+				       required_size);
 		title = N_("Reload blank disc");
 	}
 
@@ -331,10 +339,27 @@ insert_media_request_cb (NautilusBurnRec
 
 	res = gtk_dialog_run (GTK_DIALOG (dialog));
 	gtk_widget_destroy (dialog);
-	if (res == GTK_RESPONSE_CANCEL) {
-		return FALSE;
-	}
 
+	g_free (msg);
+
+	return res;
+}
+
+static gboolean
+insert_media_request_cb (NautilusBurnRecorder *cdrecorder,
+			 gboolean              is_reload,
+			 gboolean              can_rewrite,
+			 gboolean              busy_cd,
+			 gpointer              data)
+{
+	int res;
+	int required_size = GPOINTER_TO_INT (data);
+
+	res = ask_for_media (is_reload, can_rewrite, busy_cd, FALSE, required_size);
+
+	if (res == GTK_RESPONSE_CANCEL)
+		return FALSE;
+ 
 	return TRUE;
 }
 
@@ -536,6 +561,7 @@ static int
 burn_cd (const NautilusBurnDrive *rec,
 	 const char              *source_iso,
 	 const char              *label,
+	 GnomeVFSFileSize         burn_size,
 	 gboolean                 eject_cd,
 	 int                      speed,
 	 gboolean                 dummy,
@@ -548,6 +574,7 @@ burn_cd (const NautilusBurnDrive *rec,
 	char                          *filename, *str;
 	int                            fd;
 	int                            res = NAUTILUS_BURN_RECORDER_RESULT_ERROR;
+	int                            mibs = (burn_size + 1024 * 1024 - 1)/ (1024 * 1024);
 
 	tracks = NULL;
 	filename = NULL;
@@ -600,7 +627,7 @@ burn_cd (const NautilusBurnDrive *rec,
 			g_object_unref (G_OBJECT (gc));
 			if (path != NULL && path[0] != '\0') {
 				filename = g_build_filename (path, "image.iso.XXXXXX", NULL);
-				fd = g_mkstemp(filename);
+				fd = g_mkstemp (filename);
 				close (fd);
 			}
 		} else {
@@ -608,6 +635,29 @@ burn_cd (const NautilusBurnDrive *rec,
 		}
 	}
 
+	if (rec->type != NAUTILUS_BURN_DRIVE_TYPE_FILE) {
+		if (!overburn) {
+			gint64 media_size;
+
+			do {
+				int res;
+
+				media_size = nautilus_burn_drive_get_media_size ((NautilusBurnDrive *)rec);
+
+				res = ask_for_media ((media_size > 0), (rec->type & NAUTILUS_BURN_DRIVE_TYPE_CDRW_RECORDER),
+						     FALSE, (((gint64) burn_size - media_size) <= SUGGEST_OVERBURN),
+						     mibs);
+
+				if (res == GTK_RESPONSE_CANCEL)
+					return 1;
+				if (res == RESPONSE_OVERBURN) {
+					flags |= NAUTILUS_BURN_RECORDER_OVERBURN;
+					break;
+				}
+			} while (media_size < 0 || (gint64) burn_size > media_size);
+		}
+	}
+
 	if (source_iso == NULL) {
 		cancel = CANCEL_MAKE_ISO;
 
@@ -672,7 +722,7 @@ burn_cd (const NautilusBurnDrive *rec,
 		g_signal_connect (G_OBJECT (cdrecorder),
 				  "insert-media-request",
 				  G_CALLBACK (insert_media_request_cb),
-				  NULL);
+				  GINT_TO_POINTER (mibs));
 
 		track = g_new0 (NautilusBurnRecorderTrack, 1);
 		track->type = NAUTILUS_BURN_RECORDER_TRACK_TYPE_DATA;
@@ -695,7 +745,7 @@ burn_cd (const NautilusBurnDrive *rec,
 		if (burnproof) {
 			flags |= NAUTILUS_BURN_RECORDER_BURNPROOF;
 		}
-
+	
 		res = nautilus_burn_recorder_write_tracks (cdrecorder, (NautilusBurnDrive *)rec,
 							   tracks, speed, flags);
 
@@ -1160,7 +1210,7 @@ main (int argc, char *argv[])
 		gconf_client_set_int (gc, "/apps/nautilus-cd-burner/default_speed", speed, NULL);
 		g_object_unref (G_OBJECT (gc));
 
-		res = burn_cd (rec, source_iso, label, eject, speed, dummy, debug, overburn, burnproof);
+		res = burn_cd (rec, source_iso, label, size, eject, speed, dummy, debug, overburn, burnproof);
 
 		reuse_check = glade_xml_get_widget (xml, "reuse_check");
 		reuse = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (reuse_check));
