[brasero] Fix glitches with video options



commit 310f238a5627b5d442927b0747b0de97690736cd
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Sun Aug 16 16:51:23 2009 +0200

    Fix glitches with video options
    some options were not properly updated (the 4:3 option with vcd in particular)

 libbrasero-burn/brasero-image-properties.c |   75 ++++++++++++---
 libbrasero-burn/brasero-video-options.c    |  143 ++++++++++++++++++++--------
 2 files changed, 165 insertions(+), 53 deletions(-)
---
diff --git a/libbrasero-burn/brasero-image-properties.c b/libbrasero-burn/brasero-image-properties.c
index f88757c..42e0809 100644
--- a/libbrasero-burn/brasero-image-properties.c
+++ b/libbrasero-burn/brasero-image-properties.c
@@ -46,6 +46,8 @@
 #include "brasero-image-properties.h"
 #include "brasero-image-type-chooser.h"
 
+#include "brasero-session-helper.h"
+
 typedef struct _BraseroImagePropertiesPrivate BraseroImagePropertiesPrivate;
 struct _BraseroImagePropertiesPrivate
 {
@@ -77,15 +79,8 @@ brasero_image_properties_get_format (BraseroImageProperties *self)
 
 	priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (self);
 
-	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));
-	}
+	if (priv->format == NULL)
+		return BRASERO_IMAGE_FORMAT_NONE;
 
 	brasero_image_type_chooser_get_format (BRASERO_IMAGE_TYPE_CHOOSER (priv->format),
 					       &format);
