[brasero] Lots of fixes for image output path settings (including fixing extensions)



commit f4d62757e26a3eda1429bf0a05f0e4b8054d6ec6
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Thu Aug 13 15:21:10 2009 +0200

    Lots of fixes for image output path settings (including fixing extensions)

 libbrasero-burn/brasero-image-properties.c  |   21 +++---
 libbrasero-burn/brasero-medium-properties.c |    8 ++-
 libbrasero-burn/brasero-session-cfg.c       |   99 +++++++++++++++++++++++----
 libbrasero-burn/libbrasero-marshal.list     |    1 +
 4 files changed, 104 insertions(+), 25 deletions(-)
---
diff --git a/libbrasero-burn/brasero-image-properties.c b/libbrasero-burn/brasero-image-properties.c
index 94f8a19..82b87bf 100644
--- a/libbrasero-burn/brasero-image-properties.c
+++ b/libbrasero-burn/brasero-image-properties.c
@@ -77,8 +77,15 @@ brasero_image_properties_get_format (BraseroImageProperties *self)
 
 	priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (self);
 
-	if (priv->format == NULL)
-		return BRASERO_IMAGE_FORMAT_NONE;
+	if (priv->format == NULL) {
+		/* This means that since there was just
+		 * one format available, we did not 
+		 * show the format chooser widget
+		 * which means in turn that we did not
+		 * changed the format that was set
+		 * at the beginning in session */
+		return brasero_burn_session_get_output_format (BRASERO_BURN_SESSION (priv->session));
+	}
 
 	brasero_image_type_chooser_get_format (BRASERO_IMAGE_TYPE_CHOOSER (priv->format),
 					       &format);
@@ -277,20 +284,16 @@ brasero_image_properties_response (GtkFileChooser *chooser,
 	BraseroImageFormat format;
 	gchar *path;
 
-	priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (chooser);
-
 	if (response_id != GTK_RESPONSE_OK)
 		return;
 
+	priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (chooser);
+
 	/* get and check format */
 	format = brasero_image_properties_get_format (BRASERO_IMAGE_PROPERTIES (chooser));
 
 	/* see if the user has changed the path */
-	if (priv->edited)
-		path = brasero_image_properties_get_path (BRASERO_IMAGE_PROPERTIES (chooser));
-	else
-		path = NULL;
-
+	path = brasero_image_properties_get_path (BRASERO_IMAGE_PROPERTIES (chooser));
 	brasero_image_properties_set_output_path (BRASERO_IMAGE_PROPERTIES (chooser),
 						  format,
 						  path);
diff --git a/libbrasero-burn/brasero-medium-properties.c b/libbrasero-burn/brasero-medium-properties.c
index d7f04df..0d7c4a2 100644
--- a/libbrasero-burn/brasero-medium-properties.c
+++ b/libbrasero-burn/brasero-medium-properties.c
@@ -177,7 +177,6 @@ brasero_medium_properties_image_properties (BraseroMediumProperties *self)
 	/* and here we go ... run the thing */
 	gtk_widget_show (priv->medium_prop);
 	gtk_dialog_run (GTK_DIALOG (priv->medium_prop));
-
 	gtk_widget_destroy (priv->medium_prop);
 	priv->medium_prop = NULL;
 }
