[brasero] Create private convenience functions brasero_burn_session_tag_add_int () and brasero_burn_session_ta
- From: Philippe Rouquier <philippr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [brasero] Create private convenience functions brasero_burn_session_tag_add_int () and brasero_burn_session_ta
- Date: Mon, 24 Aug 2009 13:45:46 +0000 (UTC)
commit 73fc2f8f86b33dd560fcf9ea21a75c3d77419462
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date: Wed Aug 19 14:13:26 2009 +0200
Create private convenience functions brasero_burn_session_tag_add_int () and brasero_burn_session_tag_lookup () and use them whenever it is possible
libbrasero-burn/brasero-dest-selection.c | 37 ++++--------
libbrasero-burn/brasero-image-properties.c | 80 ++++++++----------------
libbrasero-burn/brasero-session-helper.h | 7 ++
libbrasero-burn/brasero-session.c | 61 ++++++++++++++++++
libbrasero-burn/brasero-video-options.c | 93 +++++++++++++---------------
src/brasero-project.c | 15 +---
6 files changed, 152 insertions(+), 141 deletions(-)
---
diff --git a/libbrasero-burn/brasero-dest-selection.c b/libbrasero-burn/brasero-dest-selection.c
index 389d376..38ccb1c 100644
--- a/libbrasero-burn/brasero-dest-selection.c
+++ b/libbrasero-burn/brasero-dest-selection.c
@@ -122,27 +122,6 @@ brasero_dest_selection_valid_session (BraseroSessionCfg *session,
}
static void
-brasero_dest_selection_set_tag (BraseroDestSelection *self,
- const gchar *tag,
- gint contents)
-{
- GValue *value;
- BraseroDestSelectionPrivate *priv;
-
- priv = BRASERO_DEST_SELECTION_PRIVATE (self);
-
- if (!priv->session)
- return;
-
- value = g_new0 (GValue, 1);
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, contents);
- brasero_burn_session_tag_add (priv->session,
- tag,
- value);
-}
-
-static void
brasero_dest_selection_output_changed (BraseroSessionCfg *session,
BraseroMedium *former,
BraseroDestSelection *self)
@@ -174,17 +153,25 @@ brasero_dest_selection_output_changed (BraseroSessionCfg *session,
media = brasero_medium_get_status (medium);
if (media & BRASERO_MEDIUM_DVD)
- brasero_dest_selection_set_tag (self, BRASERO_DVD_STREAM_FORMAT, BRASERO_AUDIO_FORMAT_AC3);
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (priv->session),
+ BRASERO_DVD_STREAM_FORMAT,
+ BRASERO_AUDIO_FORMAT_AC3);
else if (media & BRASERO_MEDIUM_CD)
- brasero_dest_selection_set_tag (self, BRASERO_DVD_STREAM_FORMAT, BRASERO_AUDIO_FORMAT_MP2);
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (priv->session),
+ BRASERO_DVD_STREAM_FORMAT,
+ BRASERO_AUDIO_FORMAT_MP2);
else {
BraseroImageFormat format;
format = brasero_burn_session_get_output_format (priv->session);
if (format == BRASERO_IMAGE_FORMAT_CUE)
- brasero_dest_selection_set_tag (self, BRASERO_DVD_STREAM_FORMAT, BRASERO_AUDIO_FORMAT_MP2);
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (priv->session),
+ BRASERO_DVD_STREAM_FORMAT,
+ BRASERO_AUDIO_FORMAT_MP2);
else
- brasero_dest_selection_set_tag (self, BRASERO_DVD_STREAM_FORMAT, BRASERO_AUDIO_FORMAT_AC3);
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (priv->session),
+ BRASERO_DVD_STREAM_FORMAT,
+ BRASERO_AUDIO_FORMAT_AC3);
}
}
diff --git a/libbrasero-burn/brasero-image-properties.c b/libbrasero-burn/brasero-image-properties.c
index 42e0809..27ce749 100644
--- a/libbrasero-burn/brasero-image-properties.c
+++ b/libbrasero-burn/brasero-image-properties.c
@@ -168,43 +168,29 @@ brasero_image_properties_format_changed_cb (BraseroImageTypeChooser *chooser,
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);
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (priv->session),
+ BRASERO_VCD_TYPE,
+ 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);
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (priv->session),
+ BRASERO_VCD_TYPE,
+ BRASERO_VCD_V2);
/* 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);
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (priv->session),
+ BRASERO_DVD_STREAM_FORMAT,
+ BRASERO_AUDIO_FORMAT_MP2);
}
+ else
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (priv->session),
+ BRASERO_DVD_STREAM_FORMAT,
+ BRASERO_AUDIO_FORMAT_AC3);
}
}
@@ -356,43 +342,29 @@ brasero_image_properties_response (GtkFileChooser *chooser,
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);
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (priv->session),
+ BRASERO_VCD_TYPE,
+ 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);
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (priv->session),
+ BRASERO_VCD_TYPE,
+ BRASERO_VCD_V2);
/* This is 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 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);
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (priv->session),
+ BRASERO_DVD_STREAM_FORMAT,
+ BRASERO_AUDIO_FORMAT_MP2);
}
+ else
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (priv->session),
+ BRASERO_DVD_STREAM_FORMAT,
+ BRASERO_AUDIO_FORMAT_AC3);
}
}
diff --git a/libbrasero-burn/brasero-session-helper.h b/libbrasero-burn/brasero-session-helper.h
index 61d5ddc..8c3d0fb 100644
--- a/libbrasero-burn/brasero-session-helper.h
+++ b/libbrasero-burn/brasero-session-helper.h
@@ -47,6 +47,13 @@ G_BEGIN_DECLS
BraseroBurnResult
brasero_burn_session_set_image_output_format (BraseroBurnSession *self,
BraseroImageFormat format);
+BraseroBurnResult
+brasero_burn_session_tag_add_int (BraseroBurnSession *self,
+ const gchar *tag,
+ gint value);
+gint
+brasero_burn_session_tag_lookup_int (BraseroBurnSession *self,
+ const gchar *tag);
/**
* Some convenience functions used internally
diff --git a/libbrasero-burn/brasero-session.c b/libbrasero-burn/brasero-session.c
index ff18339..7a83e4e 100644
--- a/libbrasero-burn/brasero-session.c
+++ b/libbrasero-burn/brasero-session.c
@@ -1560,6 +1560,7 @@ brasero_burn_session_tag_remove (BraseroBurnSession *self,
BraseroBurnSessionPrivate *priv;
g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
+ g_return_val_if_fail (tag != NULL, BRASERO_BURN_ERR);
priv = BRASERO_BURN_SESSION_PRIVATE (self);
if (!priv->tags)
@@ -1583,6 +1584,7 @@ brasero_burn_session_tag_remove (BraseroBurnSession *self,
* Associates a new @tag with @session. This can be used
* to pass arbitrary information for plugins, like parameters
* for video discs, ...
+ * NOTE: the #BraseroBurnSession object takes ownership of @value.
* See brasero-tags.h for a list of knowns tags.
*
* Return value: a #BraseroBurnResult.
@@ -1598,6 +1600,7 @@ brasero_burn_session_tag_add (BraseroBurnSession *self,
BraseroBurnSessionPrivate *priv;
g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
+ g_return_val_if_fail (tag != NULL, BRASERO_BURN_ERR);
priv = BRASERO_BURN_SESSION_PRIVATE (self);
if (!priv->tags)
@@ -1615,6 +1618,39 @@ brasero_burn_session_tag_add (BraseroBurnSession *self,
}
/**
+ * brasero_burn_session_tag_add_int:
+ * @session: a #BraseroBurnSession
+ * @tag: a #gchar *
+ * @value: a #gint
+ *
+ * Associates a new @tag with @session. This can be used
+ * to pass arbitrary information for plugins, like parameters
+ * for video discs, ...
+ * See brasero-tags.h for a list of knowns tags.
+ *
+ * Return value: a #BraseroBurnResult.
+ * BRASERO_BURN_OK if it was successful,
+ * BRASERO_BURN_ERR otherwise.
+ **/
+
+BraseroBurnResult
+brasero_burn_session_tag_add_int (BraseroBurnSession *self,
+ const gchar *tag,
+ gint value)
+{
+ GValue *gvalue;
+
+ g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
+ g_return_val_if_fail (tag != NULL, BRASERO_BURN_ERR);
+
+ gvalue = g_new0 (GValue, 1);
+ g_value_init (gvalue, G_TYPE_INT);
+ g_value_set_int (gvalue, value);
+
+ return brasero_burn_session_tag_add (self, tag, gvalue);
+}
+
+/**
* brasero_burn_session_tag_lookup:
* @session: a #BraseroBurnSession
* @tag: a #gchar *
@@ -1638,6 +1674,7 @@ brasero_burn_session_tag_lookup (BraseroBurnSession *self,
gpointer data;
g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
+ g_return_val_if_fail (tag != NULL, BRASERO_BURN_ERR);
priv = BRASERO_BURN_SESSION_PRIVATE (self);
if (!value)
@@ -1655,6 +1692,30 @@ brasero_burn_session_tag_lookup (BraseroBurnSession *self,
}
/**
+ * brasero_burn_session_tag_lookup_int:
+ * @session: a #BraseroBurnSession
+ * @tag: a #gchar
+ *
+ * Retrieves an int value associated with @session through
+ * brasero_session_tag_add () and returns it.
+ *
+ * Return value: a #gint.
+ **/
+
+gint
+brasero_burn_session_tag_lookup_int (BraseroBurnSession *self,
+ const gchar *tag)
+{
+ GValue *value = NULL;
+
+ brasero_burn_session_tag_lookup (self, tag, &value);
+ if (!value || !G_VALUE_HOLDS_INT (value))
+ return 0;
+
+ return g_value_get_int (value);
+}
+
+/**
* Used to save and restore settings/sources
*/
diff --git a/libbrasero-burn/brasero-video-options.c b/libbrasero-burn/brasero-video-options.c
index 2ba2a46..4b9502b 100644
--- a/libbrasero-burn/brasero-video-options.c
+++ b/libbrasero-burn/brasero-video-options.c
@@ -203,27 +203,6 @@ brasero_video_options_tag_changed_cb (BraseroBurnSession *session,
}
static void
-brasero_video_options_set_tag (BraseroVideoOptions *options,
- const gchar *tag,
- gint contents)
-{
- GValue *value;
- BraseroVideoOptionsPrivate *priv;
-
- priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
-
- if (!priv->session)
- return;
-
- value = g_new0 (GValue, 1);
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, contents);
- brasero_burn_session_tag_add (priv->session,
- tag,
- value);
-}
-
-static void
brasero_video_options_SVCD (GtkToggleButton *button,
BraseroVideoOptions *options)
{
@@ -232,15 +211,14 @@ brasero_video_options_SVCD (GtkToggleButton *button,
if (!gtk_toggle_button_get_active (button))
return;
- brasero_video_options_set_tag (options,
- BRASERO_VCD_TYPE,
- BRASERO_SVCD);
+ priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
+ brasero_burn_session_tag_add_int (priv->session,
+ 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);
gtk_widget_set_sensitive (priv->button_16_9, TRUE);
}
@@ -254,14 +232,13 @@ brasero_video_options_VCD (GtkToggleButton *button,
if (!gtk_toggle_button_get_active (button))
return;
- brasero_video_options_set_tag (options,
- BRASERO_VCD_TYPE,
- BRASERO_VCD_V2);
+ priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
+ brasero_burn_session_tag_add_int (priv->session,
+ 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);
@@ -272,24 +249,30 @@ static void
brasero_video_options_NTSC (GtkToggleButton *button,
BraseroVideoOptions *options)
{
+ BraseroVideoOptionsPrivate *priv;
+
if (!gtk_toggle_button_get_active (button))
return;
- brasero_video_options_set_tag (options,
- BRASERO_VIDEO_OUTPUT_FRAMERATE,
- BRASERO_VIDEO_FRAMERATE_NTSC);
+ priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
+ brasero_burn_session_tag_add_int (priv->session,
+ BRASERO_VIDEO_OUTPUT_FRAMERATE,
+ BRASERO_VIDEO_FRAMERATE_NTSC);
}
static void
brasero_video_options_PAL_SECAM (GtkToggleButton *button,
BraseroVideoOptions *options)
{
+ BraseroVideoOptionsPrivate *priv;
+
if (!gtk_toggle_button_get_active (button))
return;
- brasero_video_options_set_tag (options,
- BRASERO_VIDEO_OUTPUT_FRAMERATE,
- BRASERO_VIDEO_FRAMERATE_PAL_SECAM);
+ priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
+ brasero_burn_session_tag_add_int (priv->session,
+ BRASERO_VIDEO_OUTPUT_FRAMERATE,
+ BRASERO_VIDEO_FRAMERATE_PAL_SECAM);
}
static void
@@ -298,10 +281,10 @@ brasero_video_options_native_framerate (GtkToggleButton *button,
{
BraseroVideoOptionsPrivate *priv;
- priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
if (!gtk_toggle_button_get_active (button))
return;
+ priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
brasero_burn_session_tag_remove (priv->session, BRASERO_VIDEO_OUTPUT_FRAMERATE);
}
@@ -309,24 +292,30 @@ static void
brasero_video_options_16_9 (GtkToggleButton *button,
BraseroVideoOptions *options)
{
+ BraseroVideoOptionsPrivate *priv;
+
if (!gtk_toggle_button_get_active (button))
return;
- brasero_video_options_set_tag (options,
- BRASERO_VIDEO_OUTPUT_ASPECT,
- BRASERO_VIDEO_ASPECT_16_9);
+ priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
+ brasero_burn_session_tag_add_int (priv->session,
+ BRASERO_VIDEO_OUTPUT_ASPECT,
+ BRASERO_VIDEO_ASPECT_16_9);
}
static void
brasero_video_options_4_3 (GtkToggleButton *button,
BraseroVideoOptions *options)
{
+ BraseroVideoOptionsPrivate *priv;
+
if (!gtk_toggle_button_get_active (button))
return;
- brasero_video_options_set_tag (options,
- BRASERO_VIDEO_OUTPUT_ASPECT,
- BRASERO_VIDEO_ASPECT_4_3);
+ priv = BRASERO_VIDEO_OPTIONS_PRIVATE (options);
+ brasero_burn_session_tag_add_int (priv->session,
+ BRASERO_VIDEO_OUTPUT_ASPECT,
+ BRASERO_VIDEO_ASPECT_4_3);
}
void
@@ -584,13 +573,15 @@ brasero_video_options_init (BraseroVideoOptions *object)
gtk_widget_show_all (widget);
gtk_container_add (GTK_CONTAINER (object), widget);
- /* Just to make sure our tags are correct in BraseroBurnSession */
- brasero_video_options_set_tag (object,
- BRASERO_VCD_TYPE,
- BRASERO_SVCD);
- brasero_video_options_set_tag (object,
- BRASERO_VIDEO_OUTPUT_ASPECT,
- BRASERO_VIDEO_ASPECT_4_3);
+ if (priv->session) {
+ /* Just to make sure our tags are correct in BraseroBurnSession */
+ brasero_burn_session_tag_add_int (priv->session,
+ BRASERO_VCD_TYPE,
+ BRASERO_SVCD);
+ brasero_burn_session_tag_add_int (priv->session,
+ BRASERO_VIDEO_OUTPUT_ASPECT,
+ BRASERO_VIDEO_ASPECT_4_3);
+ }
}
static void
diff --git a/src/brasero-project.c b/src/brasero-project.c
index 257fb9a..7530593 100644
--- a/src/brasero-project.c
+++ b/src/brasero-project.c
@@ -1491,17 +1491,10 @@ brasero_project_burn (BraseroProject *project)
brasero_burn_session_get_input_type (BRASERO_BURN_SESSION (project->priv->session), track_type);
if (brasero_track_type_get_has_stream (track_type)
- && BRASERO_STREAM_FORMAT_HAS_VIDEO (brasero_track_type_get_stream_format (track_type))) {
- GValue *value;
-
- /* Special case for video project */
- value = g_new0 (GValue, 1);
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, BRASERO_SVCD);
- brasero_burn_session_tag_add (BRASERO_BURN_SESSION (project->priv->session),
- BRASERO_VCD_TYPE,
- value);
- }
+ && BRASERO_STREAM_FORMAT_HAS_VIDEO (brasero_track_type_get_stream_format (track_type)))
+ brasero_burn_session_tag_add_int (BRASERO_BURN_SESSION (project->priv->session),
+ BRASERO_VCD_TYPE,
+ BRASERO_SVCD);
brasero_track_type_free (track_type);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]