brasero r926 - in trunk: . src
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r926 - in trunk: . src
- Date: Sat, 28 Jun 2008 15:05:57 +0000 (UTC)
Author: philippr
Date: Sat Jun 28 15:05:56 2008
New Revision: 926
URL: http://svn.gnome.org/viewvc/brasero?rev=926&view=rev
Log:
Some cleanups
Fix a problem when copying a disc with the same source and destination
where dialog allowed to copy even if the source disc couldn\'t be read
* src/brasero-dest-selection.c
(brasero_dest_selection_get_possible_output_formats),
(brasero_dest_selection_set_drive_properties),
(brasero_dest_selection_set_image_properties),
(brasero_dest_selection_check_image_settings),
(brasero_dest_selection_check_drive_settings),
(brasero_dest_selection_source_changed),
(brasero_dest_selection_caps_changed),
(brasero_dest_selection_output_changed):
* src/brasero-disc-copy-dialog.c (brasero_disc_copy_dialog_init):
* src/burn-caps.c
(brasero_burn_caps_is_session_supported_same_src_dest),
(brasero_burn_caps_is_session_supported),
(brasero_burn_caps_get_required_media_type):
* src/burn-medium.c (brasero_medium_get_icon):
Modified:
trunk/ChangeLog
trunk/src/brasero-dest-selection.c
trunk/src/brasero-disc-copy-dialog.c
trunk/src/burn-caps.c
trunk/src/burn-medium.c
Modified: trunk/src/brasero-dest-selection.c
==============================================================================
--- trunk/src/brasero-dest-selection.c (original)
+++ trunk/src/brasero-dest-selection.c Sat Jun 28 15:05:56 2008
@@ -478,7 +478,7 @@
output.type = BRASERO_TRACK_TYPE_IMAGE;
for (; format > BRASERO_IMAGE_FORMAT_NONE; format >>= 1) {
- gboolean result;
+ BraseroBurnResult result;
output.subtype.img_format = format;
result = brasero_burn_caps_is_output_supported (priv->caps,
@@ -807,14 +807,15 @@
brasero_dest_selection_set_drive_properties (BraseroDestSelection *self)
{
BraseroDestSelectionPrivate *priv;
+ BraseroBurnResult is_valid;
BraseroTrackType source;
BraseroBurnFlag flags;
BraseroMedium *medium;
BraseroDrive *drive;
GConfClient *client;
GConfValue *value;
- gchar *path;
guint64 rate;
+ gchar *path;
gchar *key;
priv = BRASERO_DEST_SELECTION_PRIVATE (self);
@@ -826,6 +827,7 @@
0,
FALSE);
gtk_widget_set_sensitive (priv->button, FALSE);
+ gtk_widget_set_sensitive (priv->copies_box, FALSE);
return;
}
@@ -898,47 +900,22 @@
value = gconf_client_get_without_default (client, key, NULL);
g_free (key);
- if (!value) {
- BraseroBurnResult result;
- BraseroBurnFlag supported = BRASERO_BURN_FLAG_NONE;
- BraseroBurnFlag compulsory = BRASERO_BURN_FLAG_NONE;
-
- flags = BRASERO_BURN_FLAG_EJECT|
- BRASERO_BURN_FLAG_BURNPROOF;
-
- if (source.type == BRASERO_TRACK_TYPE_DATA
- || source.type == BRASERO_TRACK_TYPE_DISC
- || source.type == BRASERO_TRACK_TYPE_IMAGE)
- flags |= BRASERO_BURN_FLAG_NO_TMP_FILES;
-
- brasero_dest_selection_add_drive_properties_flags (self,
- flags,
- &supported,
- &compulsory);
-
- /* Now that we updated the session flags see if everything works */
- result = brasero_burn_caps_is_session_supported (priv->caps, priv->session);
- g_signal_emit (self,
- brasero_dest_selection_signals [VALID_MEDIA_SIGNAL],
- 0,
- (result == BRASERO_BURN_OK));
-
- gtk_widget_set_sensitive (priv->button, (result == BRASERO_BURN_OK));
- gtk_widget_set_sensitive (priv->copies_box, (result == BRASERO_BURN_OK));
- }
- else if (brasero_dest_selection_check_same_src_dest (self)) {
- /* Special case: better not check if session is supported. */
+ if (brasero_dest_selection_check_same_src_dest (self)) {
+ /* Special case */
/* wipe out previous flags */
brasero_burn_session_remove_flag (priv->session,
- BRASERO_DRIVE_PROPERTIES_FLAGS|
- BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE|
- BRASERO_BURN_FLAG_FAST_BLANK|
- BRASERO_BURN_FLAG_DAO);
+ BRASERO_DRIVE_PROPERTIES_FLAGS);
/* set new ones */
- flags = gconf_value_get_int (value) & BRASERO_DEST_SAVED_FLAGS;
- gconf_value_free (value);
+ if (value) {
+ flags = gconf_value_get_int (value) & BRASERO_DEST_SAVED_FLAGS;
+ gconf_value_free (value);
+ }
+ else
+ flags = BRASERO_BURN_FLAG_EJECT|
+ BRASERO_BURN_FLAG_BURNPROOF;
+
brasero_burn_session_add_flag (priv->session, flags);
/* NOTE: of course NO_TMP is not possible; DAO and BLANK_BEFORE
@@ -950,16 +927,25 @@
BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE|
BRASERO_BURN_FLAG_FAST_BLANK|
BRASERO_BURN_FLAG_DAO);
+ }
+ else if (!value) {
+ BraseroBurnFlag supported = BRASERO_BURN_FLAG_NONE;
+ BraseroBurnFlag compulsory = BRASERO_BURN_FLAG_NONE;
- g_signal_emit (self,
- brasero_dest_selection_signals [VALID_MEDIA_SIGNAL],
- 0,
- TRUE);
- gtk_widget_set_sensitive (priv->button, TRUE);
- gtk_widget_set_sensitive (priv->copies_box, TRUE);
+ flags = BRASERO_BURN_FLAG_EJECT|
+ BRASERO_BURN_FLAG_BURNPROOF;
+
+ if (source.type == BRASERO_TRACK_TYPE_DATA
+ || source.type == BRASERO_TRACK_TYPE_DISC
+ || source.type == BRASERO_TRACK_TYPE_IMAGE)
+ flags |= BRASERO_BURN_FLAG_NO_TMP_FILES;
+
+ brasero_dest_selection_add_drive_properties_flags (self,
+ flags,
+ &supported,
+ &compulsory);
}
else {
- BraseroBurnResult result;
BraseroBurnFlag supported = BRASERO_BURN_FLAG_NONE;
BraseroBurnFlag compulsory = BRASERO_BURN_FLAG_NONE;
@@ -971,18 +957,17 @@
flags,
&supported,
&compulsory);
+ }
- /* Now that we updated the session flags see if everything works
- * if not, unset all flags and retry. */
- result = brasero_burn_caps_is_session_supported (priv->caps, priv->session);
- g_signal_emit (self,
- brasero_dest_selection_signals [VALID_MEDIA_SIGNAL],
- 0,
- (result == BRASERO_BURN_OK));
+ /* Now that we updated the session flags see if everything works */
+ is_valid = brasero_burn_caps_is_session_supported (priv->caps, priv->session);
+ g_signal_emit (self,
+ brasero_dest_selection_signals [VALID_MEDIA_SIGNAL],
+ 0,
+ (is_valid == BRASERO_BURN_OK));
- gtk_widget_set_sensitive (priv->copies_box, (result == BRASERO_BURN_OK));
- gtk_widget_set_sensitive (priv->button, (result == BRASERO_BURN_OK));
- }
+ gtk_widget_set_sensitive (priv->copies_box, (is_valid == BRASERO_BURN_OK));
+ gtk_widget_set_sensitive (priv->button, (is_valid == BRASERO_BURN_OK));
key = g_strdup_printf ("%s/tmpdir", BRASERO_DRIVE_PROPERTIES_KEY);
path = gconf_client_get_string (client, key, NULL);
@@ -1010,6 +995,7 @@
if (output.type == BRASERO_TRACK_TYPE_NONE
|| output.subtype.img_format == BRASERO_IMAGE_FORMAT_NONE) {
/* That means that we've got a problem */
+ /* FIXME: we need to display a message nevertheless */
brasero_burn_session_set_image_output (priv->session,
BRASERO_IMAGE_FORMAT_NONE,
NULL);
@@ -1017,6 +1003,7 @@
brasero_dest_selection_signals [VALID_MEDIA_SIGNAL],
0,
FALSE);
+
gtk_widget_set_sensitive (priv->button, FALSE);
return;
}
@@ -1050,12 +1037,15 @@
priv = BRASERO_DEST_SELECTION_PRIVATE (self);
if (brasero_burn_session_get_output (priv->session, NULL, NULL, NULL) == BRASERO_BURN_OK) {
+ gchar *path;
BraseroTrackType output;
BraseroImageFormat format;
+ /* we already have an output check its validity */
output.type = BRASERO_TRACK_TYPE_IMAGE;
if (!priv->default_format) {
+ /* The user set a format */
output.subtype.img_format = brasero_burn_session_get_output_format (priv->session);
/* check that the format is still supported. If not then find a good default */
@@ -1071,35 +1061,17 @@
brasero_dest_selection_get_default_output_format (self, &output);
format = output.subtype.img_format;
-
- if (format != BRASERO_IMAGE_FORMAT_NONE) {
- gchar *path;
-
- if (!priv->default_path) {
- /* check that the extension is ok */
- path = brasero_dest_selection_get_output_path (self);
- if (priv->default_ext
- && brasero_dest_selection_image_check_extension (self, format, path))
- path = brasero_dest_selection_fix_image_extension (format, TRUE, path);
- }
- else
- path = brasero_dest_selection_get_default_output_path (self, format);
-
- brasero_burn_session_set_image_output (priv->session, format, path);
- brasero_drive_selection_set_image_path (BRASERO_DRIVE_SELECTION (self), path);
- g_free (path);
- }
-
g_signal_emit (self,
brasero_dest_selection_signals [VALID_MEDIA_SIGNAL],
0,
(format != BRASERO_IMAGE_FORMAT_NONE));
- gtk_widget_set_sensitive (priv->button, (format != BRASERO_IMAGE_FORMAT_NONE));
- if (format == BRASERO_IMAGE_FORMAT_NONE) {
- if (priv->button)
- gtk_widget_set_sensitive (priv->button, FALSE);
+ if (priv->button)
+ gtk_widget_set_sensitive (priv->button, (format != BRASERO_IMAGE_FORMAT_NONE));
+ if (format == BRASERO_IMAGE_FORMAT_NONE) {
+ /* FIXME: we've got a problem and it's not possible,
+ * display a message to say so */
if (priv->drive_prop) {
gtk_widget_destroy (priv->drive_prop);
priv->drive_prop = NULL;
@@ -1108,8 +1080,19 @@
return;
}
- if (priv->button)
- gtk_widget_set_sensitive (priv->button, TRUE);
+ if (!priv->default_path) {
+ /* check that the extension is ok if not update it */
+ path = brasero_dest_selection_get_output_path (self);
+ if (priv->default_ext
+ && brasero_dest_selection_image_check_extension (self, format, path))
+ path = brasero_dest_selection_fix_image_extension (format, TRUE, path);
+ }
+ else
+ path = brasero_dest_selection_get_default_output_path (self, format);
+
+ brasero_burn_session_set_image_output (priv->session, format, path);
+ brasero_drive_selection_set_image_path (BRASERO_DRIVE_SELECTION (self), path);
+ g_free (path);
}
else
brasero_dest_selection_set_image_properties (self);
@@ -1129,8 +1112,7 @@
}
static void
-brasero_dest_selection_check_drive_settings (BraseroDestSelection *self,
- BraseroDrive *drive)
+brasero_dest_selection_check_drive_settings (BraseroDestSelection *self)
{
BraseroBurnFlag compulsory = BRASERO_BURN_FLAG_NONE;
BraseroBurnFlag supported = BRASERO_BURN_FLAG_NONE;
@@ -1140,35 +1122,30 @@
priv = BRASERO_DEST_SELECTION_PRIVATE (self);
- /* check for a special case */
+ /* Update the flags and save them */
if (brasero_dest_selection_check_same_src_dest (self)) {
- gtk_widget_set_sensitive (priv->button, TRUE);
- g_signal_emit (self,
- brasero_dest_selection_signals [VALID_MEDIA_SIGNAL],
- 0,
- TRUE);
- gtk_widget_set_sensitive (priv->button, TRUE);
-
- /* These are always set in any case */
+ /* These are always set in any case and there is no way to check
+ * the current flags */
brasero_burn_session_add_flag (priv->session,
BRASERO_BURN_FLAG_DAO|
BRASERO_BURN_FLAG_FAST_BLANK|
BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE);
- return;
}
+ else {
+ /* Try to properly update the flags for the current drive */
+ flags = brasero_burn_session_get_flags (priv->session);
- /* Try to properly update the flags for the current drive */
- flags = brasero_burn_session_get_flags (priv->session);
-
- /* check each flag before re-adding it */
- brasero_dest_selection_add_drive_properties_flags (self,
- flags,
- &supported,
- &compulsory);
+ /* check each flag before re-adding it */
+ brasero_dest_selection_add_drive_properties_flags (self,
+ flags,
+ &supported,
+ &compulsory);
+ }
/* NOTE: we save even if result != BRASERO_BURN_OK. That way if a flag
* is no longer supported after the removal of a plugin then the
* properties are reset and the user can access them again */
+
/* save potential changes for the new profile */
brasero_dest_selection_save_drive_properties (self);
@@ -1187,6 +1164,7 @@
brasero_dest_selection_signals [VALID_MEDIA_SIGNAL],
0,
(result == BRASERO_BURN_OK));
+
if (priv->button)
gtk_widget_set_sensitive (priv->button, (result == BRASERO_BURN_OK));
@@ -1212,7 +1190,7 @@
/* NOTE: that can't happen if we are going to write to an image since
* that would mean we are changing the image format (something we don't
- * do. So it has to be when we write to a drive */
+ * do). So it has to be when we write to a drive */
brasero_dest_selection_set_drive_properties (self);
}
@@ -1220,7 +1198,6 @@
brasero_dest_selection_caps_changed (BraseroPluginManager *manager,
BraseroDestSelection *self)
{
- BraseroDrive *drive;
BraseroDestSelectionPrivate *priv;
/* In this case we are still in the same context (same src, dest) so we
@@ -1231,14 +1208,10 @@
/* The caps of the library / the source have changed so we must check:
* if it's an image that the output type is still possible
* if it's a drive that all flags are still supported and that the media is too */
- drive = brasero_burn_session_get_burner (priv->session);
- if (!drive)
- return;
-
- if (!brasero_drive_is_fake (drive))
- brasero_dest_selection_check_drive_settings (self, drive);
- else
+ if (brasero_burn_session_is_dest_file (priv->session))
brasero_dest_selection_check_image_settings (self);
+ else
+ brasero_dest_selection_check_drive_settings (self);
}
static void
@@ -1251,18 +1224,18 @@
priv = BRASERO_DEST_SELECTION_PRIVATE (self);
- burner = brasero_burn_session_get_burner (priv->session);
- if (priv->drive_prop) {
- /* cancel the drive properties dialog as it's not the same drive */
- gtk_dialog_response (GTK_DIALOG (priv->drive_prop),
- GTK_RESPONSE_CANCEL);
- }
-
/* make sure the current displayed drive reflects that */
+ burner = brasero_burn_session_get_burner (priv->session);
drive = brasero_drive_selection_get_drive (BRASERO_DRIVE_SELECTION (self));
- if (drive && burner && burner != drive)
+ if (burner != drive) {
brasero_drive_selection_set_drive (BRASERO_DRIVE_SELECTION (self), drive);
+ if (priv->drive_prop) {
+ /* cancel the drive properties dialog as it's not the same drive */
+ gtk_dialog_response (GTK_DIALOG (priv->drive_prop), GTK_RESPONSE_CANCEL);
+ }
+ }
+
if (drive)
g_object_unref (drive);
@@ -1276,10 +1249,9 @@
brasero_dest_selection_set_drive_properties (self);
- gtk_widget_show (priv->copies_box);
-
numcopies = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->copies_spin));
brasero_burn_session_set_num_copies (priv->session, numcopies);
+ gtk_widget_show (priv->copies_box);
}
else {
gtk_widget_hide (priv->copies_box);
Modified: trunk/src/brasero-disc-copy-dialog.c
==============================================================================
--- trunk/src/brasero-disc-copy-dialog.c (original)
+++ trunk/src/brasero-disc-copy-dialog.c Sat Jun 28 15:05:56 2008
@@ -175,15 +175,24 @@
src_drive = brasero_drive_selection_get_drive (BRASERO_DRIVE_SELECTION (priv->source));
if (brasero_burn_session_same_src_dest_drive (priv->session)) {
- BraseroMedia media;
+ BraseroTrackType source;
- media = brasero_medium_get_status (brasero_burn_session_get_src_medium (priv->session));
+ memset (&source, 0, sizeof (BraseroTrackType));
+ brasero_burn_session_get_input_type (priv->session, &source);
- if (media == BRASERO_MEDIUM_NONE
- || (media & (BRASERO_MEDIUM_HAS_AUDIO|BRASERO_MEDIUM_HAS_DATA)) == 0)
+ if (source.subtype.media == BRASERO_MEDIUM_NONE
+ || (source.subtype.media & (BRASERO_MEDIUM_HAS_AUDIO|BRASERO_MEDIUM_HAS_DATA)) == 0)
valid = FALSE;
- else
- valid = TRUE;
+ else {
+ BraseroBurnResult result;
+ BraseroBurnCaps *caps;
+
+ caps = brasero_burn_caps_get_default ();
+ result = brasero_burn_caps_is_session_supported (caps, priv->session);
+ g_object_unref (caps);
+
+ valid = (result == BRASERO_BURN_OK);
+ }
}
else {
BraseroBurnCaps *caps;
Modified: trunk/src/burn-caps.c
==============================================================================
--- trunk/src/burn-caps.c (original)
+++ trunk/src/burn-caps.c Sat Jun 28 15:05:56 2008
@@ -1878,6 +1878,83 @@
return BRASERO_BURN_OK;
}
+static BraseroBurnResult
+brasero_burn_caps_is_session_supported_same_src_dest (BraseroBurnCaps *self,
+ BraseroBurnSession *session)
+{
+ GSList *iter;
+ BraseroTrackType input;
+ BraseroTrackType output;
+ BraseroImageFormat format;
+ BraseroBurnFlag session_flags;
+
+ BRASERO_BURN_LOG ("Checking disc copy support with same source and destination");
+
+ /* To determine if a CD/DVD can be copied using the same source/dest,
+ * we first determine if can be imaged and then if this image can be
+ * burnt to whatever medium type. */
+ memset (&input, 0, sizeof (BraseroTrackType));
+ brasero_burn_session_get_input_type (session, &input);
+ BRASERO_BURN_LOG_TYPE (&input, "input");
+
+ /* NOTE: BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE is a problem here since it
+ * is only used if needed. Likewise DAO can be a problem. So just in
+ * case remove them. They are not really useful in this context. What we
+ * want here is to know whether a medium can be used given the input;
+ * only 1 flag is important here (MERGE) and can have consequences. */
+ session_flags = brasero_burn_session_get_flags (session);
+ session_flags &= ~(BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE|BRASERO_BURN_FLAG_DAO);
+
+ BRASERO_BURN_LOG_FLAGS (session_flags, "flags");
+
+ /* Find one available output format */
+ format = BRASERO_IMAGE_FORMAT_CDRDAO;
+ output.type = BRASERO_TRACK_TYPE_IMAGE;
+
+ for (; format > BRASERO_IMAGE_FORMAT_NONE; format >>= 1) {
+ BraseroBurnResult result;
+
+ output.subtype.img_format = format;
+
+ BRASERO_BURN_LOG_TYPE (&output, "Testing temporary image format");
+ result = brasero_caps_try_output_with_blanking (self,
+ session,
+ &output,
+ &input,
+ BRASERO_PLUGIN_IO_ACCEPT_FILE);
+ if (result != BRASERO_BURN_OK)
+ continue;
+
+ /* This format can be used to create an image. Check if can be
+ * burnt now. Just find at least one medium. */
+ for (iter = self->priv->caps_list; iter; iter = iter->next) {
+ BraseroCaps *caps;
+ gboolean result;
+
+ caps = iter->data;
+
+ if (caps->type.type != BRASERO_TRACK_TYPE_DISC)
+ continue;
+
+ /* Put BRASERO_MEDIUM_NONE so we can always succeed */
+ result = brasero_caps_find_link (caps,
+ session_flags,
+ BRASERO_MEDIUM_NONE,
+ &input,
+ BRASERO_PLUGIN_IO_ACCEPT_FILE);
+
+ BRASERO_BURN_LOG_DISC_TYPE (caps->type.subtype.media,
+ "Tested medium (%s)",
+ result ? "working":"not working");
+
+ if (result)
+ return BRASERO_BURN_OK;
+ }
+ }
+
+ return BRASERO_BURN_NOT_SUPPORTED;
+}
+
BraseroBurnResult
brasero_burn_caps_is_session_supported (BraseroBurnCaps *self,
BraseroBurnSession *session)
@@ -1887,6 +1964,10 @@
BraseroTrackType output;
BraseroPluginIOFlag io_flags;
+ /* Special case */
+ if (brasero_burn_session_same_src_dest_drive (session))
+ return brasero_burn_caps_is_session_supported_same_src_dest (self, session);
+
/* Here flags don't matter as we don't record anything.
* Even the IOFlags since that can be checked later with
* brasero_burn_caps_get_flags. */
@@ -1952,8 +2033,7 @@
* want here is to know which media can be used given the input; only 1
* flag is important here (MERGE) and can have consequences. */
session_flags = brasero_burn_session_get_flags (session);
- session_flags &= ~(BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE|
- BRASERO_BURN_FLAG_DAO);
+ session_flags &= ~(BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE|BRASERO_BURN_FLAG_DAO);
BRASERO_BURN_LOG_FLAGS (session_flags, "and flags");
Modified: trunk/src/burn-medium.c
==============================================================================
--- trunk/src/burn-medium.c (original)
+++ trunk/src/burn-medium.c Sat Jun 28 15:05:56 2008
@@ -141,6 +141,9 @@
{
BraseroMediumPrivate *priv;
+ if (!medium)
+ return NULL;
+
priv = BRASERO_MEDIUM_PRIVATE (medium);
return priv->icon;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]