[brasero] Fix #612980 - Copy disc to ISO image always uses brasero.iso by default



commit 0d7083d95d7293d0a9ffef58c81c2849b77ceff3
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Sun Oct 17 15:58:49 2010 +0200

    Fix #612980 - Copy disc to ISO image always uses brasero.iso by default

 libbrasero-burn/brasero-image-properties.c |   72 +++++++++++++---------------
 libbrasero-burn/brasero-session-cfg.c      |   19 +++++++-
 libbrasero-burn/burn-image-format.c        |    9 ++-
 libbrasero-burn/burn-image-format.h        |    3 +-
 4 files changed, 59 insertions(+), 44 deletions(-)
---
diff --git a/libbrasero-burn/brasero-image-properties.c b/libbrasero-burn/brasero-image-properties.c
index 0f88914..abb6d83 100644
--- a/libbrasero-burn/brasero-image-properties.c
+++ b/libbrasero-burn/brasero-image-properties.c
@@ -118,6 +118,38 @@ brasero_image_properties_set_path (BraseroImageProperties *self,
 						     g_get_home_dir ());
 }
 
+static gchar *
+brasero_image_properties_get_output_path (BraseroImageProperties *self)
+{
+	gchar *path = NULL;
+	BraseroImageFormat format;
+	BraseroImagePropertiesPrivate *priv;
+
+	priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (self);
+
+	format = brasero_burn_session_get_output_format (BRASERO_BURN_SESSION (priv->session));
+	switch (format) {
+	case BRASERO_IMAGE_FORMAT_BIN:
+		brasero_burn_session_get_output (BRASERO_BURN_SESSION (priv->session),
+						 &path,
+						 NULL);
+		break;
+
+	case BRASERO_IMAGE_FORMAT_CLONE:
+	case BRASERO_IMAGE_FORMAT_CDRDAO:
+	case BRASERO_IMAGE_FORMAT_CUE:
+		brasero_burn_session_get_output (BRASERO_BURN_SESSION (priv->session),
+						 NULL,
+						 &path);
+		break;
+
+	default:
+		break;
+	}
+
+	return path;
+}
+
 static void
 brasero_image_properties_format_changed_cb (BraseroImageTypeChooser *chooser,
 					    BraseroImageProperties *self)