@@ -141,8 +136,14 @@ brasero_image_properties_format_changed_cb (BraseroImageTypeChooser *chooser,
 		return;
 
 	format = brasero_image_properties_get_format (self);
-	if (format == BRASERO_IMAGE_FORMAT_ANY || format == BRASERO_IMAGE_FORMAT_NONE)
-		format = brasero_burn_session_get_default_output_format (BRASERO_BURN_SESSION (priv->session));
+
+	/* Set the format now */
+	brasero_burn_session_set_image_output_format (BRASERO_BURN_SESSION (priv->session), format);
+
+	/* make sure the format is valid and possibly update path */
+	if (format == BRASERO_IMAGE_FORMAT_ANY
+	||  format == BRASERO_IMAGE_FORMAT_NONE)
+		format = brasero_burn_session_get_output_format (BRASERO_BURN_SESSION (priv->session));
 
 	if (!priv->edited) {
 		/* not changed: get a new default path */
@@ -162,6 +163,49 @@ brasero_image_properties_format_changed_cb (BraseroImageTypeChooser *chooser,
 	}
 
 	brasero_image_properties_set_path (self, image_path);
+
+	/* This is specific to video projects */
+	if (priv->is_video) {
+		if (format == BRASERO_IMAGE_FORMAT_CUE) {
+			gboolean res = TRUE;
+			GValue *value;
+
+			value = g_new0 (GValue, 1);
+			g_value_init (value, G_TYPE_INT);
+
+			/* There should always be a priv->format in this case but who knows... */
+			if (priv->format)
+				res = brasero_image_type_chooser_get_VCD_type (BRASERO_IMAGE_TYPE_CHOOSER (priv->format));
+
+			if (res)
+				g_value_set_int (value, BRASERO_SVCD);
+			else
+				g_value_set_int (value, BRASERO_VCD_V2);
+
+			brasero_burn_session_tag_add (BRASERO_BURN_SESSION (priv->session),
+						      BRASERO_VCD_TYPE,
+						      value);
+
+			/* This is for a (S)VCD set to MP2 */
+			value = g_new0 (GValue, 1);
+			g_value_init (value, G_TYPE_INT);
+			g_value_set_int (value, BRASERO_AUDIO_FORMAT_MP2);
+			brasero_burn_session_tag_add (BRASERO_BURN_SESSION (priv->session),
+						      BRASERO_DVD_STREAM_FORMAT,
+						      value);
+		}
+		else {
+			GValue *value;
+
+			/* This is for a DVD set to AC3 */
+			value = g_new0 (GValue, 1);
+			g_value_init (value, G_TYPE_INT);
+			g_value_set_int (value, BRASERO_AUDIO_FORMAT_AC3);
+			brasero_burn_session_tag_add (BRASERO_BURN_SESSION (priv->session),
+						      BRASERO_DVD_STREAM_FORMAT,
+						      value);
+		}
+	}
 }
 
 static void
@@ -253,10 +297,17 @@ brasero_image_properties_set_output_path (BraseroImageProperties *self,
 					  const gchar *path)
 {
 	BraseroImagePropertiesPrivate *priv;
+	BraseroImageFormat real_format;
 
 	priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (self);
 
-	switch (format) {
+	if (format == BRASERO_IMAGE_FORMAT_ANY
+	||  format == BRASERO_IMAGE_FORMAT_NONE)
+		real_format = brasero_burn_session_get_output_format (BRASERO_BURN_SESSION (priv->session));
+	else
+		real_format = format;
+
+	switch (real_format) {
 	case BRASERO_IMAGE_FORMAT_BIN:
 		brasero_burn_session_set_image_output_full (BRASERO_BURN_SESSION (priv->session),
 							    format,
diff --git a/libbrasero-burn/brasero-video-options.c b/libbrasero-burn/brasero-video-options.c
index a2a7d30..2ba2a46 100644
--- a/libbrasero-burn/brasero-video-options.c
+++ b/libbrasero-burn/brasero-video-options.c
@@ -54,6 +54,9 @@ struct _BraseroVideoOptionsPrivate
 	GtkWidget *vcd_button;
 	GtkWidget *svcd_button;
 
+	GtkWidget *button_native;
+	GtkWidget *button_ntsc;
+	GtkWidget *button_pal;
 	GtkWidget *button_4_3;
 	GtkWidget *button_16_9;
 };
@@ -68,41 +71,71 @@ enum {
 G_DEFINE_TYPE (BraseroVideoOptions, brasero_video_options, GTK_TYPE_ALIGNMENT);
 
 static void
-brasero_video_options_audio_AC3 (BraseroVideoOptions *options)
+brasero_video_options_update_from_tag (BraseroVideoOptions *options,
+                                       const gchar *tag)
 {
 	GValue *value = NULL;
 	BraseroVideoOptionsPrivate *priv;
 
-	priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
-
-	if (!priv->session)
+	if (!tag)
 		return;
 
-	value = g_new0 (GValue, 1);
-	g_value_init (value, G_TYPE_INT);
-	g_value_set_int (value, BRASERO_AUDIO_FORMAT_AC3);
-	brasero_burn_session_tag_add (priv->session,
-				      BRASERO_DVD_STREAM_FORMAT,
-				      value);
-}
-
-static void
-brasero_video_options_audio_MP2 (BraseroVideoOptions *options)
-{
-	GValue *value = NULL;
-	BraseroVideoOptionsPrivate *priv;
-
 	priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
+	
+	if (!strcmp (tag, BRASERO_VCD_TYPE)) {
+		brasero_burn_session_tag_lookup (priv->session,
+						 tag,
+						 &value);
+
+		if (value && g_value_get_int (value) == BRASERO_SVCD) {
+			if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->svcd_button)))
+				gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->svcd_button), TRUE);
+
+				gtk_widget_set_sensitive (priv->button_4_3, TRUE);
+				gtk_widget_set_sensitive (priv->button_16_9, TRUE);
+		}
+		else {
+			if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->vcd_button)))
+				gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->vcd_button), TRUE);
 
-	if (!priv->session)
-		return;
+			if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->button_4_3)))
+				gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button_4_3), TRUE);
 
