[brasero] Remove the oversize signal from BraseroDataSession and others as it's now handled by BraseroSessionC



commit eaf391ee21fddf8f357f7101b83731000349bdb4
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Wed Jun 3 14:56:49 2009 +0200

    Remove the oversize signal from BraseroDataSession and others as it's now handled by BraseroSessionCfg
    Added to BraseroProject the necessary message to match BraseroSessionCfg

 libbrasero-burn/brasero-data-session.c   |  101 ----------------------
 libbrasero-burn/brasero-track-data-cfg.c |   29 -------
 src/brasero-data-disc.c                  |   78 -----------------
 src/brasero-project.c                    |  135 +++++++++++++++++++++++++++++-
 4 files changed, 131 insertions(+), 212 deletions(-)
---
diff --git a/libbrasero-burn/brasero-data-session.c b/libbrasero-burn/brasero-data-session.c
index e874e3b..99f3863 100644
--- a/libbrasero-burn/brasero-data-session.c
+++ b/libbrasero-burn/brasero-data-session.c
@@ -66,11 +66,6 @@ struct _BraseroDataSessionPrivate
 
 	/* Nodes from the loaded session in the tree */
 	GSList *nodes;
-
-	glong size_changed_sig;
-
-	guint is_oversized:1;
-	guint is_overburn:1;
 };
 
 #define BRASERO_DATA_SESSION_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_DATA_SESSION, BraseroDataSessionPrivate))
@@ -78,7 +73,6 @@ struct _BraseroDataSessionPrivate
 G_DEFINE_TYPE (BraseroDataSession, brasero_data_session, BRASERO_TYPE_DATA_PROJECT);
 
 enum {
-	OVERSIZE_SIGNAL,
 	AVAILABLE_SIGNAL,
 	LOADED_SIGNAL,
 	LAST_SIGNAL
@@ -205,77 +199,6 @@ brasero_io_load_image_directory (const gchar *dev_image,
 
 }
 
-static void
-brasero_data_session_check_size (BraseroDataSession *self)
-{
-	BraseroDataSessionPrivate *priv;
-	gint64 max_sectors = 0;
-	gint64 medium_sect = 0;
-	goffset sectors = 0;
-
-	priv = BRASERO_DATA_SESSION_PRIVATE (self);
-
-	sectors = brasero_data_project_get_sectors (BRASERO_DATA_PROJECT (self));
-	brasero_medium_get_free_space (priv->loaded,
-				       NULL,
-				       &medium_sect);
-
-	/* NOTE: This is not good since with a DVD 3% of 4.3G may be too much
-	 * with 3% we are slightly over the limit of the most overburnable discs
-	 * but at least users can try to overburn as much as they can. */
-
-	/* The idea would be to test write the disc with cdrecord from /dev/null
-	 * until there is an error and see how much we were able to write. So,
-	 * when we propose overburning to the user, we could ask if he wants
-	 * us to determine how much data can be written to a particular disc
-	 * provided he has chosen a real disc. */
-	max_sectors = medium_sect * 103 / 100;
-
-	if (medium_sect < sectors) {
-		/* send it once */
-		if (!priv->is_oversized || priv->is_overburn) {
-			gboolean overburn;
-
-			/* see if overburn is possible */
-			overburn = (sectors < max_sectors);
-			if (!priv->is_overburn && overburn)
-				g_signal_emit (self,
-					       brasero_data_session_signals [OVERSIZE_SIGNAL],
-					       0,
-					       TRUE,
-					       overburn);
-			else if (!overburn)
-				g_signal_emit (self,
-					       brasero_data_session_signals [OVERSIZE_SIGNAL],
-					       0,
-					       TRUE,
-					       overburn);
-
-			priv->is_overburn = overburn;
-		}
-
-		priv->is_oversized = TRUE;
-	}
-	else {
-		if (priv->is_oversized || priv->is_overburn)
-			g_signal_emit (self,
-				       brasero_data_session_signals [OVERSIZE_SIGNAL],
-				       0,
-				       FALSE,
-				       FALSE);
-
-		priv->is_oversized = FALSE;
-		priv->is_overburn = FALSE;
-	}
-}
-
-static void
-brasero_data_session_size_changed (BraseroDataProject *project,
-				   gpointer NULL_data)
-{
-	brasero_data_session_check_size (BRASERO_DATA_SESSION (project));
-}
-
 void
 brasero_data_session_remove_last (BraseroDataSession *self)
 {
@@ -308,14 +231,6 @@ brasero_data_session_remove_last (BraseroDataSession *self)
 		g_object_unref (priv->loaded);
 		priv->loaded = NULL;
 	}
-
-	if (priv->size_changed_sig) {
-		g_signal_handler_disconnect (self, priv->size_changed_sig);
-		priv->size_changed_sig = 0;
-	}
-
-	priv->is_oversized = FALSE;
-	priv->is_overburn = FALSE;
 }
 
 static void