@@ -146,19 +178,15 @@ brasero_image_properties_format_changed_cb (BraseroImageTypeChooser *chooser,
 	if (!priv->edited) {
 		/* not changed: get a new default path */
 		g_free (image_path);
-		image_path = brasero_image_format_get_default_path (format);
+		image_path = brasero_image_properties_get_output_path (self);
 	}
-	else if (image_path) {
+	else {
 		gchar *tmp;
 
 		tmp = image_path;
 		image_path = brasero_image_format_fix_path_extension (format, FALSE, image_path);
 		g_free (tmp);
 	}
-	else {
-		priv->edited = FALSE;
-		image_path = brasero_image_format_get_default_path (format);
-	}
 
 	brasero_image_properties_set_path (self, image_path);
 
@@ -342,38 +370,6 @@ brasero_image_properties_response (GtkFileChooser *chooser,
 	}
 }
 
-static gchar *
-brasero_image_properties_get_output_path (BraseroImageProperties *self)
-{
-	gchar *path = NULL;
-	BraseroImageFormat format;
-	BraseroImagePropertiesPrivate *priv;
-
-	priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (self);
-
-	format = brasero_burn_session_get_output_format (BRASERO_BURN_SESSION (priv->session));
-	switch (format) {
-	case BRASERO_IMAGE_FORMAT_BIN:
-		brasero_burn_session_get_output (BRASERO_BURN_SESSION (priv->session),
-						 &path,
-						 NULL);
-		break;
-
-	case BRASERO_IMAGE_FORMAT_CLONE:
-	case BRASERO_IMAGE_FORMAT_CDRDAO:
-	case BRASERO_IMAGE_FORMAT_CUE:
-		brasero_burn_session_get_output (BRASERO_BURN_SESSION (priv->session),
-						 NULL,
-						 &path);
-		break;
-
-	default:
-		break;
-	}
-
-	return path;
-}
-
 static void
 brasero_image_properties_update (BraseroImageProperties *self)
 {
diff --git a/libbrasero-burn/brasero-session-cfg.c b/libbrasero-burn/brasero-session-cfg.c
index ef161c3..3f7fe3f 100644
--- a/libbrasero-burn/brasero-session-cfg.c
+++ b/libbrasero-burn/brasero-session-cfg.c
@@ -39,6 +39,8 @@
 #include <glib-object.h>
 #include <glib/gi18n-lib.h>
 
+#include "brasero-volume.h"
+
 #include "burn-basics.h"
 #include "burn-debug.h"
 #include "burn-plugin-manager.h"
@@ -722,8 +724,21 @@ brasero_session_cfg_check_volume_size (BraseroSessionCfg *self)
 		if (priv->output_format == BRASERO_IMAGE_FORMAT_NONE)
 			priv->output_format = brasero_burn_session_get_output_format (BRASERO_BURN_SESSION (self));
 
-		if (!priv->output)
-			priv->output = brasero_image_format_get_default_path (priv->output_format);
+		if (!priv->output) {
+			gchar *name = NULL;
+
+			/* If we try to copy a volume get (and use) its name */
+			if (brasero_track_type_get_has_medium (priv->source)) {
+				BraseroMedium *medium;
+
+				medium = brasero_burn_session_get_src_medium (BRASERO_BURN_SESSION (self));
+				if (medium)
+					name = brasero_volume_get_name (BRASERO_VOLUME (medium));
+			}
+
+			priv->output = brasero_image_format_get_default_path (priv->output_format, name);
+			g_free (name);
+		}
 
 		directory = g_path_get_dirname (priv->output);
 		file = g_file_new_for_path (directory);
diff --git a/libbrasero-burn/burn-image-format.c b/libbrasero-burn/burn-image-format.c
index a1ac79b..530cb87 100644
--- a/libbrasero-burn/burn-image-format.c
+++ b/libbrasero-burn/burn-image-format.c
@@ -840,7 +840,8 @@ brasero_image_format_get_clone_size (gchar *uri,
 }
 
 gchar *
-brasero_image_format_get_default_path (BraseroImageFormat format)
+brasero_image_format_get_default_path (BraseroImageFormat format,
+				       const gchar *name)
 {
 	const gchar *suffixes [] = {".iso",
 				    ".toc",
@@ -860,15 +861,17 @@ brasero_image_format_get_default_path (BraseroImageFormat format)
 	else if (format & BRASERO_IMAGE_FORMAT_CDRDAO)
 		suffix = suffixes [3];
 
-	path = g_strdup_printf ("%s/brasero%s",
+	path = g_strdup_printf ("%s/%s%s",
 				g_get_home_dir (),
+				name? name:"brasero",
 				suffix);
 
 	while (g_file_test (path, G_FILE_TEST_EXISTS)) {
 		g_free (path);
 
-		path = g_strdup_printf ("%s/brasero-%i%s",
+		path = g_strdup_printf ("%s/%s-%i%s",
 					g_get_home_dir (),
+					name? name:"brasero",
 					i,
 					suffix);
 		i ++;
diff --git a/libbrasero-burn/burn-image-format.h b/libbrasero-burn/burn-image-format.h
index 9073abd..a7f3058 100644
--- a/libbrasero-burn/burn-image-format.h
+++ b/libbrasero-burn/burn-image-format.h
@@ -43,7 +43,8 @@ brasero_image_format_identify_cuesheet (const gchar *path,
 					GError **error);
 
 gchar *
-brasero_image_format_get_default_path (BraseroImageFormat format);
+brasero_image_format_get_default_path (BraseroImageFormat format,
+				       const gchar *name);
 
 gchar *
 brasero_image_format_fix_path_extension (BraseroImageFormat format,



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