brasero r1357 - in trunk: . src



Author: philippr
Date: Wed Oct  8 10:42:07 2008
New Revision: 1357
URL: http://svn.gnome.org/viewvc/brasero?rev=1357&view=rev

Log:
	Make brasero more intelligent when choosing destination media
	Fix a small bug with FAST_BLANK flag being used unconditionally

	* src/brasero-burn-options.c (brasero_burn_options_add_source),
	(brasero_burn_options_valid_media_cb):
	* src/brasero-dest-selection.c
	(brasero_dest_selection_foreach_medium),
	(brasero_dest_selection_choose_best),
	(brasero_dest_selection_set_property):
	* src/brasero-dest-selection.h:
	* src/brasero-medium-selection.c
	(brasero_medium_selection_foreach):
	* src/brasero-medium-selection.h:
	* src/brasero-session-cfg.c
	(brasero_session_cfg_add_drive_properties_flags):


Modified:
   trunk/ChangeLog
   trunk/src/brasero-burn-options.c
   trunk/src/brasero-dest-selection.c
   trunk/src/brasero-dest-selection.h
   trunk/src/brasero-medium-selection.c
   trunk/src/brasero-medium-selection.h
   trunk/src/brasero-session-cfg.c

Modified: trunk/src/brasero-burn-options.c
==============================================================================
--- trunk/src/brasero-burn-options.c	(original)
+++ trunk/src/brasero-burn-options.c	Wed Oct  8 10:42:07 2008
@@ -91,6 +91,8 @@
 
 	gtk_container_add (GTK_CONTAINER (priv->source), source);
 	gtk_widget_show (priv->source);
+
+	brasero_dest_selection_choose_best (BRASERO_DEST_SELECTION (priv->selection));
 }
 
 void
@@ -229,9 +231,8 @@
 	BraseroSessionError valid;
 	gint numcopies;
 
-g_print("VALID %d\n", valid);
 	valid = brasero_session_cfg_get_error (session);
-g_print("VALID2 %d\n", valid);
+
 	priv = BRASERO_BURN_OPTIONS_PRIVATE (self);
 
 	gtk_widget_set_sensitive (priv->button, valid == BRASERO_SESSION_VALID);

Modified: trunk/src/brasero-dest-selection.c
==============================================================================
--- trunk/src/brasero-dest-selection.c	(original)
+++ trunk/src/brasero-dest-selection.c	Wed Oct  8 10:42:07 2008
@@ -214,6 +214,67 @@
 	G_OBJECT_CLASS (brasero_dest_selection_parent_class)->finalize (object);
 }
 