@@ -458,11 +373,6 @@ brasero_data_session_add_last (BraseroDataSession *self,
 	priv->loaded = medium;
 	g_object_ref (medium);
 
-	priv->size_changed_sig = g_signal_connect (self,
-						   "size-changed",
-						   G_CALLBACK (brasero_data_session_size_changed),
-						   NULL);
-
 	return brasero_data_session_load_directory_contents_real (self, NULL, error);
 }
 
@@ -704,15 +614,4 @@ brasero_data_session_class_init (BraseroDataSessionClass *klass)
 			  2,
 			  G_TYPE_OBJECT,
 			  G_TYPE_BOOLEAN);
-	brasero_data_session_signals [OVERSIZE_SIGNAL] = 
-	    g_signal_new ("oversize",
-			  G_TYPE_FROM_CLASS (klass),
-			  G_SIGNAL_RUN_LAST,
-			  0,
-			  NULL, NULL,
-			  brasero_marshal_VOID__BOOLEAN_BOOLEAN,
-			  G_TYPE_NONE,
-			  2,
-			  G_TYPE_BOOLEAN,
-			  G_TYPE_BOOLEAN);
 }
diff --git a/libbrasero-burn/brasero-track-data-cfg.c b/libbrasero-burn/brasero-track-data-cfg.c
index 7229845..51690cb 100644
--- a/libbrasero-burn/brasero-track-data-cfg.c
+++ b/libbrasero-burn/brasero-track-data-cfg.c
@@ -115,7 +115,6 @@ typedef enum {
 enum {
 	AVAILABLE,
 	LOADED,
-	OVERSIZE,
 	ACTIVITY,
 	IMAGE,
 	UNREADABLE,
@@ -2688,19 +2687,6 @@ emit_signal:
 }
 
 static void
-brasero_track_data_cfg_oversized_cb (BraseroDataProject *project,
-				     gboolean is_oversized,
-				     gboolean overburn_possible,
-				     BraseroTrackDataCfg *self)
-{
-	g_signal_emit (self,
-		       brasero_track_data_cfg_signals [OVERSIZE],
-		       0,
-		       is_oversized,
-		       overburn_possible);
-}
-
-static void
 brasero_track_data_cfg_size_changed_cb (BraseroDataProject *project,
 					BraseroTrackDataCfg *self)
 {
@@ -3002,10 +2988,6 @@ brasero_track_data_cfg_init (BraseroTrackDataCfg *object)
 			  object);
 
 	g_signal_connect (priv->tree,
-			  "oversize",
-			  G_CALLBACK (brasero_track_data_cfg_oversized_cb),
-			  object);
-	g_signal_connect (priv->tree,
 			  "size-changed",
 			  G_CALLBACK (brasero_track_data_cfg_size_changed_cb),
 			  object);
@@ -3111,17 +3093,6 @@ brasero_track_data_cfg_class_init (BraseroTrackDataCfgClass *klass)
 			  2,
 			  G_TYPE_OBJECT,
 			  G_TYPE_BOOLEAN);