@@ -206,9 +205,16 @@ brasero_medium_properties_output_changed (BraseroBurnSession *session,
 					  BraseroMediumProperties *self)
 {
 	BraseroMediumPropertiesPrivate *priv;
+	BraseroDrive *burner;
 
 	priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
 
+	/* make sure that's an actual change of medium
+	 * as it could also be a change of path for image */
+	burner = brasero_burn_session_get_burner (session);
+	if (former == brasero_drive_get_medium (burner))
+		return;
+
 	/* close properties dialog */
 	if (priv->medium_prop) {
 		gtk_dialog_response (GTK_DIALOG (priv->medium_prop),
diff --git a/libbrasero-burn/brasero-session-cfg.c b/libbrasero-burn/brasero-session-cfg.c
index 1373eaa..e108d68 100644
--- a/libbrasero-burn/brasero-session-cfg.c
+++ b/libbrasero-burn/brasero-session-cfg.c
@@ -46,6 +46,7 @@
 #include "brasero-session.h"
 #include "burn-plugin-manager.h"
 #include "burn-image-format.h"
+#include "libbrasero-marshal.h"
 
 #include "brasero-tags.h"
 #include "brasero-track-image.h"
@@ -143,6 +144,8 @@ brasero_session_cfg_set_output_image (BraseroBurnSession *session,
 				      const gchar *toc)
 {
 	gchar *dot;
+	gchar *set_toc = NULL;
+	gchar * set_image = NULL;
 	BraseroBurnResult result;
 	BraseroBurnSessionClass *klass;
 	const gchar *suffixes [] = {".iso",
@@ -151,8 +154,39 @@ brasero_session_cfg_set_output_image (BraseroBurnSession *session,
 				    ".toc",
 				    NULL };
 
-	/* First set all information */
+	/* Make sure something actually changed */
 	klass = BRASERO_BURN_SESSION_CLASS (brasero_session_cfg_parent_class);
+	klass->get_output_path (BRASERO_BURN_SESSION (session),
+	                        &set_image,
+	                        &set_toc);
+
+	if (!set_image && !set_toc) {
+		/* see if image and toc set paths differ */
+		brasero_burn_session_get_output (BRASERO_BURN_SESSION (session),
+		                                 &set_image,
+		                                 &set_toc);
+		if (set_image && image && !strcmp (set_image, image)) {
+			/* It's the same default path so no 
+			 * need to carry on and actually set
+			 * the path of image. */
+			image = NULL;
+		}
+
+		if (set_toc && toc && !strcmp (set_toc, toc)) {
+			/* It's the same default path so no 
+			 * need to carry on and actually set
+			 * the path of image. */
+			toc = NULL;
+		}
+	}
+
+	if (set_image)
+		g_free (set_image);
+
+	if (set_toc)
+		g_free (set_toc);
+
+	/* First set all information */
 	result = klass->set_output_image (session,
 					  format,
 					  image,
@@ -169,40 +203,75 @@ brasero_session_cfg_set_output_image (BraseroBurnSession *session,
 
 	if (format & BRASERO_IMAGE_FORMAT_BIN) {
 		dot = g_utf8_strrchr (image, -1, '.');
-		if (!strcmp (suffixes [0], dot)) {
+		if (strcmp (suffixes [0], dot)) {
 			gboolean res;
 
 			res = brasero_session_cfg_wrong_extension_signal (BRASERO_SESSION_CFG (session));
-			if (res)
-				brasero_image_format_fix_path_extension (format, FALSE, image);
+			if (res) {
+				gchar *fixed_path;
+
+				fixed_path = brasero_image_format_fix_path_extension (format, FALSE, image);
+				/* NOTE: call ourselves with the fixed path as this way,
+				 * in case the path is the same as the default one after
+				 * fixing the extension we'll keep on using default path */
+				result = brasero_burn_session_set_image_output_full (session,
+				                                                     format,
+				                                                     fixed_path,
+				                                                     toc);
+				g_free (fixed_path);
+			}
 		}
 	}
 	else {
 		dot = g_utf8_strrchr (toc, -1, '.');
 
 		if (format & BRASERO_IMAGE_FORMAT_CLONE
-		&& !strcmp (suffixes [1], dot)) {
+		&& strcmp (suffixes [1], dot)) {
 			gboolean res;
 
 			res = brasero_session_cfg_wrong_extension_signal (BRASERO_SESSION_CFG (session));
-			if (res)
-				brasero_image_format_fix_path_extension (format, FALSE, toc);
+			if (res) {
+				gchar *fixed_path;
+
+				fixed_path = brasero_image_format_fix_path_extension (format, FALSE, toc);
+				result = brasero_burn_session_set_image_output_full (session,
+				                                                     format,
+				                                                     image,
+				                                                     fixed_path);
+				g_free (fixed_path);
+			}
 		}
 		else if (format & BRASERO_IMAGE_FORMAT_CUE
-		     && !strcmp (suffixes [2], dot)) {
+		     && strcmp (suffixes [2], dot)) {
 			gboolean res;
 
 			res = brasero_session_cfg_wrong_extension_signal (BRASERO_SESSION_CFG (session));
-			if (res)
-				brasero_image_format_fix_path_extension (format, FALSE, toc);
+			if (res) {
+				gchar *fixed_path;
+
+				fixed_path = brasero_image_format_fix_path_extension (format, FALSE, toc);
+				result = brasero_burn_session_set_image_output_full (session,
+				                                                     format,
+				                                                     image,
+				                                                     fixed_path);
+				g_free (fixed_path);
+			}
 		}
 		else if (format & BRASERO_IMAGE_FORMAT_CDRDAO
-		     && !strcmp (suffixes [3], dot)) {
+		     && strcmp (suffixes [3], dot)) {
 			gboolean res;
 
 			res = brasero_session_cfg_wrong_extension_signal (BRASERO_SESSION_CFG (session));
-			if (res)
-				brasero_image_format_fix_path_extension (format, FALSE, toc);
+			if (res) {
+				gchar *fixed_path;
+
+				fixed_path = brasero_image_format_fix_path_extension (format, FALSE, toc);
+				result = brasero_burn_session_set_image_output_full (session,
+				                                                     format,
+				                                                     image,
+				                                                     fixed_path);
+				g_free (fixed_path);
+			}
 		}
 	}
 
@@ -1445,8 +1514,8 @@ brasero_session_cfg_class_init (BraseroSessionCfgClass *klass)
 		              G_SIGNAL_RUN_LAST | G_SIGNAL_RUN_CLEANUP | G_SIGNAL_ACTION,
 		              0,
 		              NULL, NULL,
-		              g_cclosure_marshal_VOID__VOID,
-		              G_TYPE_NONE,
+		              brasero_marshal_BOOLEAN__VOID,
+		              G_TYPE_BOOLEAN,
 			      0,
 		              G_TYPE_NONE);
 	session_cfg_signals [IS_VALID_SIGNAL] =
diff --git a/libbrasero-burn/libbrasero-marshal.list b/libbrasero-burn/libbrasero-marshal.list
index 2354de0..3641719 100644
--- a/libbrasero-burn/libbrasero-marshal.list
+++ b/libbrasero-burn/libbrasero-marshal.list
@@ -3,6 +3,7 @@ INT:INT
 INT:STRING
 INT:OBJECT,INT,INT
 INT:POINTER,BOOLEAN
+BOOLEAN:VOID
 BOOLEAN:STRING
 BOOLEAN:POINTER
 VOID:INT,STRING



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