+static gboolean
+brasero_dest_selection_foreach_medium (BraseroMedium *medium,
+				       gpointer callback_data)
+{
+	BraseroBurnSession *session;
+	BraseroDrive *burner;
+
+	session = callback_data;
+	burner = brasero_burn_session_get_burner (session);
+
+	if (!burner) {
+		brasero_burn_session_set_burner (session, brasero_medium_get_drive (medium));
+		return TRUE;
+	}
+
+	/* no need to deal with this case */
+	if (brasero_drive_get_medium (burner) == medium)
+		return TRUE;
+
+	/* The rule is:
+	 * - take the biggest
+	 * - blank media are our favourite
+	 * - try to avoid a medium that is already our source for copying */
+
+	/* NOTE: we could check if medium is bigger */
+	if (brasero_burn_session_get_dest_media (session) & BRASERO_MEDIUM_BLANK)
+		return TRUE;
+
+	if (brasero_medium_get_status (medium) & BRASERO_MEDIUM_BLANK) {
+		brasero_burn_session_set_burner (session, brasero_medium_get_drive (medium));
+		return TRUE;
+	}
+	if (brasero_burn_session_same_src_dest_drive (session)) {
+		brasero_burn_session_set_burner (session, brasero_medium_get_drive (medium));
+		return TRUE;
+	}
+
+	return TRUE;
+}
+
+void
+brasero_dest_selection_choose_best (BraseroDestSelection *self)
+{
+	BraseroDestSelectionPrivate *priv;
+
+	priv = BRASERO_DEST_SELECTION_PRIVATE (self);
+	if (!(brasero_burn_session_get_flags (priv->session) & BRASERO_BURN_FLAG_MERGE)) {
+		BraseroDrive *drive;
+
+		/* Select the best fitting media */
+		brasero_medium_selection_foreach (BRASERO_MEDIUM_SELECTION (self),
+						  brasero_dest_selection_foreach_medium,
+						  priv->session);
+
+		drive = brasero_burn_session_get_burner (BRASERO_BURN_SESSION (priv->session));
+		if (drive)
+			brasero_medium_selection_set_active (BRASERO_MEDIUM_SELECTION (self),
+							     brasero_drive_get_medium (drive));
+	}
+}
+
 static void
 brasero_dest_selection_set_property (GObject *object,
 				     guint property_id,
@@ -237,17 +298,18 @@
 		 * it's only set at construct time */
 		priv->session = session;
 		g_object_ref (session);
+
+		drive = brasero_medium_selection_get_active_drive (BRASERO_MEDIUM_SELECTION (object));
+		if (drive) {
+			brasero_burn_session_set_burner (session, drive);
+			g_object_unref (drive);
+		}
+
 		priv->valid_sig = g_signal_connect (session,
 						    "is-valid",
 						    G_CALLBACK (brasero_dest_selection_valid_session),
 						    object);
 
-		drive = brasero_medium_selection_get_active_drive (BRASERO_MEDIUM_SELECTION (object));
-		brasero_burn_session_set_burner (session, drive);
-
-		if (drive)
-			g_object_unref (drive);
-
 		brasero_medium_selection_update_media_string (BRASERO_MEDIUM_SELECTION (object));
 		break;
 

Modified: trunk/src/brasero-dest-selection.h
==============================================================================
--- trunk/src/brasero-dest-selection.h	(original)
+++ trunk/src/brasero-dest-selection.h	Wed Oct  8 10:42:07 2008
@@ -55,12 +55,15 @@
 GType brasero_dest_selection_get_type (void) G_GNUC_CONST;
 
 GtkWidget *
-brasero_dest_selection_new (BraseroBurnSession *session);
+brasero_dest_selection_new (BraseroBurnSession *selection);
 
 void
-brasero_dest_selection_lock (BraseroDestSelection *session,
+brasero_dest_selection_lock (BraseroDestSelection *selection,
 			     gboolean locked);
 
+void
+brasero_dest_selection_choose_best (BraseroDestSelection *selection);
+
 G_END_DECLS
 
 #endif /* _BRASERO_DEST_SELECTION_H_ */

Modified: trunk/src/brasero-medium-selection.c
==============================================================================
--- trunk/src/brasero-medium-selection.c	(original)
+++ trunk/src/brasero-medium-selection.c	Wed Oct  8 10:42:07 2008
@@ -65,6 +65,37 @@
 
 G_DEFINE_TYPE (BraseroMediumSelection, brasero_medium_selection, GTK_TYPE_COMBO_BOX);
 
+void
+brasero_medium_selection_foreach (BraseroMediumSelection *selection,
+				  BraseroMediumSelectionFunc function,
+				  gpointer callback_data)
+{
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (selection));
+
+	if (!gtk_tree_model_get_iter_first (model, &iter))
+		return;
+
+	do {
+		BraseroMedium *medium;
+
+		medium = NULL;
+		gtk_tree_model_get (model, &iter,
+				    MEDIUM_COL, &medium,
+				    -1);
+
+		/* The following can happen when there isn't any medium */
+		if (!medium)
+			return;
+
+		if (!function (medium, callback_data))
+			break;
+
+	} while (gtk_tree_model_iter_next (model, &iter));
+}
+
 static gchar *
 brasero_medium_selection_get_medium_string (BraseroMediumSelection *self,
 					    BraseroMedium *medium)

Modified: trunk/src/brasero-medium-selection.h
==============================================================================
--- trunk/src/brasero-medium-selection.h	(original)
+++ trunk/src/brasero-medium-selection.h	Wed Oct  8 10:42:07 2008
@@ -60,6 +60,7 @@
 GType brasero_medium_selection_get_type (void) G_GNUC_CONST;
 GtkWidget* brasero_medium_selection_new (void);
 
+typedef gboolean (*BraseroMediumSelectionFunc) (BraseroMedium *medium, gpointer callback_data);
 
 BraseroMedium *
 brasero_medium_selection_get_active (BraseroMediumSelection *selection);
@@ -72,6 +73,11 @@
 				     BraseroMedium *medium);
 
 void
+brasero_medium_selection_foreach (BraseroMediumSelection *selection,
+				  BraseroMediumSelectionFunc function,
+				  gpointer callback_data);
+
+void
 brasero_medium_selection_show_type (BraseroMediumSelection *selection,
 				    BraseroMediaType type);
 

Modified: trunk/src/brasero-session-cfg.c
==============================================================================
--- trunk/src/brasero-session-cfg.c	(original)
+++ trunk/src/brasero-session-cfg.c	Wed Oct  8 10:42:07 2008
@@ -204,8 +204,11 @@
 	/* Always set this flag whenever possible */
 	if (priv->supported & BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE) {
 		brasero_burn_session_add_flag (BRASERO_BURN_SESSION (self),
-					       BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE|
-					       BRASERO_BURN_FLAG_FAST_BLANK);
+					       BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE);
+
+		if (priv->supported & BRASERO_BURN_FLAG_FAST_BLANK)
+			brasero_burn_session_add_flag (BRASERO_BURN_SESSION (self),
+						       BRASERO_BURN_FLAG_FAST_BLANK);
 
 		priv->supported = BRASERO_BURN_FLAG_NONE;
 		priv->compulsory = BRASERO_BURN_FLAG_NONE;



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