-	value = g_new0 (GValue, 1);
-	g_value_init (value, G_TYPE_INT);
-	g_value_set_int (value, BRASERO_AUDIO_FORMAT_MP2);
-	brasero_burn_session_tag_add (priv->session,
-				      BRASERO_DVD_STREAM_FORMAT,
-				      value);
+			gtk_widget_set_sensitive (priv->button_4_3, FALSE);
+			gtk_widget_set_sensitive (priv->button_16_9, FALSE);
+		}
+	}
+	else if (!strcmp (tag, BRASERO_VIDEO_OUTPUT_FRAMERATE)) {
+		brasero_burn_session_tag_lookup (priv->session,
+						 tag,
+						 &value);
+		if (value) {
+			if (g_value_get_int (value) == BRASERO_VIDEO_FRAMERATE_NTSC) {
+				if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->button_ntsc)))
+					gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button_ntsc), TRUE);
+			}
+			else {
+				if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->button_pal)))
+					gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button_pal), TRUE);
+			}
+		}
+		else if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->button_native)))
+			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button_native), TRUE);
+	}
+	else if (!strcmp (tag, BRASERO_VIDEO_OUTPUT_ASPECT)) {
+		brasero_burn_session_tag_lookup (priv->session,
+						 tag,
+						 &value);
+
+		if (value && g_value_get_int (value) == BRASERO_VIDEO_ASPECT_16_9) {
+			if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->button_16_9)))
+				gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button_16_9), TRUE);
+		}
+		else {
+			if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->button_4_3)))
+				gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button_4_3), TRUE);
+		}
+	}
 }
 
 static void
@@ -119,7 +152,6 @@ brasero_video_options_update (BraseroVideoOptions *options)
 
 	media = brasero_burn_session_get_dest_media (priv->session);
 	if (media & BRASERO_MEDIUM_DVD) {
-		brasero_video_options_audio_AC3 (options);
 		gtk_widget_hide (priv->vcd_label);
 		gtk_widget_hide (priv->vcd_button);
 		gtk_widget_hide (priv->svcd_button);
@@ -128,27 +160,29 @@ brasero_video_options_update (BraseroVideoOptions *options)
 		gtk_widget_set_sensitive (priv->button_16_9, TRUE);
 	}
 	else if (media & BRASERO_MEDIUM_CD) {
-		brasero_video_options_audio_MP2 (options);
 		gtk_widget_show (priv->vcd_label);
 		gtk_widget_show (priv->vcd_button);
 		gtk_widget_show (priv->svcd_button);
 
-		if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->vcd_button))) {
-			gtk_widget_set_sensitive (priv->button_4_3, FALSE);
-			gtk_widget_set_sensitive (priv->button_16_9, FALSE);
-		}
-		else {
-			gtk_widget_set_sensitive (priv->button_4_3, TRUE);
-			gtk_widget_set_sensitive (priv->button_16_9, TRUE);
-		}
+		brasero_video_options_update_from_tag (options, BRASERO_VCD_TYPE);
 	}
 	else if (media & BRASERO_MEDIUM_FILE) {
+		BraseroImageFormat format;
+
 		/* Hide any options about (S)VCD type
 		 * as this is handled in BraseroImageTypeChooser 
 		 * object */
 		gtk_widget_hide (priv->vcd_label);
 		gtk_widget_hide (priv->vcd_button);
 		gtk_widget_hide (priv->svcd_button);
+
+		format = brasero_burn_session_get_output_format (priv->session);
+		if (format == BRASERO_IMAGE_FORMAT_BIN) {
+			gtk_widget_set_sensitive (priv->button_4_3, TRUE);
+			gtk_widget_set_sensitive (priv->button_16_9, TRUE);
+		}
+		else if (format == BRASERO_IMAGE_FORMAT_CUE)
+			brasero_video_options_update_from_tag (options, BRASERO_VCD_TYPE);
 	}
 }
 
@@ -161,6 +195,14 @@ brasero_video_options_output_changed_cb (BraseroBurnSession *session,
 }
 
 static void
+brasero_video_options_tag_changed_cb (BraseroBurnSession *session,
+                                      const gchar *tag,
+                                      BraseroVideoOptions *options)
+{
+	brasero_video_options_update_from_tag (options, tag);
+}
+
+static void
 brasero_video_options_set_tag (BraseroVideoOptions *options,
 			       const gchar *tag,
 			       gint contents)