-	brasero_track_data_cfg_signals [OVERSIZE] = 
-	    g_signal_new ("session_oversized",
-			  G_TYPE_FROM_CLASS (klass),
-			  G_SIGNAL_RUN_LAST,
-			  0,
-			  NULL, NULL,
-			  brasero_marshal_VOID__BOOLEAN_BOOLEAN,
-			  G_TYPE_NONE,
-			  2,
-			  G_TYPE_BOOLEAN,
-			  G_TYPE_BOOLEAN);
 
 	brasero_track_data_cfg_signals [ACTIVITY] = 
 	    g_signal_new ("vfs_activity",
diff --git a/src/brasero-data-disc.c b/src/brasero-data-disc.c
index c89c149..06b49c4 100644
--- a/src/brasero-data-disc.c
+++ b/src/brasero-data-disc.c
@@ -523,79 +523,6 @@ brasero_data_disc_name_edited_cb (GtkCellRendererText *cellrenderertext,
  */
 
 static void
-brasero_data_disc_use_overburn_response_cb (BraseroDiscMessage *message,
-					    GtkResponseType response,
-					    BraseroDataDisc *self)
-{
-	BraseroDataDiscPrivate *priv;
-
-	priv = BRASERO_DATA_DISC_PRIVATE (self);
-
-	if (response != GTK_RESPONSE_OK)
-		return;
-
-	priv->overburning = 1;
-}
-
-static void
-brasero_data_disc_project_oversized_cb (BraseroTrackDataCfg *project,
-					gboolean oversized,
-					gboolean overburn,
-					BraseroDataDisc *self)
-{
-	GtkWidget *message;
-	BraseroDataDiscPrivate *priv;
-
-	priv = BRASERO_DATA_DISC_PRIVATE (self);
-
-	if (!priv->message)
-		return;
-
-	if (overburn) {
-		if (priv->overburning)
-			return;
-
-		message = brasero_notify_message_add (BRASERO_NOTIFY (priv->message),
-						      _("Would you like to burn beyond the disc reported capacity?"),
-						      _("The size of the project is too large for the disc and you must remove files from the project otherwise."
-							"\nYou may want to use this option if you're using 90 or 100 min CD-R(W) which cannot be properly recognised and therefore need overburn option."
-							"\nNOTE: This option might cause failure."),
-						      -1,
-						      BRASERO_NOTIFY_CONTEXT_SIZE);
-
-		brasero_disc_message_set_image (BRASERO_DISC_MESSAGE (message), GTK_STOCK_DIALOG_WARNING);
-		brasero_notify_button_add (BRASERO_NOTIFY (priv->message),
-					   BRASERO_DISC_MESSAGE (message),
-					   _("_Overburn"),
-					   _("Burn beyond the disc reported capacity"),
-					   GTK_RESPONSE_OK);
-		brasero_notify_button_add (BRASERO_NOTIFY (priv->message),
-					   BRASERO_DISC_MESSAGE (message),
-					   GTK_STOCK_CANCEL,
-					   _("Click here not to use overburning"),
-					   GTK_RESPONSE_CANCEL);
-		
-		g_signal_connect (BRASERO_DISC_MESSAGE (message),
-				  "response",
-				  G_CALLBACK (brasero_data_disc_use_overburn_response_cb),
-				  self);
-	}
-	else if (oversized) {
-		message = brasero_notify_message_add (BRASERO_NOTIFY (priv->message),
-						      _("Please delete some files from the project."),
-						      _("The size of the project is too large for the disc even with the overburn option."),
-						      -1,
-						      BRASERO_NOTIFY_CONTEXT_SIZE);
-
-		brasero_disc_message_set_image (BRASERO_DISC_MESSAGE (message), GTK_STOCK_DIALOG_WARNING);
-		brasero_disc_message_add_close_button (BRASERO_DISC_MESSAGE (message));
-	}
-	else
-		brasero_notify_message_remove (BRASERO_NOTIFY (priv->message),
-					       BRASERO_NOTIFY_CONTEXT_SIZE);
-}
-
-static void
 brasero_data_disc_project_loading_cb (BraseroTrackDataCfg *project,
 				      gdouble progress,
 				      BraseroDataDisc *self)
@@ -2235,11 +2162,6 @@ brasero_data_disc_init (BraseroDataDisc *object)
 			  G_CALLBACK (brasero_data_disc_project_loaded_cb),
 			  object);
 
-	g_signal_connect (priv->project,
-			  "session-oversized",
-			  G_CALLBACK (brasero_data_disc_project_oversized_cb),
-			  object);
-
 	/* Use the BraseroTrack "changed" signal */
 	g_signal_connect (priv->project,
 			  "changed",
diff --git a/src/brasero-project.c b/src/brasero-project.c
index e3cf50a..460db55 100644
--- a/src/brasero-project.c
+++ b/src/brasero-project.c
@@ -67,6 +67,8 @@
 #include "brasero-burn-options.h"
 #include "brasero-cover.h"
 
+#include "brasero-medium-selection-priv.h"
+#include "brasero-session-helper.h"
 #include "brasero-session-cfg.h"
 #include "brasero-dest-selection.h"
 
@@ -156,7 +158,7 @@ typedef enum {
 } BraseroProjectSave;
 
 struct BraseroProjectPrivate {
-	BraseroBurnSession *session;
+	BraseroSessionCfg *session;
 
 	GtkWidget *selection;
 	GtkWidget *name_display;
@@ -552,6 +554,126 @@ brasero_project_icon_button_size_request (GtkWidget *widget,
 }
 
 static void
+brasero_project_message_response_span_cb (BraseroDiscMessage *message,
+					  GtkResponseType response,
+					  BraseroProject *project)
+{
+	if (response == GTK_RESPONSE_OK)
+		brasero_session_span_start (BRASERO_SESSION_SPAN (project->priv->session));
+}
+
+static void
+brasero_project_message_response_overburn_cb (BraseroDiscMessage *message,
+					      GtkResponseType response,
+					      BraseroProject *project)
+{
+	if (response == GTK_RESPONSE_OK)
+		brasero_session_cfg_add_flags (project->priv->session, BRASERO_BURN_FLAG_OVERBURN);
+}
+
+static void
+brasero_project_is_valid (BraseroSessionCfg *session,
+			  BraseroProject *project)
+{
+	BraseroSessionError valid;
+
+	valid = brasero_session_cfg_get_error (project->priv->session);
+
+	/* Update burn button state */
+	gtk_widget_set_sensitive (project->priv->burn, BRASERO_SESSION_IS_VALID (valid));
+
+	/* FIXME: update option button state as well */
+
+	/* Clean any message */
+	brasero_notify_message_remove (BRASERO_NOTIFY (project->priv->message),
+				       BRASERO_NOTIFY_CONTEXT_SIZE);
+
+	if (valid == BRASERO_SESSION_INSUFFICIENT_SPACE) {
+		/* Here there is an alternative: we may be able to span the data
+		 * across multiple media. So try that. */
+		if (brasero_session_span_possible (BRASERO_SESSION_SPAN (project->priv->session)) == BRASERO_BURN_RETRY) {
+			GtkWidget *message;
+
+			message = brasero_notify_message_add (BRASERO_NOTIFY (project->priv->message),
+							      _("Would you like to burn the selection of files across several media?"),
+							      _("The size of the project is too large for the disc even with the overburn option."),
+							      -1,
+							      BRASERO_NOTIFY_CONTEXT_SIZE);
+			brasero_notify_button_add (BRASERO_NOTIFY (project->priv->message),
+						   BRASERO_DISC_MESSAGE (message),
+						   _("_Burn Several Discs"),
+						   _("Burn the selection of files across several media"),
+						   GTK_RESPONSE_OK);
+
+			g_signal_connect (message,
+					  "response",
+					  G_CALLBACK (brasero_project_message_response_span_cb),
+					  project);
+		}
+		else
+			brasero_notify_message_add (BRASERO_NOTIFY (project->priv->message),
+						    _("Please choose another CD or DVD or insert a new one."),
+						    _("The size of the project is too large for the disc even with the overburn option."),
+						    -1,
+						    BRASERO_NOTIFY_CONTEXT_SIZE);
+	}
+	else if (valid == BRASERO_SESSION_OVERBURN_NECESSARY) {
+		GtkWidget *message;
+
+		message = brasero_notify_message_add (BRASERO_NOTIFY (project->priv->message),
+						      _("Would you like to burn beyond the disc reported capacity?"),
+						      _("The size of the project is too large for the disc and you must remove files from the project otherwise."
+							"\nYou may want to use this option if you're using 90 or 100 min CD-R(W) which cannot be properly recognised and therefore need overburn option."
+							"\nNOTE: This option might cause failure."),
+						      -1,
+						      BRASERO_NOTIFY_CONTEXT_SIZE);
+		brasero_notify_button_add (BRASERO_NOTIFY (project->priv->message),
+					   BRASERO_DISC_MESSAGE (message),
+					   _("_Overburn"),
+					   _("Burn beyond the disc reported capacity"),
+					   GTK_RESPONSE_OK);
+
+		g_signal_connect (message,
+				  "response",
+				  G_CALLBACK (brasero_project_message_response_overburn_cb),
+				  project);
+	}
+	else if (valid == BRASERO_SESSION_NO_OUTPUT) {
+		brasero_notify_message_add (BRASERO_NOTIFY (project->priv->message),
+					    _("Please insert a recordable CD or DVD."),
+					    _("There is no recordable disc inserted."),
+					    -1,
+					    BRASERO_NOTIFY_CONTEXT_SIZE);
+	}
+	else if (valid == BRASERO_SESSION_NO_CD_TEXT) {
+		brasero_notify_message_add (BRASERO_NOTIFY (project->priv->message),
+					    _("No track information (artist, title, ...) will be written to the disc."),
+					    _("This is not supported by the current active burning backend."),
+					    -1,
+					    BRASERO_NOTIFY_CONTEXT_SIZE);
+	}
+	else if (valid == BRASERO_SESSION_NOT_SUPPORTED) {
+		brasero_notify_message_add (BRASERO_NOTIFY (project->priv->message),
+					    _("Please replace the disc with a supported CD or DVD."),
+					    _("It is not possible to write with the current set of plugins."),
+					    -1,
+					    BRASERO_NOTIFY_CONTEXT_SIZE);
+	}
+	else if (brasero_burn_session_is_dest_file (BRASERO_BURN_SESSION (project->priv->session))
+	     &&  brasero_medium_selection_get_media_num (BRASERO_MEDIUM_SELECTION (project->priv->selection)) == 1) {
+		/* The user may have forgotten to insert a disc so remind him of that if
+		 * there aren't any other possibility in the selection */
+		brasero_notify_message_add (BRASERO_NOTIFY (project->priv->message),
+					    _("Please insert a recordable CD or DVD if you don't want to write to an image file."),
+					    NULL,
+					    -1,
+					    BRASERO_NOTIFY_CONTEXT_SIZE);
+	}
+
+
+}
+
+static void
 brasero_project_init (BraseroProject *obj)
 {
 	GtkSizeGroup *size_group;
@@ -574,9 +696,13 @@ brasero_project_init (BraseroProject *obj)
 	gtk_box_pack_start (GTK_BOX (obj), obj->priv->message, FALSE, TRUE, 0);
 	gtk_widget_show (obj->priv->message);
 
-	/* bottom */
-	obj->priv->session = BRASERO_BURN_SESSION (brasero_session_cfg_new ());
+	obj->priv->session = brasero_session_cfg_new ();
+	g_signal_connect (obj->priv->session,
+			  "is-valid",
+			  G_CALLBACK (brasero_project_is_valid),
+			  obj);
 
+	/* bottom */
 	box = gtk_hbox_new (FALSE, 6);
 	gtk_container_set_border_width (GTK_CONTAINER (box), 0);
 	gtk_widget_show (box);
@@ -599,7 +725,7 @@ brasero_project_init (BraseroProject *obj)
 			  GTK_EXPAND,
 			  0, 0);
 
-	selector = brasero_dest_selection_new (obj->priv->session);
+	selector = brasero_dest_selection_new (BRASERO_BURN_SESSION (obj->priv->session));
 	gtk_widget_show (selector);
 	obj->priv->selection = selector;
 
@@ -832,6 +958,7 @@ brasero_project_new ()
 }
 
 /********************************** size ***************************************/
+
 gchar *
 brasero_project_get_sectors_string (gint64 sectors,
 				    gboolean time_format)



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