@@ -194,6 +236,9 @@ brasero_video_options_SVCD (GtkToggleButton *button,
 				       BRASERO_VCD_TYPE,
 				       BRASERO_SVCD);
 
+	/* NOTE: this is only possible when that's
+	 * not an image */
+
 	priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
 
 	gtk_widget_set_sensitive (priv->button_4_3, TRUE);
@@ -213,6 +258,9 @@ brasero_video_options_VCD (GtkToggleButton *button,
 				       BRASERO_VCD_TYPE,
 				       BRASERO_VCD_V2);
 
+	/* NOTE: this is only possible when that's
+	 * not an image */
+
 	priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
 	gtk_widget_set_sensitive (priv->button_4_3, FALSE);
 	gtk_widget_set_sensitive (priv->button_16_9, FALSE);
@@ -292,7 +340,9 @@ brasero_video_options_set_session (BraseroVideoOptions *options,
 		g_signal_handlers_disconnect_by_func (priv->session,
 		                                      brasero_video_options_output_changed_cb,
 		                                      options);
-
+		g_signal_handlers_disconnect_by_func (priv->session,
+		                                      brasero_video_options_tag_changed_cb,
+		                                      options);
 		g_object_unref (priv->session);
 		priv->session = NULL;
 	}
@@ -300,10 +350,17 @@ brasero_video_options_set_session (BraseroVideoOptions *options,
 	if (session) {
 		priv->session = g_object_ref (session);
 		brasero_video_options_update (options);
+		brasero_video_options_update_from_tag (options, BRASERO_VIDEO_OUTPUT_FRAMERATE);
+		brasero_video_options_update_from_tag (options, BRASERO_VIDEO_OUTPUT_ASPECT);
+
 		g_signal_connect (priv->session,
 		                  "output-changed",
 		                  G_CALLBACK (brasero_video_options_output_changed_cb),
 		                  options);
+		g_signal_connect (priv->session,
+		                  "tag-changed",
+		                  G_CALLBACK (brasero_video_options_tag_changed_cb),
+		                  options);
 	}
 }
 
@@ -387,8 +444,8 @@ brasero_video_options_init (BraseroVideoOptions *object)
 			  GTK_FILL,
 			  0, 0);
 
-	button1 = gtk_radio_button_new_with_mnemonic (NULL,
-						      _("_NTSC"));
+	button1 = gtk_radio_button_new_with_mnemonic (NULL, _("_NTSC"));
+	priv->button_ntsc = button1;
 	gtk_widget_set_tooltip_text (button1, _("Format used mostly on the North American Continent"));
 	g_signal_connect (button1,
 			  "toggled",
@@ -402,8 +459,8 @@ brasero_video_options_init (BraseroVideoOptions *object)
 			  GTK_FILL,
 			  0, 0);
 
-	button2 = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (button1),
-								  _("_PAL/SECAM"));
+	button2 = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (button1), _("_PAL/SECAM"));
+	priv->button_pal = button2;
 	gtk_widget_set_tooltip_text (button2, _("Format used mostly in Europe"));
 	g_signal_connect (button2,
 			  "toggled",
@@ -419,6 +476,7 @@ brasero_video_options_init (BraseroVideoOptions *object)
 
 	button3 = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (button1),
 								  _("Native _format"));
+	priv->button_native = button3;
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button3), TRUE);
 	g_signal_connect (button3,
 			  "toggled",
@@ -545,6 +603,9 @@ brasero_video_options_finalize (GObject *object)
 		g_signal_handlers_disconnect_by_func (priv->session,
 		                                      brasero_video_options_output_changed_cb,
 		                                      object);
+		g_signal_handlers_disconnect_by_func (priv->session,
+		                                      brasero_video_options_tag_changed_cb,
+		                                      object);
 		g_object_unref (priv->session);
 		priv->session = NULL;
 	}



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