[brasero] New layout for the UI:
- From: Philippe Rouquier <philippr src gnome org>
- To: svn-commits-list gnome org
- Subject: [brasero] New layout for the UI:
- Date: Sun, 21 Jun 2009 17:07:53 -0400 (EDT)
commit 64701840527d4f7c8ae71f4480f24370acae8e68
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date: Sun Jun 21 13:09:02 2009 +0200
New layout for the UI:
the medium selector is still inside the main window and on clicking burn a dialog appears to set the session burning options
More graphical objects now relies on a BraseroBurnSession object
API changes for BraseroBurnSession
libbrasero-burn/brasero-burn-dialog.c | 3 +-
libbrasero-burn/brasero-burn-options.c | 2 +-
libbrasero-burn/brasero-burn.c | 3 +-
libbrasero-burn/brasero-caps-session.c | 33 +
libbrasero-burn/brasero-dest-selection.c | 16 +-
libbrasero-burn/brasero-image-properties.c | 316 ++++--
libbrasero-burn/brasero-image-properties.h | 21 +-
libbrasero-burn/brasero-medium-properties.c | 423 +-------
libbrasero-burn/brasero-medium-properties.h | 4 +-
libbrasero-burn/brasero-session-cfg.c | 200 ++++-
libbrasero-burn/brasero-session-cfg.h | 8 +-
libbrasero-burn/brasero-session.c | 74 +-
libbrasero-burn/brasero-session.h | 17 +-
libbrasero-burn/brasero-track-data-cfg.c | 25 +-
libbrasero-burn/brasero-track-stream-cfg.c | 2 +-
libbrasero-burn/burn-image-format.c | 2 +-
libbrasero-burn/burn-image-format.h | 2 +-
libbrasero-burn/burn-job.c | 3 +-
src/brasero-audio-disc.c | 175 +---
src/brasero-data-disc.c | 631 ++++-------
src/brasero-data-disc.h | 7 -
src/brasero-disc.c | 37 +-
src/brasero-disc.h | 16 -
src/brasero-project-manager.c | 39 +-
src/brasero-project-manager.h | 2 +-
src/brasero-project-name.c | 302 +++++-
src/brasero-project-name.h | 4 +-
src/brasero-project-parse.c | 916 ++++++++++++----
src/brasero-project-parse.h | 76 +-
src/brasero-project.c | 1589 ++++++++++-----------------
src/brasero-project.h | 4 +-
src/brasero-video-disc.c | 110 +--
src/brasero-video-tree-model.c | 27 +-
src/main.c | 19 +-
34 files changed, 2496 insertions(+), 2612 deletions(-)
---
diff --git a/libbrasero-burn/brasero-burn-dialog.c b/libbrasero-burn/brasero-burn-dialog.c
index afb6e74..ef930e1 100644
--- a/libbrasero-burn/brasero-burn-dialog.c
+++ b/libbrasero-burn/brasero-burn-dialog.c
@@ -751,8 +751,7 @@ brasero_burn_dialog_image_error (BraseroBurn *burn,
format = brasero_burn_session_get_output_format (priv->session);
brasero_burn_session_get_output (priv->session,
&image,
- &toc,
- NULL);
+ &toc);
if (toc) {
gchar *name;
diff --git a/libbrasero-burn/brasero-burn-options.c b/libbrasero-burn/brasero-burn-options.c
index e7412f8..6161723 100644
--- a/libbrasero-burn/brasero-burn-options.c
+++ b/libbrasero-burn/brasero-burn-options.c
@@ -542,7 +542,7 @@ brasero_burn_options_build_contents (BraseroBurnOptions *object)
gtk_widget_show (priv->selection);
gtk_container_add (GTK_CONTAINER (alignment), priv->selection);
- priv->properties = brasero_medium_properties_new (BRASERO_BURN_SESSION (priv->session));
+ priv->properties = brasero_medium_properties_new (priv->session);
gtk_size_group_add_widget (priv->size_group, priv->properties);
gtk_widget_show (priv->properties);
gtk_box_pack_start (GTK_BOX (selection),
diff --git a/libbrasero-burn/brasero-burn.c b/libbrasero-burn/brasero-burn.c
index 8340644..301f6d5 100644
--- a/libbrasero-burn/brasero-burn.c
+++ b/libbrasero-burn/brasero-burn.c
@@ -1399,8 +1399,7 @@ start:
* would clutter the disk, wasting space. */
brasero_burn_session_get_output (priv->session,
&image,
- &toc,
- NULL);
+ &toc);
if (image)
g_remove (image);
if (toc)
diff --git a/libbrasero-burn/brasero-caps-session.c b/libbrasero-burn/brasero-caps-session.c
index 273e51f..ca806bd 100644
--- a/libbrasero-burn/brasero-caps-session.c
+++ b/libbrasero-burn/brasero-caps-session.c
@@ -945,6 +945,39 @@ brasero_burn_session_get_required_media_type (BraseroBurnSession *session)
return required_media;
}
+guint
+brasero_burn_session_get_possible_output_formats (BraseroBurnSession *session,
+ BraseroImageFormat *formats)
+{
+ guint num = 0;
+ BraseroImageFormat format;
+ BraseroTrackType *output = NULL;
+
+ g_return_val_if_fail (BRASERO_IS_BURN_SESSION (session), 0);
+
+ /* see how many output format are available */
+ format = BRASERO_IMAGE_FORMAT_CDRDAO;
+ (*formats) = BRASERO_IMAGE_FORMAT_NONE;
+
+ output = brasero_track_type_new ();
+ brasero_track_type_set_has_image (output);
+
+ for (; format > BRASERO_IMAGE_FORMAT_NONE; format >>= 1) {
+ BraseroBurnResult result;
+
+ brasero_track_type_set_image_format (output, format);
+ result = brasero_burn_session_output_supported (session, output);
+ if (result == BRASERO_BURN_OK) {
+ (*formats) |= format;
+ num ++;
+ }
+ }
+
+ brasero_track_type_free (output);
+
+ return num;
+}
+
BraseroImageFormat
brasero_burn_session_get_default_output_format (BraseroBurnSession *session)
{
diff --git a/libbrasero-burn/brasero-dest-selection.c b/libbrasero-burn/brasero-dest-selection.c
index 8188eac..1bbeb08 100644
--- a/libbrasero-burn/brasero-dest-selection.c
+++ b/libbrasero-burn/brasero-dest-selection.c
@@ -442,29 +442,15 @@ brasero_dest_selection_get_output_path (BraseroDestSelection *self)
case BRASERO_IMAGE_FORMAT_BIN:
brasero_burn_session_get_output (priv->session,
&path,
- NULL,
NULL);
break;
case BRASERO_IMAGE_FORMAT_CLONE:
- brasero_burn_session_get_output (priv->session,
- NULL,
- &path,
- NULL);
- break;
-
case BRASERO_IMAGE_FORMAT_CDRDAO:
- brasero_burn_session_get_output (priv->session,
- NULL,
- &path,
- NULL);
- break;
-
case BRASERO_IMAGE_FORMAT_CUE:
brasero_burn_session_get_output (priv->session,
NULL,
- &path,
- NULL);
+ &path);
break;
default:
diff --git a/libbrasero-burn/brasero-image-properties.c b/libbrasero-burn/brasero-image-properties.c
index a314482..000b2df 100644
--- a/libbrasero-burn/brasero-image-properties.c
+++ b/libbrasero-burn/brasero-image-properties.c
@@ -41,30 +41,32 @@
#include <gtk/gtk.h>
#include "burn-basics.h"
+#include "burn-image-format.h"
#include "brasero-image-properties.h"
#include "brasero-image-type-chooser.h"
typedef struct _BraseroImagePropertiesPrivate BraseroImagePropertiesPrivate;
struct _BraseroImagePropertiesPrivate
{
+ BraseroSessionCfg *session;
+
GtkWidget *format;
- gchar *original_path;
+ GtkWidget *format_box;
guint edited:1;
};
#define BRASERO_IMAGE_PROPERTIES_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_IMAGE_PROPERTIES, BraseroImagePropertiesPrivate))
-enum {
- FORMAT_CHANGED_SIGNAL,
- LAST_SIGNAL
-};
-static guint brasero_image_properties_signals [LAST_SIGNAL] = { 0 };
-
static GtkDialogClass* parent_class = NULL;
G_DEFINE_TYPE (BraseroImageProperties, brasero_image_properties, GTK_TYPE_FILE_CHOOSER_DIALOG);
+enum {
+ PROP_0,
+ PROP_SESSION
+};
+
BraseroImageFormat
brasero_image_properties_get_format (BraseroImageProperties *self)
{
@@ -82,33 +84,6 @@ brasero_image_properties_get_format (BraseroImageProperties *self)
return format;
}
-gboolean
-brasero_image_properties_is_path_edited (BraseroImageProperties *self)
-{
- BraseroImagePropertiesPrivate *priv;
- gchar *chooser_path;
-
- priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (self);
-
- if (!priv->original_path)
- return TRUE;
-
- if (priv->edited)
- return TRUE;
-
- chooser_path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (self));
- if (!chooser_path && priv->original_path)
- return TRUE;
-
- if (!priv->original_path && chooser_path)
- return TRUE;
-
- if (!strcmp (chooser_path, priv->original_path))
- return FALSE;
-
- return TRUE;
-}
-
gchar *
brasero_image_properties_get_path (BraseroImageProperties *self)
{
@@ -118,32 +93,13 @@ brasero_image_properties_get_path (BraseroImageProperties *self)
return gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (self));
}
-void
+static void
brasero_image_properties_set_path (BraseroImageProperties *self,
const gchar *path)
{
BraseroImagePropertiesPrivate *priv;
priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (self);
-
- if (priv->original_path) {
- if (!priv->edited) {
- gchar *chooser_path;
-
- /* check if the path was edited since the last time it was set */
- chooser_path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (self));
- priv->edited = (!chooser_path && priv->original_path) ||
- (!priv->original_path && chooser_path) ||
- strcmp (priv->original_path, chooser_path) != 0;
-
- if (chooser_path)
- g_free (chooser_path);
- }
- g_free (priv->original_path);
- }
-
- priv->original_path = g_strdup (path);
-
if (path) {
gchar *name;
@@ -165,16 +121,42 @@ brasero_image_properties_format_changed_cb (BraseroImageTypeChooser *chooser,
BraseroImageProperties *self)
{
BraseroImagePropertiesPrivate *priv;
+ BraseroImageFormat format;
+ gchar *image_path;
priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (self);
- /* propagate the signal */
- g_signal_emit (self,
- brasero_image_properties_signals [FORMAT_CHANGED_SIGNAL],
- 0);
+ /* make sure the extension is still valid */
+ image_path = brasero_image_properties_get_path (self);
+ if (!image_path)
+ 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));
+
+ if (!priv->edited) {
+ /* not changed: get a new default path */
+ g_free (image_path);
+ image_path = brasero_image_format_get_default_path (format);
+ }
+ else if (image_path) {
+ gchar *tmp;
+
+ tmp = image_path;
+ image_path = brasero_image_format_fix_path_extension (format, FALSE, image_path);
+ g_free (tmp);
+ }
+ else {
+ priv->edited = FALSE;
+ image_path = brasero_image_format_get_default_path (format);
+ }
+
+ brasero_image_properties_set_path (self, image_path);
}
-void
+static void
brasero_image_properties_set_formats (BraseroImageProperties *self,
BraseroImageFormat formats,
BraseroImageFormat format)
@@ -221,6 +203,8 @@ brasero_image_properties_set_formats (BraseroImageProperties *self,
"changed",
G_CALLBACK (brasero_image_properties_format_changed_cb),
self);
+
+ priv->format_box = box;
}
num = brasero_image_type_chooser_set_formats (BRASERO_IMAGE_TYPE_CHOOSER (priv->format),
@@ -229,9 +213,179 @@ brasero_image_properties_set_formats (BraseroImageProperties *self,
format);
if (num > 1)
- gtk_widget_show (priv->format);
+ gtk_widget_show (priv->format_box);
else
- gtk_widget_hide (priv->format);
+ gtk_widget_hide (priv->format_box);
+}
+
+static void
+brasero_image_properties_set_output_path (BraseroImageProperties *self,
+ BraseroImageFormat format,
+ const gchar *path)
+{
+ BraseroImagePropertiesPrivate *priv;
+
+ priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (self);
+
+ switch (format) {
+ case BRASERO_IMAGE_FORMAT_BIN:
+ brasero_burn_session_set_image_output_full (BRASERO_BURN_SESSION (priv->session),
+ format,
+ path,
+ NULL);
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CDRDAO:
+ case BRASERO_IMAGE_FORMAT_CLONE:
+ case BRASERO_IMAGE_FORMAT_CUE:
+ brasero_burn_session_set_image_output_full (BRASERO_BURN_SESSION (priv->session),
+ format,
+ NULL,
+ path);
+ break;
+
+ default:
+ break;
+ }
+}
+
+static void
+brasero_image_properties_file_activated (GtkFileChooser *chooser,
+ BraseroImageProperties *self)
+{
+ BraseroImagePropertiesPrivate *priv;
+ BraseroImageFormat format;
+ gchar *path;
+
+ priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (self);
+
+ /* get and check format */
+ format = brasero_image_properties_get_format (self);
+
+ /* see if the user has changed the path */
+ if (priv->edited)
+ path = brasero_image_properties_get_path (self);
+ else
+ path = NULL;
+
+ brasero_image_properties_set_output_path (self,
+ format,
+ path);
+ g_free (path);
+}
+
+static gchar *
+brasero_image_properties_get_output_path (BraseroImageProperties *self)
+{
+ gchar *path = NULL;
+ BraseroImageFormat format;
+ BraseroImagePropertiesPrivate *priv;
+
+ priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (self);
+
+ format = brasero_burn_session_get_output_format (BRASERO_BURN_SESSION (priv->session));
+ switch (format) {
+ case BRASERO_IMAGE_FORMAT_BIN:
+ brasero_burn_session_get_output (BRASERO_BURN_SESSION (priv->session),
+ &path,
+ NULL);
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CLONE:
+ case BRASERO_IMAGE_FORMAT_CDRDAO:
+ case BRASERO_IMAGE_FORMAT_CUE:
+ brasero_burn_session_get_output (BRASERO_BURN_SESSION (priv->session),
+ NULL,
+ &path);
+ break;
+
+ default:
+ break;
+ }
+
+ return path;
+}
+
+static void
+brasero_image_properties_update (BraseroImageProperties *self)
+{
+ BraseroImagePropertiesPrivate *priv;
+ BraseroImageFormat formats;
+ BraseroImageFormat format;
+ gchar *path;
+ guint num;
+
+ priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (self);
+
+ priv->edited = brasero_session_cfg_has_default_output_path (priv->session);
+
+ /* set all information namely path and format */
+ path = brasero_image_properties_get_output_path (self);
+ brasero_image_properties_set_path (self, path);
+ g_free (path);
+
+ if (!brasero_session_cfg_has_default_output_format (priv->session))
+ format = brasero_burn_session_get_output_format (BRASERO_BURN_SESSION (priv->session));
+ else
+ format = BRASERO_IMAGE_FORMAT_ANY;
+
+ num = brasero_burn_session_get_possible_output_formats (BRASERO_BURN_SESSION (priv->session), &formats);
+ brasero_image_properties_set_formats (self,
+ num > 0 ? formats:BRASERO_IMAGE_FORMAT_NONE,
+ format);
+}
+
+void
+brasero_image_properties_set_session (BraseroImageProperties *props,
+ BraseroSessionCfg *session)
+{
+ BraseroImagePropertiesPrivate *priv;
+
+ priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (props);
+
+ priv->session = g_object_ref (session);
+ brasero_image_properties_update (BRASERO_IMAGE_PROPERTIES (props));
+}
+
+static void
+brasero_image_properties_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ BraseroImagePropertiesPrivate *priv;
+
+ priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_SESSION: /* Readable and only writable at creation time */
+ /*brasero_image_properties_set_session (BRASERO_IMAGE_PROPERTIES (object),
+ g_value_get_object (value));
+ */break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+brasero_image_properties_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ BraseroImagePropertiesPrivate *priv;
+
+ priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_SESSION:
+ g_value_set_object (value, G_OBJECT (priv->session));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
}
static void
@@ -243,13 +397,13 @@ brasero_image_properties_init (BraseroImageProperties *object)
gtk_window_set_title (GTK_WINDOW (object), _("Location for Image File"));
gtk_dialog_set_has_separator (GTK_DIALOG (object), FALSE);
- gtk_dialog_add_buttons (GTK_DIALOG (object),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_APPLY, GTK_RESPONSE_OK,
- NULL);
-
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (object)->vbox), 12);
gtk_container_set_border_width (GTK_CONTAINER (GTK_BOX (GTK_DIALOG (object)->vbox)), 10);
+
+ g_signal_connect (object,
+ "file-activated",
+ G_CALLBACK (brasero_image_properties_file_activated),
+ NULL);
}
static void
@@ -258,9 +412,10 @@ brasero_image_properties_finalize (GObject *object)
BraseroImagePropertiesPrivate *priv;
priv = BRASERO_IMAGE_PROPERTIES_PRIVATE (object);
- if (priv->original_path) {
- g_free (priv->original_path);
- priv->original_path = NULL;
+
+ if (priv->session) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -274,20 +429,25 @@ brasero_image_properties_class_init (BraseroImagePropertiesClass *klass)
g_type_class_add_private (klass, sizeof (BraseroImagePropertiesPrivate));
+ object_class->set_property = brasero_image_properties_set_property;
+ object_class->get_property = brasero_image_properties_get_property;
object_class->finalize = brasero_image_properties_finalize;
- brasero_image_properties_signals [FORMAT_CHANGED_SIGNAL] =
- g_signal_new ("format_changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST|G_SIGNAL_NO_RECURSE,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0, G_TYPE_NONE);
+
+ g_object_class_install_property (object_class,
+ PROP_SESSION,
+ g_param_spec_object ("session",
+ "The session",
+ "The session to work with",
+ BRASERO_TYPE_SESSION_CFG,
+ G_PARAM_READWRITE));
}
GtkWidget *
-brasero_image_properties_new ()
+brasero_image_properties_new (void)
{
+ /* Reminder: because it is a GtkFileChooser we can set the session as
+ * a construct parameter because the GtkFileChooser interface won't be
+ * setup when we set the value for the session property. */
return GTK_WIDGET (g_object_new (BRASERO_TYPE_IMAGE_PROPERTIES,
"action", GTK_FILE_CHOOSER_ACTION_SAVE,
"do-overwrite-confirmation", TRUE,
diff --git a/libbrasero-burn/brasero-image-properties.h b/libbrasero-burn/brasero-image-properties.h
index b0884ff..c632c36 100644
--- a/libbrasero-burn/brasero-image-properties.h
+++ b/libbrasero-burn/brasero-image-properties.h
@@ -35,7 +35,7 @@
#include <gtk/gtk.h>
-#include "brasero-track.h"
+#include "brasero-session-cfg.h"
G_BEGIN_DECLS
@@ -61,25 +61,12 @@ struct _BraseroImageProperties
GType brasero_image_properties_get_type (void) G_GNUC_CONST;
-GtkWidget *brasero_image_properties_new ();
-
-gchar *
-brasero_image_properties_get_path (BraseroImageProperties *self);
-
-gboolean
-brasero_image_properties_is_path_edited (BraseroImageProperties *self);
-
-BraseroImageFormat
-brasero_image_properties_get_format (BraseroImageProperties *self);
+GtkWidget *brasero_image_properties_new (void);
void
-brasero_image_properties_set_path (BraseroImageProperties *self,
- const gchar *path);
+brasero_image_properties_set_session (BraseroImageProperties *prop,
+ BraseroSessionCfg *session);
-void
-brasero_image_properties_set_formats (BraseroImageProperties *self,
- BraseroImageFormat formats,
- BraseroImageFormat format);
G_END_DECLS
#endif /* _BRASERO_IMAGE_PROPERTIES_H_ */
diff --git a/libbrasero-burn/brasero-medium-properties.c b/libbrasero-burn/brasero-medium-properties.c
index ee46d21..495bce0 100644
--- a/libbrasero-burn/brasero-medium-properties.c
+++ b/libbrasero-burn/brasero-medium-properties.c
@@ -58,13 +58,6 @@ struct _BraseroMediumPropertiesPrivate
BraseroBurnSession *session;
GtkWidget *medium_prop;
-
- glong valid_sig;
- glong output_sig;
-
- guint default_format:1;
- guint default_path:1;
- guint default_ext:1;
};
#define BRASERO_MEDIUM_PROPERTIES_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_MEDIUM_PROPERTIES, BraseroMediumPropertiesPrivate))
@@ -119,199 +112,18 @@ brasero_medium_properties_drive_properties (BraseroMediumProperties *self)
gtk_dialog_run (GTK_DIALOG (dialog));
priv->medium_prop = NULL;
gtk_widget_destroy (dialog);
-
- /* FIXME: save */
- //brasero_session_cfg_save_drive_properties (BRASERO_SESSION_CFG (priv->session));
-}
-
-static gchar *
-brasero_medium_properties_get_output_path (BraseroMediumProperties *self)
-{
- gchar *path = NULL;
- BraseroImageFormat format;
- BraseroMediumPropertiesPrivate *priv;
-
- priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
-
- format = brasero_burn_session_get_output_format (priv->session);
- switch (format) {
- case BRASERO_IMAGE_FORMAT_BIN:
- brasero_burn_session_get_output (priv->session,
- &path,
- NULL,
- NULL);
- break;
-
- case BRASERO_IMAGE_FORMAT_CLONE:
- brasero_burn_session_get_output (priv->session,
- NULL,
- &path,
- NULL);
- break;
-
- case BRASERO_IMAGE_FORMAT_CDRDAO:
- brasero_burn_session_get_output (priv->session,
- NULL,
- &path,
- NULL);
- break;
-
- case BRASERO_IMAGE_FORMAT_CUE:
- brasero_burn_session_get_output (priv->session,
- NULL,
- &path,
- NULL);
- break;
-
- default:
- break;
- }
-
- return path;
-}
-
-static void
-brasero_medium_properties_set_output_path (BraseroMediumProperties *self,
- BraseroImageFormat format,
- const gchar *path)
-{
- BraseroMediumPropertiesPrivate *priv;
-
- priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
-
- switch (format) {
- case BRASERO_IMAGE_FORMAT_BIN:
- brasero_burn_session_set_image_output_full (priv->session,
- format,
- path,
- NULL);
- break;
-
- case BRASERO_IMAGE_FORMAT_CDRDAO:
- case BRASERO_IMAGE_FORMAT_CLONE:
- case BRASERO_IMAGE_FORMAT_CUE:
- brasero_burn_session_set_image_output_full (priv->session,
- format,
- NULL,
- path);
- break;
-
- default:
- break;
- }
-}
-
-static guint
-brasero_medium_properties_get_possible_output_formats (BraseroMediumProperties *self,
- BraseroImageFormat *formats)
-{
- guint num = 0;
- BraseroImageFormat format;
- BraseroTrackType *output = NULL;
- BraseroMediumPropertiesPrivate *priv;
-
- priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
-
- /* see how many output format are available */
- format = BRASERO_IMAGE_FORMAT_CDRDAO;
- (*formats) = BRASERO_IMAGE_FORMAT_NONE;
-
- output = brasero_track_type_new ();
- brasero_track_type_set_has_image (output);
-
- for (; format > BRASERO_IMAGE_FORMAT_NONE; format >>= 1) {
- BraseroBurnResult result;
-
- brasero_track_type_set_image_format (output, format);
- result = brasero_burn_session_output_supported (priv->session, output);
- if (result == BRASERO_BURN_OK) {
- (*formats) |= format;
- num ++;
- }
- }
-
- brasero_track_type_free (output);
-
- return num;
-}
-
-static void
-brasero_medium_properties_image_format_changed_cb (BraseroImageProperties *dialog,
- BraseroMediumProperties *self)
-{
- BraseroMediumPropertiesPrivate *priv;
- BraseroImageFormat format;
- gchar *image_path;
-
- priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
-
- /* make sure the extension is still valid */
- image_path = brasero_image_properties_get_path (dialog);
- if (!image_path)
- return;
-
- format = brasero_image_properties_get_format (dialog);
-
- if (format == BRASERO_IMAGE_FORMAT_ANY || format == BRASERO_IMAGE_FORMAT_NONE)
- format = brasero_burn_session_get_default_output_format (priv->session);
-
- if (priv->default_path && !brasero_image_properties_is_path_edited (dialog)) {
- /* not changed: get a new default path */
- g_free (image_path);
- image_path = brasero_image_format_get_default_path (format);
- }
- else if (image_path) {
- gchar *tmp;
-
- tmp = image_path;
- image_path = brasero_image_format_fix_path_extension (format, FALSE, image_path);
- g_free (tmp);
- }
- else {
- priv->default_path = TRUE;
- image_path = brasero_image_format_get_default_path (format);
- }
-
- brasero_image_properties_set_path (dialog, image_path);
}
static gboolean
-brasero_medium_properties_image_check_extension (BraseroMediumProperties *self,
- BraseroImageFormat format,
- const gchar *path)
-{
- gchar *dot;
- const gchar *suffixes [] = {".iso",
- ".toc",
- ".cue",
- ".toc",
- NULL };
-
- dot = g_utf8_strrchr (path, -1, '.');
- if (dot) {
- if (format & BRASERO_IMAGE_FORMAT_BIN
- && !strcmp (suffixes [0], dot))
- return TRUE;
- else if (format & BRASERO_IMAGE_FORMAT_CLONE
- && !strcmp (suffixes [1], dot))
- return TRUE;
- else if (format & BRASERO_IMAGE_FORMAT_CUE
- && !strcmp (suffixes [2], dot))
- return TRUE;
- else if (format & BRASERO_IMAGE_FORMAT_CDRDAO
- && !strcmp (suffixes [3], dot))
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-brasero_medium_properties_image_extension_ask (BraseroMediumProperties *self)
+brasero_medium_properties_wrong_extension (BraseroSessionCfg *session,
+ BraseroMediumProperties *self)
{
GtkWidget *dialog;
GtkWidget *toplevel;
GtkResponseType answer;
+ BraseroMediumPropertiesPrivate *priv;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
@@ -345,101 +157,29 @@ static void
brasero_medium_properties_image_properties (BraseroMediumProperties *self)
{
BraseroMediumPropertiesPrivate *priv;
- BraseroImageFormat formats;
- BraseroImageFormat format;
- gulong format_changed;
- gchar *original_path;
GtkWindow *toplevel;
- gchar *image_path;
- gint answer;
- guint num;
priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
priv->medium_prop = brasero_image_properties_new ();
+ brasero_image_properties_set_session (BRASERO_IMAGE_PROPERTIES (priv->medium_prop),
+ BRASERO_SESSION_CFG (priv->session));
+
+ gtk_dialog_add_buttons (GTK_DIALOG (priv->medium_prop),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
+ NULL);
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
gtk_window_set_transient_for (GTK_WINDOW (priv->medium_prop), GTK_WINDOW (toplevel));
gtk_window_set_destroy_with_parent (GTK_WINDOW (priv->medium_prop), TRUE);
gtk_window_set_position (GTK_WINDOW (toplevel), GTK_WIN_POS_CENTER_ON_PARENT);
- /* set all information namely path and format */
- original_path = brasero_medium_properties_get_output_path (self);
- brasero_image_properties_set_path (BRASERO_IMAGE_PROPERTIES (priv->medium_prop), original_path);
- g_free (original_path);
-
- if (!priv->default_format)
- format = brasero_burn_session_get_output_format (priv->session);
- else
- format = BRASERO_IMAGE_FORMAT_ANY;
-
- num = brasero_medium_properties_get_possible_output_formats (self, &formats);
- brasero_image_properties_set_formats (BRASERO_IMAGE_PROPERTIES (priv->medium_prop),
- num > 0 ? formats:BRASERO_IMAGE_FORMAT_NONE,
- format);
-
- format_changed = g_signal_connect (priv->medium_prop,
- "format-changed",
- G_CALLBACK (brasero_medium_properties_image_format_changed_cb),
- self);
-
/* and here we go ... run the thing */
gtk_widget_show (priv->medium_prop);
- answer = gtk_dialog_run (GTK_DIALOG (priv->medium_prop));
-
- g_signal_handler_disconnect (priv->medium_prop, format_changed);
-
- if (answer != GTK_RESPONSE_OK) {
- gtk_widget_destroy (priv->medium_prop);
- priv->medium_prop = NULL;
- return;
- }
-
- /* get and check format */
- format = brasero_image_properties_get_format (BRASERO_IMAGE_PROPERTIES (priv->medium_prop));
-
- /* see if we are to choose the format ourselves */
- if (format == BRASERO_IMAGE_FORMAT_ANY || format == BRASERO_IMAGE_FORMAT_NONE) {
- format = brasero_burn_session_get_default_output_format (priv->session);
- priv->default_format = TRUE;
- }
- else
- priv->default_format = FALSE;
-
- /* see if the user has changed the path */
- if (brasero_image_properties_is_path_edited (BRASERO_IMAGE_PROPERTIES (priv->medium_prop)))
- priv->default_path = FALSE;
-
- if (!priv->default_path) {
- /* check the extension */
- image_path = brasero_image_properties_get_path (BRASERO_IMAGE_PROPERTIES (priv->medium_prop));
-
- /* there is one special case: CLONE image tocs _must_ have a
- * correct suffix ".toc" so don't ask, fix it */
- if (!brasero_medium_properties_image_check_extension (self, format, image_path)) {
- if (format == BRASERO_IMAGE_FORMAT_CLONE
- || brasero_medium_properties_image_extension_ask (self)) {
- gchar *tmp;
-
- priv->default_ext = TRUE;
- tmp = image_path;
- image_path = brasero_image_format_fix_path_extension (format, TRUE, image_path);
- g_free (tmp);
- }
- else
- priv->default_ext = FALSE;
- }
- }
- else
- image_path = brasero_image_format_get_default_path (format);
+ gtk_dialog_run (GTK_DIALOG (priv->medium_prop));
gtk_widget_destroy (priv->medium_prop);
priv->medium_prop = NULL;
-
- brasero_medium_properties_set_output_path (self,
- format,
- image_path);
- g_free (image_path);
}
static void
@@ -461,95 +201,6 @@ brasero_medium_properties_clicked (GtkButton *button)
}
static void
-brasero_medium_properties_update_image_output (BraseroMediumProperties *self,
- gboolean is_valid)
-{
- BraseroMediumPropertiesPrivate *priv;
- BraseroImageFormat valid_format;
- BraseroImageFormat format;
- gchar *path = NULL;
-
- priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
-
- /* Get session current state */
- format = brasero_burn_session_get_output_format (priv->session);
- valid_format = format;
-
- /* Check current set format if it's invalid */
- if (format != BRASERO_IMAGE_FORMAT_NONE) {
- /* The user set a format. There is nothing to do about it except
- * checking if the format is still available. If not, then set
- * default and remove the current one */
- if (!is_valid) {
- priv->default_format = TRUE;
- valid_format = brasero_burn_session_get_default_output_format (priv->session);
- }
- else if (priv->default_format) {
- /* since input, or caps changed, check if there isn't a
- * better format available. */
- valid_format = brasero_burn_session_get_default_output_format (priv->session);
- }
- }
- else {
- /* This is always invalid; find one */
- priv->default_format = TRUE;
- valid_format = brasero_burn_session_get_default_output_format (priv->session);
- }
-
- /* see if we have a workable format */
- if (valid_format == BRASERO_IMAGE_FORMAT_NONE) {
- if (priv->medium_prop) {
- gtk_widget_destroy (priv->medium_prop);
- priv->medium_prop = NULL;
- }
-
- return;
- }
-
- path = brasero_medium_properties_get_output_path (self);
-
- /* Now check, fix the output path, _provided__the__format__changed_ */
- if (valid_format == format) {
- g_free (path);
- return;
- }
-
- if (!path) {
- priv->default_path = TRUE;
- priv->default_ext = TRUE;
- path = brasero_image_format_get_default_path (valid_format);
- }
- else if (priv->default_ext
- && brasero_medium_properties_image_check_extension (self, format, path)) {
- gchar *tmp;
-
- priv->default_ext = TRUE;
-
- tmp = path;
- path = brasero_image_format_fix_path_extension (format, TRUE, path);
- g_free (tmp);
- }
-
- /* we always need to do this */
- brasero_medium_properties_set_output_path (self,
- valid_format,
- path);
-
- g_free (path);
-
- if (priv->medium_prop) {
- BraseroImageFormat formats;
- guint num;
-
- /* update image settings dialog if needed */
- num = brasero_medium_properties_get_possible_output_formats (self, &formats);
- brasero_image_properties_set_formats (BRASERO_IMAGE_PROPERTIES (priv->medium_prop),
- num > 1 ? formats:BRASERO_IMAGE_FORMAT_NONE,
- BRASERO_IMAGE_FORMAT_ANY);
- }
-}
-
-static void
brasero_medium_properties_output_changed (BraseroBurnSession *session,
BraseroMedium *former,
BraseroMediumProperties *self)
@@ -567,19 +218,6 @@ brasero_medium_properties_output_changed (BraseroBurnSession *session,
}
static void
-brasero_medium_properties_valid_session (BraseroSessionCfg *session,
- BraseroMediumProperties *self)
-{
- BraseroMediumPropertiesPrivate *priv;
-
- priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
-
- /* make sure the current displayed path is valid */
- if (brasero_burn_session_is_dest_file (priv->session))
- brasero_medium_properties_update_image_output (self, BRASERO_SESSION_IS_VALID (brasero_session_cfg_get_error (session)));
-}
-
-static void
brasero_medium_properties_init (BraseroMediumProperties *object)
{
BraseroMediumPropertiesPrivate *priv;
@@ -587,10 +225,6 @@ brasero_medium_properties_init (BraseroMediumProperties *object)
priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (object);
gtk_widget_set_tooltip_text (GTK_WIDGET (object), _("Configure recording options"));
-
- priv->default_ext = TRUE;
- priv->default_path = TRUE;
- priv->default_format = TRUE;
}
static void
@@ -600,17 +234,10 @@ brasero_medium_properties_finalize (GObject *object)
priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (object);
- if (priv->valid_sig) {
- g_signal_handler_disconnect (priv->session,
- priv->valid_sig);
- priv->valid_sig = 0;
- }
- if (priv->output_sig) {
- g_signal_handler_disconnect (priv->session,
- priv->output_sig);
- priv->output_sig = 0;
- }
if (priv->session) {
+ g_signal_handlers_disconnect_by_func (priv->session,
+ brasero_medium_properties_output_changed,
+ object);
g_object_unref (priv->session);
priv->session = NULL;
}
@@ -641,14 +268,14 @@ brasero_medium_properties_set_property (GObject *object,
priv->session = session;
g_object_ref (session);
- priv->valid_sig = g_signal_connect (session,
- "is-valid",
- G_CALLBACK (brasero_medium_properties_valid_session),
- object);
- priv->output_sig = g_signal_connect (session,
- "output-changed",
- G_CALLBACK (brasero_medium_properties_output_changed),
- object);
+ g_signal_connect (session,
+ "output-changed",
+ G_CALLBACK (brasero_medium_properties_output_changed),
+ object);
+ g_signal_connect (session,
+ "wrong-extension",
+ G_CALLBACK (brasero_medium_properties_wrong_extension),
+ object);
break;
default:
@@ -694,13 +321,13 @@ brasero_medium_properties_class_init (BraseroMediumPropertiesClass *klass)
g_param_spec_object ("session",
"The session to work with",
"The session to work with",
- BRASERO_TYPE_BURN_SESSION,
+ BRASERO_TYPE_SESSION_CFG,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
}
GtkWidget *
-brasero_medium_properties_new (BraseroBurnSession *session)
+brasero_medium_properties_new (BraseroSessionCfg *session)
{
return g_object_new (BRASERO_TYPE_MEDIUM_PROPERTIES,
"session", session,
diff --git a/libbrasero-burn/brasero-medium-properties.h b/libbrasero-burn/brasero-medium-properties.h
index 24b7bfb..f709fc8 100644
--- a/libbrasero-burn/brasero-medium-properties.h
+++ b/libbrasero-burn/brasero-medium-properties.h
@@ -35,7 +35,7 @@
#include <gtk/gtk.h>
-#include "brasero-session.h"
+#include "brasero-session-cfg.h"
G_BEGIN_DECLS
@@ -62,7 +62,7 @@ struct _BraseroMediumProperties
GType brasero_medium_properties_get_type (void) G_GNUC_CONST;
GtkWidget *
-brasero_medium_properties_new (BraseroBurnSession *session);
+brasero_medium_properties_new (BraseroSessionCfg *session);
G_END_DECLS
diff --git a/libbrasero-burn/brasero-session-cfg.c b/libbrasero-burn/brasero-session-cfg.c
index 3e433df..2fd8a4c 100644
--- a/libbrasero-burn/brasero-session-cfg.c
+++ b/libbrasero-burn/brasero-session-cfg.c
@@ -76,6 +76,7 @@ struct _BraseroSessionCfgPrivate
enum
{
IS_VALID_SIGNAL,
+ WRONG_EXTENSION_SIGNAL,
LAST_SIGNAL
};
@@ -88,6 +89,189 @@ G_DEFINE_TYPE (BraseroSessionCfg, brasero_session_cfg, BRASERO_TYPE_SESSION_SPAN
#define BRASERO_DRIVE_PROPERTIES_KEY "/apps/brasero/drives"
/**
+ * Manages the output path
+ */
+
+gboolean
+brasero_session_cfg_has_default_output_path (BraseroSessionCfg *session)
+{
+ BraseroBurnSessionClass *klass;
+ BraseroBurnResult result;
+
+ klass = BRASERO_BURN_SESSION_CLASS (brasero_session_cfg_parent_class);
+ result = klass->get_output_path (BRASERO_BURN_SESSION (session), NULL, NULL);
+ return (result == BRASERO_BURN_OK);
+}
+
+gboolean
+brasero_session_cfg_has_default_output_format (BraseroSessionCfg *session)
+{
+ BraseroBurnSessionClass *klass;
+ BraseroImageFormat format;
+
+ klass = BRASERO_BURN_SESSION_CLASS (brasero_session_cfg_parent_class);
+ format = klass->get_output_format (BRASERO_BURN_SESSION (session));
+ return (format == BRASERO_IMAGE_FORMAT_NONE);
+}
+
+static gboolean
+brasero_session_cfg_wrong_extension_signal (BraseroSessionCfg *session)
+{
+ GValue instance_and_params [1];
+ GValue return_value;
+
+ instance_and_params [0].g_type = 0;
+ g_value_init (instance_and_params, G_TYPE_FROM_INSTANCE (session));
+ g_value_set_instance (instance_and_params, session);
+
+ return_value.g_type = 0;
+ g_value_init (&return_value, G_TYPE_BOOLEAN);
+ g_value_set_int (&return_value, FALSE);
+
+ g_signal_emitv (instance_and_params,
+ session_cfg_signals [WRONG_EXTENSION_SIGNAL],
+ 0,
+ &return_value);
+
+ g_value_unset (instance_and_params);
+
+ return g_value_get_boolean (&return_value);
+}
+
+static BraseroBurnResult
+brasero_session_cfg_set_output_image (BraseroBurnSession *session,
+ BraseroImageFormat format,
+ const gchar *image,
+ const gchar *toc)
+{
+ gchar *dot;
+ BraseroBurnResult result;
+ BraseroBurnSessionClass *klass;
+ const gchar *suffixes [] = {".iso",
+ ".toc",
+ ".cue",
+ ".toc",
+ NULL };
+
+ /* First set all information */
+ klass = BRASERO_BURN_SESSION_CLASS (brasero_session_cfg_parent_class);
+ result = klass->set_output_image (session,
+ format,
+ image,
+ toc);
+
+ if (!image && !toc)
+ return result;
+
+ if (format == BRASERO_IMAGE_FORMAT_NONE)
+ format = brasero_burn_session_get_output_format (session);
+
+ if (format == BRASERO_IMAGE_FORMAT_NONE)
+ return result;
+
+ if (format & BRASERO_IMAGE_FORMAT_BIN) {
+ dot = g_utf8_strrchr (image, -1, '.');
+ if (!strcmp (suffixes [0], dot)) {
+ gboolean res;
+
+ res = brasero_session_cfg_wrong_extension_signal (BRASERO_SESSION_CFG (session));
+ if (res)
+ brasero_image_format_fix_path_extension (format, FALSE, image);
+ }
+ }
+ else {
+ dot = g_utf8_strrchr (toc, -1, '.');
+
+ if (format & BRASERO_IMAGE_FORMAT_CLONE
+ && !strcmp (suffixes [1], dot)) {
+ gboolean res;
+
+ res = brasero_session_cfg_wrong_extension_signal (BRASERO_SESSION_CFG (session));
+ if (res)
+ brasero_image_format_fix_path_extension (format, FALSE, toc);
+ }
+ else if (format & BRASERO_IMAGE_FORMAT_CUE
+ && !strcmp (suffixes [2], dot)) {
+ gboolean res;
+
+ res = brasero_session_cfg_wrong_extension_signal (BRASERO_SESSION_CFG (session));
+ if (res)
+ brasero_image_format_fix_path_extension (format, FALSE, toc);
+ }
+ else if (format & BRASERO_IMAGE_FORMAT_CDRDAO
+ && !strcmp (suffixes [3], dot)) {
+ gboolean res;
+
+ res = brasero_session_cfg_wrong_extension_signal (BRASERO_SESSION_CFG (session));
+ if (res)
+ brasero_image_format_fix_path_extension (format, FALSE, toc);
+ }
+ }
+
+ return result;
+}
+
+static BraseroBurnResult
+brasero_session_cfg_get_output_path (BraseroBurnSession *session,
+ gchar **image,
+ gchar **toc)
+{
+ gchar *path = NULL;
+ BraseroBurnResult result;
+ BraseroImageFormat format;
+ BraseroBurnSessionClass *klass;
+
+ klass = BRASERO_BURN_SESSION_CLASS (brasero_session_cfg_parent_class);
+
+ result = klass->get_output_path (session,
+ toc,
+ image);
+ if (result == BRASERO_BURN_OK)
+ return result;
+
+ format = brasero_burn_session_get_output_format (session);
+ path = brasero_image_format_get_default_path (format);
+
+ switch (format) {
+ case BRASERO_IMAGE_FORMAT_BIN:
+ if (image)
+ *image = path;
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CDRDAO:
+ case BRASERO_IMAGE_FORMAT_CLONE:
+ case BRASERO_IMAGE_FORMAT_CUE:
+ if (toc)
+ *toc = path;
+
+ if (image)
+ *image = brasero_image_format_get_complement (format, path);
+ break;
+
+ default:
+ g_free (path);
+ return BRASERO_BURN_ERR;
+ }
+
+ return BRASERO_BURN_OK;
+}
+
+static BraseroImageFormat
+brasero_session_cfg_get_output_format (BraseroBurnSession *session)
+{
+ BraseroBurnSessionClass *klass;
+ BraseroImageFormat format;
+
+ klass = BRASERO_BURN_SESSION_CLASS (brasero_session_cfg_parent_class);
+ format = klass->get_output_format (session);
+
+ if (format == BRASERO_IMAGE_FORMAT_NONE)
+ format = brasero_burn_session_get_default_output_format (session);
+
+ return format;
+}
+
+/**
* Get a key to save parameters through GConf
*/
@@ -1137,12 +1321,26 @@ brasero_session_cfg_class_init (BraseroSessionCfgClass *klass)
object_class->finalize = brasero_session_cfg_finalize;
+ session_class->get_output_path = brasero_session_cfg_get_output_path;
+ session_class->get_output_format = brasero_session_cfg_get_output_format;
+ session_class->set_output_image = brasero_session_cfg_set_output_image;
+
session_class->track_added = brasero_session_cfg_track_added;
session_class->track_removed = brasero_session_cfg_track_removed;
session_class->track_changed = brasero_session_cfg_track_changed;
session_class->output_changed = brasero_session_cfg_output_changed;
- session_cfg_signals[IS_VALID_SIGNAL] =
+ session_cfg_signals [WRONG_EXTENSION_SIGNAL] =
+ g_signal_new ("wrong_extension",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_RUN_CLEANUP | G_SIGNAL_ACTION,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ G_TYPE_NONE);
+ session_cfg_signals [IS_VALID_SIGNAL] =
g_signal_new ("is_valid",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_RUN_CLEANUP | G_SIGNAL_ACTION,
diff --git a/libbrasero-burn/brasero-session-cfg.h b/libbrasero-burn/brasero-session-cfg.h
index 8d6ec5b..f518c6e 100644
--- a/libbrasero-burn/brasero-session-cfg.h
+++ b/libbrasero-burn/brasero-session-cfg.h
@@ -107,10 +107,16 @@ brasero_session_cfg_is_supported (BraseroSessionCfg *cfg,
gboolean
brasero_session_cfg_is_compulsory (BraseroSessionCfg *cfg,
BraseroBurnFlag flags);
+
+gboolean
+brasero_session_cfg_has_default_output_format (BraseroSessionCfg *cfg);
+
+gboolean
+brasero_session_cfg_has_default_output_path (BraseroSessionCfg *cfg);
+
void
brasero_session_cfg_disable (BraseroSessionCfg *self);
-
G_END_DECLS
#endif /* _BRASERO_SESSION_CFG_H_ */
diff --git a/libbrasero-burn/brasero-session.c b/libbrasero-burn/brasero-session.c
index e98bcbc..78e67e8 100644
--- a/libbrasero-burn/brasero-session.c
+++ b/libbrasero-burn/brasero-session.c
@@ -636,23 +636,36 @@ brasero_burn_session_get_rate (BraseroBurnSession *self)
BraseroBurnResult
brasero_burn_session_get_output (BraseroBurnSession *self,
- gchar **image_ret,
- gchar **toc_ret,
- GError **error)
+ gchar **image,
+ gchar **toc)
{
- gchar *toc = NULL;
- gchar *image = NULL;
+ BraseroBurnSessionClass *klass;
BraseroBurnSessionPrivate *priv;
- g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
+ g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_IMAGE_FORMAT_NONE);
priv = BRASERO_BURN_SESSION_PRIVATE (self);
-
if (!BRASERO_BURN_SESSION_WRITE_TO_FILE (priv)) {
BRASERO_BURN_LOG ("no file disc");
return BRASERO_BURN_ERR;
}
+ klass = BRASERO_BURN_SESSION_GET_CLASS (self);
+ return klass->get_output_path (self, image, toc);
+}
+
+
+static BraseroBurnResult
+brasero_burn_session_get_output_path_real (BraseroBurnSession *self,
+ gchar **image_ret,
+ gchar **toc_ret)
+{
+ gchar *toc = NULL;
+ gchar *image = NULL;
+ BraseroBurnSessionPrivate *priv;
+
+ priv = BRASERO_BURN_SESSION_PRIVATE (self);
+
image = g_strdup (priv->settings->image);
toc = g_strdup (priv->settings->toc);
@@ -670,12 +683,6 @@ brasero_burn_session_get_output (BraseroBurnSession *self,
complement = brasero_image_format_get_complement (format, toc);
if (!complement) {
BRASERO_BURN_LOG ("no output specified");
-
- g_set_error (error,
- BRASERO_BURN_ERROR,
- BRASERO_BURN_ERROR_OUTPUT_NONE,
- _("No path was specified for the image output"));
-
g_free (toc);
return BRASERO_BURN_ERR;
}
@@ -686,11 +693,6 @@ brasero_burn_session_get_output (BraseroBurnSession *self,
*image_ret = image;
else {
BRASERO_BURN_LOG ("no output specified");
-
- g_set_error (error,
- BRASERO_BURN_ERROR,
- BRASERO_BURN_ERROR_OUTPUT_NONE,
- _("No path was specified for the image output"));
return BRASERO_BURN_ERR;
}
}
@@ -708,15 +710,25 @@ brasero_burn_session_get_output (BraseroBurnSession *self,
BraseroImageFormat
brasero_burn_session_get_output_format (BraseroBurnSession *self)
{
+ BraseroBurnSessionClass *klass;
BraseroBurnSessionPrivate *priv;
g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_IMAGE_FORMAT_NONE);
priv = BRASERO_BURN_SESSION_PRIVATE (self);
-
if (!BRASERO_BURN_SESSION_WRITE_TO_FILE (priv))
return BRASERO_IMAGE_FORMAT_NONE;
+ klass = BRASERO_BURN_SESSION_GET_CLASS (self);
+ return klass->get_output_format (self);
+}
+
+static BraseroImageFormat
+brasero_burn_session_get_output_format_real (BraseroBurnSession *self)
+{
+ BraseroBurnSessionPrivate *priv;
+
+ priv = BRASERO_BURN_SESSION_PRIVATE (self);
return priv->settings->format;
}
@@ -754,16 +766,14 @@ brasero_burn_session_set_image_output_real (BraseroBurnSession *self,
priv->settings->format = format;
}
-BraseroBurnResult
-brasero_burn_session_set_image_output_full (BraseroBurnSession *self,
+static BraseroBurnResult
+brasero_burn_session_set_output_image_real (BraseroBurnSession *self,
BraseroImageFormat format,
const gchar *image,
const gchar *toc)
{
BraseroBurnSessionPrivate *priv;
- g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
-
priv = BRASERO_BURN_SESSION_PRIVATE (self);
if (priv->settings->format == format
@@ -812,6 +822,20 @@ brasero_burn_session_set_image_output_full (BraseroBurnSession *self,
return BRASERO_BURN_OK;
}
+BraseroBurnResult
+brasero_burn_session_set_image_output_full (BraseroBurnSession *self,
+ BraseroImageFormat format,
+ const gchar *image,
+ const gchar *toc)
+{
+ BraseroBurnSessionClass *klass;
+
+ g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
+
+ klass = BRASERO_BURN_SESSION_GET_CLASS (self);
+ return klass->set_output_image (self, format, image, toc);
+}
+
/**
*
*/
@@ -1828,6 +1852,10 @@ brasero_burn_session_class_init (BraseroBurnSessionClass *klass)
parent_class = g_type_class_peek_parent(klass);
object_class->finalize = brasero_burn_session_finalize;
+ klass->get_output_path = brasero_burn_session_get_output_path_real;
+ klass->get_output_format = brasero_burn_session_get_output_format_real;
+ klass->set_output_image = brasero_burn_session_set_output_image_real;
+
/* This is to delay the setting of track source until we know all settings */
brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL] =
g_signal_new ("output_changed",
diff --git a/libbrasero-burn/brasero-session.h b/libbrasero-burn/brasero-session.h
index a31fb3f..f1687d6 100644
--- a/libbrasero-burn/brasero-session.h
+++ b/libbrasero-burn/brasero-session.h
@@ -60,6 +60,16 @@ struct _BraseroBurnSession {
struct _BraseroBurnSessionClass {
GObjectClass parent_class;
+ /** Virtual functions **/
+ BraseroBurnResult (*set_output_image) (BraseroBurnSession *session,
+ BraseroImageFormat format,
+ const gchar *image,
+ const gchar *toc);
+ BraseroBurnResult (*get_output_path) (BraseroBurnSession *session,
+ gchar **image,
+ gchar **toc);
+ BraseroImageFormat (*get_output_format) (BraseroBurnSession *session);
+
/**
* GObject signals could be used to warned of individual property
* changes but since changing one property could change others
@@ -159,8 +169,7 @@ brasero_burn_session_set_image_output_full (BraseroBurnSession *session,
BraseroBurnResult
brasero_burn_session_get_output (BraseroBurnSession *session,
gchar **image,
- gchar **toc,
- GError **error);
+ gchar **toc);
BraseroImageFormat
brasero_burn_session_get_output_format (BraseroBurnSession *session);
@@ -248,6 +257,10 @@ brasero_burn_session_output_supported (BraseroBurnSession *session,
BraseroMedia
brasero_burn_session_get_required_media_type (BraseroBurnSession *session);
+guint
+brasero_burn_session_get_possible_output_formats (BraseroBurnSession *session,
+ BraseroImageFormat *formats);
+
BraseroImageFormat
brasero_burn_session_get_default_output_format (BraseroBurnSession *session);
diff --git a/libbrasero-burn/brasero-track-data-cfg.c b/libbrasero-burn/brasero-track-data-cfg.c
index 51690cb..8648917 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,
- ACTIVITY,
IMAGE,
UNREADABLE,
RECURSIVE,
@@ -2236,8 +2235,14 @@ brasero_track_data_cfg_get_status (BraseroTrack *track,
return BRASERO_BURN_ERR;
}
- if (brasero_data_project_is_empty (BRASERO_DATA_PROJECT (priv->tree)))
+ if (brasero_data_project_is_empty (BRASERO_DATA_PROJECT (priv->tree))) {
+ if (status)
+ brasero_status_set_error (status,
+ g_error_new (BRASERO_BURN_ERROR,
+ BRASERO_BURN_ERROR_EMPTY,
+ _("The project is empty")));
return BRASERO_BURN_ERR;
+ }
return BRASERO_BURN_OK;
}
@@ -2678,11 +2683,6 @@ brasero_track_data_cfg_activity_changed (BraseroDataVFS *vfs,
emit_signal:
- g_signal_emit (self,
- brasero_track_data_cfg_signals [ACTIVITY],
- 0,
- active);
-
brasero_track_changed (BRASERO_TRACK (self));
}
@@ -3094,17 +3094,6 @@ brasero_track_data_cfg_class_init (BraseroTrackDataCfgClass *klass)
G_TYPE_OBJECT,
G_TYPE_BOOLEAN);
- brasero_track_data_cfg_signals [ACTIVITY] =
- g_signal_new ("vfs_activity",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST|G_SIGNAL_NO_RECURSE,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE,
- 1,
- G_TYPE_BOOLEAN);
-
brasero_track_data_cfg_signals [IMAGE] =
g_signal_new ("image_uri",
G_TYPE_FROM_CLASS (klass),
diff --git a/libbrasero-burn/brasero-track-stream-cfg.c b/libbrasero-burn/brasero-track-stream-cfg.c
index 5788216..f5cc388 100644
--- a/libbrasero-burn/brasero-track-stream-cfg.c
+++ b/libbrasero-burn/brasero-track-stream-cfg.c
@@ -344,7 +344,7 @@ brasero_track_stream_cfg_get_status (BraseroTrack *track,
if (status)
brasero_status_set_completed (status);
- return BRASERO_BURN_OK;
+ return BRASERO_TRACK_CLASS (brasero_track_stream_cfg_parent_class)->get_status (track, status);
}
static void
diff --git a/libbrasero-burn/burn-image-format.c b/libbrasero-burn/burn-image-format.c
index f8d9c1b..aa44191 100644
--- a/libbrasero-burn/burn-image-format.c
+++ b/libbrasero-burn/burn-image-format.c
@@ -835,7 +835,7 @@ brasero_image_format_get_default_path (BraseroImageFormat format)
gchar *
brasero_image_format_fix_path_extension (BraseroImageFormat format,
gboolean check_existence,
- gchar *path)
+ const gchar *path)
{
gchar *dot;
guint i = 0;
diff --git a/libbrasero-burn/burn-image-format.h b/libbrasero-burn/burn-image-format.h
index f246960..a1d7d2f 100644
--- a/libbrasero-burn/burn-image-format.h
+++ b/libbrasero-burn/burn-image-format.h
@@ -48,7 +48,7 @@ brasero_image_format_get_default_path (BraseroImageFormat format);
gchar *
brasero_image_format_fix_path_extension (BraseroImageFormat format,
gboolean check_existence,
- gchar *path);
+ const gchar *path);
gchar *
brasero_image_format_get_complement (BraseroImageFormat format,
const gchar *path);
diff --git a/libbrasero-burn/burn-job.c b/libbrasero-burn/burn-job.c
index 16c7d5d..64c8bfb 100644
--- a/libbrasero-burn/burn-job.c
+++ b/libbrasero-burn/burn-job.c
@@ -612,8 +612,7 @@ brasero_job_set_output_file (BraseroJob *self,
result = brasero_burn_session_get_output (session,
&image,
- &toc,
- error);
+ &toc);
/* check paths are set */
if (!image
diff --git a/src/brasero-audio-disc.c b/src/brasero-audio-disc.c
index c4ef3e7..b9969ab 100644
--- a/src/brasero-audio-disc.c
+++ b/src/brasero-audio-disc.c
@@ -58,13 +58,6 @@
#include "eggtreemultidnd.h"
static BraseroDiscResult
-brasero_audio_disc_get_track (BraseroDisc *disc,
- BraseroDiscTrack *track);
-static BraseroDiscResult
-brasero_audio_disc_load_track (BraseroDisc *disc,
- BraseroDiscTrack *track);
-
-static BraseroDiscResult
brasero_audio_disc_set_session_contents (BraseroDisc *disc,
BraseroBurnSession *session);
@@ -134,7 +127,6 @@ struct _BraseroAudioDiscPrivate {
BraseroIOJobBase *add_dir;
BraseroIOJobBase *add_playlist;
- GtkWidget *notebook;
GtkWidget *tree;
GtkUIManager *manager;
@@ -239,9 +231,7 @@ brasero_audio_disc_iface_disc_init (BraseroDiscIface *iface)
{
iface->add_uri = brasero_audio_disc_add_uri;
iface->delete_selected = brasero_audio_disc_delete_selected;
- iface->get_track = brasero_audio_disc_get_track;
iface->set_session_contents = brasero_audio_disc_set_session_contents;
- iface->load_track = brasero_audio_disc_load_track;
iface->get_selected_uri = brasero_audio_disc_get_selected_uri;
iface->get_boundaries = brasero_audio_disc_get_boundaries;
iface->add_ui = brasero_audio_disc_add_ui;
@@ -367,10 +357,6 @@ brasero_audio_disc_init (BraseroAudioDisc *obj)
obj->priv = g_new0 (BraseroAudioDiscPrivate, 1);
gtk_box_set_spacing (GTK_BOX (obj), 0);
- /* notebook to display information about how to use the tree */
- obj->priv->notebook = brasero_disc_get_use_info_notebook ();
- gtk_box_pack_start (GTK_BOX (obj), obj->priv->notebook, TRUE, TRUE, 0);
-
/* Tree */
obj->priv->tree = gtk_tree_view_new ();
gtk_tree_view_set_rubber_banding (GTK_TREE_VIEW (obj->priv->tree), TRUE);
@@ -434,9 +420,7 @@ brasero_audio_disc_init (BraseroAudioDisc *obj)
gtk_tree_view_column_pack_end (column, renderer, TRUE);
gtk_tree_view_column_add_attribute (column, renderer,
"markup", BRASERO_VIDEO_TREE_MODEL_NAME);
-/* gtk_tree_view_column_add_attribute (column, renderer,
- "background", BACKGROUND_COL);
-*/ gtk_tree_view_column_add_attribute (column, renderer,
+ gtk_tree_view_column_add_attribute (column, renderer,
"editable", BRASERO_VIDEO_TREE_MODEL_EDITABLE);
gtk_tree_view_column_set_title (column, _("Title"));
g_object_set (G_OBJECT (column),
@@ -490,10 +474,11 @@ brasero_audio_disc_init (BraseroAudioDisc *obj)
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (scroll), obj->priv->tree);
- gtk_notebook_append_page (GTK_NOTEBOOK (obj->priv->notebook),
+ gtk_box_pack_start (GTK_BOX (obj), scroll, TRUE, TRUE, 0);
+ /*gtk_notebook_append_page (GTK_NOTEBOOK (obj->priv->notebook),
scroll,
NULL);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (obj->priv->notebook), 0);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (obj->priv->notebook), 0);*/
/* dnd */
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (obj->priv->tree),
@@ -502,32 +487,6 @@ brasero_audio_disc_init (BraseroAudioDisc *obj)
GDK_ACTION_COPY|
GDK_ACTION_MOVE);
-/* g_signal_connect (G_OBJECT (obj->priv->tree),
- "drag-data-received",
- G_CALLBACK (brasero_audio_disc_drag_data_received_cb),
- obj);
- g_signal_connect (G_OBJECT (obj->priv->tree),
- "drag-drop",
- G_CALLBACK (brasero_audio_disc_drag_drop_cb),
- obj);
- g_signal_connect (G_OBJECT (obj->priv->tree),
- "drag_motion",
- G_CALLBACK (brasero_audio_disc_drag_motion_cb),
- obj);
- g_signal_connect (G_OBJECT (obj->priv->tree),
- "drag_leave",
- G_CALLBACK (brasero_audio_disc_drag_leave_cb),
- obj);
-
- g_signal_connect (G_OBJECT (obj->priv->tree),
- "drag-begin",
- G_CALLBACK (brasero_audio_disc_drag_begin_cb),
- obj);
- g_signal_connect (G_OBJECT (obj->priv->tree),
- "drag_end",
- G_CALLBACK (brasero_audio_disc_drag_end_cb),
- obj);
-*/
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (obj->priv->tree),
GDK_BUTTON1_MASK,
ntables_source,
@@ -604,7 +563,6 @@ brasero_audio_disc_add_uri_real (BraseroAudioDisc *disc,
gint64 gap_sectors,
gint64 start,
gint64 end,
- BraseroStreamInfo *info,
GtkTreePath **path_return)
{
BraseroTrackStreamCfg *track;
@@ -617,8 +575,6 @@ brasero_audio_disc_add_uri_real (BraseroAudioDisc *disc,
if (disc->priv->reject_files)
return BRASERO_DISC_NOT_READY;
- gtk_notebook_set_current_page (GTK_NOTEBOOK (BRASERO_AUDIO_DISC (disc)->priv->notebook), 1);
-
store = gtk_tree_view_get_model (GTK_TREE_VIEW (disc->priv->tree));
session = brasero_video_tree_model_get_session (BRASERO_VIDEO_TREE_MODEL (store));
@@ -629,22 +585,6 @@ brasero_audio_disc_add_uri_real (BraseroAudioDisc *disc,
end,
BRASERO_SECTORS_TO_TIME (gap_sectors));
- if (info) {
- brasero_track_tag_add_string (BRASERO_TRACK (track),
- BRASERO_TRACK_STREAM_TITLE_TAG,
- info->title);
- brasero_track_tag_add_string (BRASERO_TRACK (track),
- BRASERO_TRACK_STREAM_ARTIST_TAG,
- info->artist);
- brasero_track_tag_add_string (BRASERO_TRACK (track),
- BRASERO_TRACK_STREAM_COMPOSER_TAG,
- info->composer);
-
- brasero_track_tag_add_int (BRASERO_TRACK (track),
- BRASERO_TRACK_STREAM_ISRC_TAG,
- info->isrc);
- }
-
session = brasero_video_tree_model_get_session (BRASERO_VIDEO_TREE_MODEL (store));
if (pos > 0) {
GSList *tracks;
@@ -741,7 +681,6 @@ brasero_audio_disc_result (GObject *obj,
-1,
-1,
-1,
- NULL,
NULL);
}
@@ -959,7 +898,6 @@ brasero_audio_disc_add_uri (BraseroDisc *disc,
0,
-1,
-1,
- NULL,
&treepath);
if (treepath) {
@@ -1032,50 +970,6 @@ brasero_audio_disc_delete_selected (BraseroDisc *disc)
brasero_disc_selection_changed (disc);
}
-/********************************* create track ********************************/
-static BraseroDiscResult
-brasero_audio_disc_get_track (BraseroDisc *disc,
- BraseroDiscTrack *track_arg)
-{
- GSList *tracks;
- GtkTreeModel *model;
- BraseroAudioDisc *audio;
- BraseroSessionCfg *session;
-
- audio = BRASERO_AUDIO_DISC (disc);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (audio->priv->tree));
- session = brasero_video_tree_model_get_session (BRASERO_VIDEO_TREE_MODEL (model));
-
- tracks = brasero_burn_session_get_tracks (BRASERO_BURN_SESSION (session));
- if (!tracks)
- return BRASERO_DISC_ERROR_EMPTY_SELECTION;
-
- for (; tracks; tracks = tracks->next) {
- BraseroTrackStream *track;
- BraseroStreamInfo *info;
- BraseroDiscSong *song;
-
- track = tracks->data;
-
- song = g_new0 (BraseroDiscSong, 1);
- song->uri = brasero_track_stream_get_source (track, TRUE);
- song->start = brasero_track_stream_get_start (track);
- song->end = brasero_track_stream_get_end (track);
- song->gap = brasero_track_stream_get_gap (track);
-
- info = g_new0 (BraseroStreamInfo, 1);
- info->title = g_strdup (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_TITLE_TAG));
- info->artist = g_strdup (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ARTIST_TAG));
- info->composer = g_strdup (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_COMPOSER_TAG));
- info->isrc = brasero_track_tag_lookup_int (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ISRC_TAG);
- song->info = info;
-
- track_arg->contents.tracks = g_slist_append (track_arg->contents.tracks, song);
- }
-
- return BRASERO_DISC_OK;
-}
-
static BraseroDiscResult
brasero_audio_disc_set_session_contents (BraseroDisc *disc,
BraseroBurnSession *session)
@@ -1104,66 +998,6 @@ brasero_audio_disc_set_session_contents (BraseroDisc *disc,
return BRASERO_DISC_OK;
}
-/********************************* load track **********************************/
-static void
-brasero_audio_disc_add_track (BraseroAudioDisc *disc,
- BraseroDiscSong *song)
-{
- GtkTreeModel *model;
- BraseroSessionCfg *session;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (disc->priv->tree));
- session = brasero_video_tree_model_get_session (BRASERO_VIDEO_TREE_MODEL (model));
-
- brasero_audio_disc_add_uri_real (disc,
- song->uri,
- -1,
- song->gap,
- song->start,
- song->end,
- song->info,
- NULL);
-}
-
-static BraseroDiscResult
-brasero_audio_disc_load_track (BraseroDisc *disc,
- BraseroDiscTrack *track)
-{
- GSList *iter;
-
- g_return_val_if_fail (track->type == BRASERO_PROJECT_TYPE_AUDIO, FALSE);
-
- if (track->contents.tracks == NULL)
- return BRASERO_DISC_ERROR_EMPTY_SELECTION;
-
- for (iter = track->contents.tracks; iter; iter = iter->next) {
- BraseroDiscSong *song;
- BraseroStreamInfo *info;
-
- song = iter->data;
- info = song->info;
-
- if (song->end > 0 && !brasero_app_is_running (brasero_app_get_default ())) {
- /* Set the minimum information */
- brasero_audio_disc_add_track (BRASERO_AUDIO_DISC (disc), song);
- }
- else {
- BRASERO_AUDIO_DISC (disc)->priv->loading ++;
- brasero_audio_disc_add_uri_real (BRASERO_AUDIO_DISC (disc),
- song->uri,
- -1,
- song->gap,
- song->start,
- song->end,
- info,
- NULL);
- }
-
- }
-
- return BRASERO_DISC_OK;
-}
-
/********************************** Cell Editing *******************************/
static void
brasero_audio_disc_display_edited_cb (GtkCellRendererText *renderer,
@@ -1824,7 +1658,6 @@ brasero_audio_disc_clipboard_text_cb (GtkClipboard *clipboard,
0,
-1,
-1,
- NULL,
NULL);
g_free (uri);
}
diff --git a/src/brasero-data-disc.c b/src/brasero-data-disc.c
index 97950ef..6f97320 100644
--- a/src/brasero-data-disc.c
+++ b/src/brasero-data-disc.c
@@ -68,7 +68,8 @@ struct _BraseroDataDiscPrivate
GtkWidget *tree;
GtkWidget *filter;
BraseroTrackDataCfg *project;
- GtkWidget *notebook;
+
+ GtkSizeGroup *button_size;
GtkWidget *message;
@@ -97,7 +98,7 @@ struct _BraseroDataDiscPrivate
static void
-brasero_data_disc_new_folder_clicked_cb (GtkButton *button,
+brasero_data_disc_new_folder_clicked_cb (GtkAction *action,
BraseroDataDisc *disc);
static void
brasero_data_disc_open_activated_cb (GtkAction *action,
@@ -169,13 +170,6 @@ static GtkTargetEntry ntables_source [] = {
static guint nb_targets_source = sizeof (ntables_source) / sizeof (ntables_source[0]);
enum {
- ICON_CHANGED,
- LAST_SIGNAL
-};
-
-static gulong brasero_data_disc_signals [LAST_SIGNAL] = { 0 };
-
-enum {
PROP_NONE,
PROP_REJECT_FILE,
};
@@ -232,7 +226,6 @@ brasero_data_disc_import_session (BraseroDataDisc *disc,
return FALSE;
}
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
return TRUE;
}
@@ -316,7 +309,7 @@ brasero_data_disc_get_parent (BraseroDataDisc *self)
}
static void
-brasero_data_disc_new_folder_clicked_cb (GtkButton *button,
+brasero_data_disc_new_folder_clicked_cb (GtkAction *action,
BraseroDataDisc *disc)
{
BraseroDataDiscPrivate *priv;
@@ -332,8 +325,6 @@ brasero_data_disc_new_folder_clicked_cb (GtkButton *button,
treepath = brasero_track_data_cfg_add_empty_directory (BRASERO_TRACK_DATA_CFG (priv->project), NULL, parent);
gtk_tree_path_free (parent);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
-
/* grab focus must be called before next function to avoid
* triggering a bug where if pointer is not in the widget
* any more and enter is pressed the cell will remain editable */
@@ -438,8 +429,6 @@ brasero_data_disc_paste_activated_cb (GtkAction *action,
data = g_new0 (BraseroClipData, 1);
data->disc = disc;
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
-
parent = brasero_data_disc_get_parent (disc);
if (parent)
data->reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->project), parent);
@@ -592,29 +581,6 @@ brasero_data_disc_project_loaded_cb (BraseroTrackDataCfg *project,
}
}
-static void
-brasero_data_disc_activity_changed_cb (BraseroTrackDataCfg *vfs,
- gboolean active,
- BraseroDataDisc *self)
-{
- BraseroDataDiscPrivate *priv;
-
- priv = BRASERO_DATA_DISC_PRIVATE (self);
-
- if (!GTK_WIDGET (self)->window)
- return;
-
- if (active) {
- GdkCursor *cursor;
-
- cursor = gdk_cursor_new (GDK_WATCH);
- gdk_window_set_cursor (GTK_WIDGET (self)->window, cursor);
- gdk_cursor_unref (cursor);
- }
- else
- gdk_window_set_cursor (GTK_WIDGET (self)->window, NULL);
-}
-
static BraseroBurnResult
brasero_data_disc_image_uri_cb (BraseroTrackDataCfg *vfs,
const gchar *uri,
@@ -774,6 +740,7 @@ brasero_data_disc_joliet_rename_cb (BraseroTrackDataCfg *project,
secondary = g_strdup_printf ("%s\n%s",
_("Some files don't have a suitable name for a fully Windows-compatible CD."),
_("Those names should be changed and truncated to 64 characters."));
+
message = brasero_notify_message_add (BRASERO_NOTIFY (priv->message),
_("Should files be renamed to be fully Windows-compatible?"),
secondary,
@@ -1131,15 +1098,6 @@ brasero_data_disc_session_available_cb (BraseroTrackDataCfg *session,
}
static void
-brasero_data_disc_icon_changed_cb (BraseroTrackDataCfg *session,
- BraseroDataDisc *self)
-{
- g_signal_emit (self,
- brasero_data_disc_signals [ICON_CHANGED],
- 0);
-}
-
-static void
brasero_data_disc_session_loaded_cb (BraseroTrackDataCfg *session,
BraseroMedium *medium,
gboolean loaded,
@@ -1204,49 +1162,6 @@ brasero_data_disc_clear (BraseroDisc *disc)
}
static void
-brasero_data_disc_reset (BraseroDisc *disc)
-{
- BraseroDataDiscPrivate *priv;
-
- priv = BRASERO_DATA_DISC_PRIVATE (disc);
-
- if (priv->size_changed_id) {
- g_source_remove (priv->size_changed_id);
- priv->size_changed_id = 0;
- }
-
- /* Unload session */
- if (brasero_track_data_cfg_get_current_medium (BRASERO_TRACK_DATA_CFG (priv->project)))
- brasero_track_data_cfg_unload_current_medium (BRASERO_TRACK_DATA_CFG (priv->project));
-
- /* Hide all toggle actions for session importing */
- if (gtk_action_group_get_visible (priv->import_group))
- gtk_action_group_set_visible (priv->import_group, FALSE);
-
- if (gtk_action_group_get_visible (priv->disc_group))
- gtk_action_group_set_visible (priv->disc_group, FALSE);
-
- if (priv->load_errors) {
- g_slist_foreach (priv->load_errors, (GFunc) g_free , NULL);
- g_slist_free (priv->load_errors);
- priv->load_errors = NULL;
- }
-
- brasero_track_data_cfg_reset (priv->project);
-
- brasero_notify_message_remove (BRASERO_NOTIFY (priv->message), BRASERO_NOTIFY_CONTEXT_SIZE);
- brasero_notify_message_remove (BRASERO_NOTIFY (priv->message), BRASERO_NOTIFY_CONTEXT_LOADING);
- brasero_notify_message_remove (BRASERO_NOTIFY (priv->message), BRASERO_NOTIFY_CONTEXT_MULTISESSION);
-
- brasero_disc_size_changed (disc, 0);
-
- if (GTK_WIDGET (disc)->window)
- gdk_window_set_cursor (GTK_WIDGET (disc)->window, NULL);
-
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 0);
-}
-
-static void
brasero_data_disc_delete_selected (BraseroDisc *disc)
{
BraseroDataDiscPrivate *priv;
@@ -1310,7 +1225,6 @@ brasero_data_disc_add_uri (BraseroDisc *disc, const gchar *uri)
return BRASERO_DISC_LOADING;
parent = brasero_data_disc_get_parent (BRASERO_DATA_DISC (disc));
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
if (brasero_track_data_cfg_add (BRASERO_TRACK_DATA_CFG (priv->project), uri, parent)) {
gtk_tree_path_free (parent);
return BRASERO_DISC_OK;
@@ -1320,84 +1234,6 @@ brasero_data_disc_add_uri (BraseroDisc *disc, const gchar *uri)
return BRASERO_DISC_ERROR_UNKNOWN;
}
-static BraseroDiscResult
-brasero_data_disc_get_track (BraseroDisc *disc,
- BraseroDiscTrack *track)
-{
- gboolean res;
- GSList *grafts = NULL;
- GSList *excluded = NULL;
- BraseroDataDiscPrivate *priv;
-
- priv = BRASERO_DATA_DISC_PRIVATE (disc);
-
- res = brasero_track_data_cfg_get_contents (BRASERO_TRACK_DATA (priv->project),
- &grafts,
- &excluded);
- if (!res)
- return BRASERO_DISC_ERROR_EMPTY_SELECTION;
-
- track->contents.data.icon = g_strdup (brasero_track_data_cfg_get_icon_path (priv->project));
- track->type = BRASERO_PROJECT_TYPE_DATA;
- track->contents.data.grafts = grafts;
- track->contents.data.excluded = excluded;
-
- /* get restored */
- track->contents.data.restored = brasero_track_data_cfg_get_restored_list (BRASERO_TRACK_DATA_CFG (priv->project));
-
- return BRASERO_DISC_OK;
-}
-
-static void
-brasero_data_disc_track_removed (BraseroBurnSession *session,
- BraseroTrack *track,
- guint former_position,
- BraseroDataDisc *disc)
-{
- BraseroDataDiscPrivate *priv;
-
- priv = BRASERO_DATA_DISC_PRIVATE (disc);
-
- g_signal_handlers_disconnect_by_func (session,
- brasero_data_disc_track_removed,
- disc);
-
- /* Hide all toggle actions for session importing */
- if (gtk_action_group_get_visible (priv->import_group))
- gtk_action_group_set_visible (priv->import_group, FALSE);
-
- if (gtk_action_group_get_visible (priv->disc_group))
- gtk_action_group_set_visible (priv->disc_group, FALSE);
-
- if (priv->load_errors) {
- g_slist_foreach (priv->load_errors, (GFunc) g_free , NULL);
- g_slist_free (priv->load_errors);
- priv->load_errors = NULL;
- }
-}
-
-static BraseroDiscResult
-brasero_data_disc_set_session_contents (BraseroDisc *self,
- BraseroBurnSession *session)
-{
- BraseroDataDiscPrivate *priv;
-
- priv = BRASERO_DATA_DISC_PRIVATE (self);
-
- if (!session)
- return BRASERO_DISC_OK;
-
- brasero_burn_session_add_track (session,
- BRASERO_TRACK (priv->project),
- NULL);
- g_signal_connect (session,
- "track-removed",
- G_CALLBACK (brasero_data_disc_track_removed),
- self);
-
- return BRASERO_DISC_OK;
-}
-
static void
brasero_data_disc_message_response_cb (BraseroDiscMessage *message,
GtkResponseType response,
@@ -1417,42 +1253,125 @@ brasero_data_disc_message_response_cb (BraseroDiscMessage *message,
}
static BraseroDiscResult
-brasero_data_disc_load_track (BraseroDisc *disc,
- BraseroDiscTrack *track)
+brasero_data_disc_set_track (BraseroDataDisc *disc,
+ BraseroTrackDataCfg *track)
{
BraseroDataDiscPrivate *priv;
- BraseroBurnResult res;
BraseroStatus *status;
GtkWidget *message;
- GSList *iter;
priv = BRASERO_DATA_DISC_PRIVATE (disc);
- /* First add the restored files */
- for (iter = track->contents.data.restored; iter; iter = iter->next) {
- gchar *uri;
+ priv->project = g_object_ref (track);
- uri = iter->data;
- brasero_track_data_cfg_dont_filter_uri (priv->project, uri);
+ /* filtered files */
+ priv->filter = brasero_file_filtered_new (priv->project);
+ brasero_file_filtered_set_right_button_group (BRASERO_FILE_FILTERED (priv->filter), priv->button_size);
+ g_signal_connect (priv->filter,
+ "activate",
+ G_CALLBACK (brasero_data_disc_filter_expanded_cb),
+ disc);
+ gtk_widget_show (priv->filter);
+ gtk_box_pack_end (GTK_BOX (disc), priv->filter, FALSE, TRUE, 0);
+
+ /* Now let's take care of all the available sessions */
+ if (!priv->import_group) {
+ GSList *iter;
+ GSList *list;
+
+ priv->import_group = gtk_action_group_new ("session_import_group");
+ gtk_action_group_set_translation_domain (priv->import_group, GETTEXT_PACKAGE);
+ gtk_ui_manager_insert_action_group (priv->manager,
+ priv->import_group,
+ 0);
+
+ list = brasero_track_data_cfg_get_available_media (priv->project);
+ for (iter = list; iter; iter = iter->next) {
+ BraseroMedium *medium;
+
+ medium = iter->data;
+ brasero_data_disc_import_button_new (BRASERO_DATA_DISC (disc), medium);
+ }
+ g_slist_foreach (list, (GFunc) g_object_unref, NULL);
+ g_slist_free (list);
}
+ else
+ gtk_action_group_set_visible (priv->import_group, TRUE);
+
+ g_signal_connect (track,
+ "2G-file",
+ G_CALLBACK (brasero_data_disc_2G_file_cb),
+ disc);
+ g_signal_connect (track,
+ "deep-directory",
+ G_CALLBACK (brasero_data_disc_deep_directory_cb),
+ disc);
+ g_signal_connect (track,
+ "name-collision",
+ G_CALLBACK (brasero_data_disc_name_collision_cb),
+ disc);
+ g_signal_connect (track,
+ "joliet-rename",
+ G_CALLBACK (brasero_data_disc_joliet_rename_cb),
+ disc);
+
+ g_signal_connect (track,
+ "source-loading",
+ G_CALLBACK (brasero_data_disc_project_loading_cb),
+ disc);
+ g_signal_connect (track,
+ "source-loaded",
+ G_CALLBACK (brasero_data_disc_project_loaded_cb),
+ disc);
+
+ /* Use the BraseroTrack "changed" signal for size changes */
+ g_signal_connect (track,
+ "changed",
+ G_CALLBACK (brasero_data_disc_size_changed_cb),
+ disc);
+
+ g_signal_connect (track,
+ "image-uri",
+ G_CALLBACK (brasero_data_disc_image_uri_cb),
+ disc);
+ g_signal_connect (track,
+ "unreadable-uri",
+ G_CALLBACK (brasero_data_disc_unreadable_uri_cb),
+ disc);
+ g_signal_connect (track,
+ "recursive-sym",
+ G_CALLBACK (brasero_data_disc_recursive_uri_cb),
+ disc);
+ g_signal_connect (track,
+ "unknown-uri",
+ G_CALLBACK (brasero_data_disc_unknown_uri_cb),
+ disc);
+
+ g_signal_connect (track,
+ "session-available",
+ G_CALLBACK (brasero_data_disc_session_available_cb),
+ disc);
+ g_signal_connect (track,
+ "session-loaded",
+ G_CALLBACK (brasero_data_disc_session_loaded_cb),
+ disc);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree), GTK_TREE_MODEL (track));
- res = brasero_track_data_set_source (BRASERO_TRACK_DATA (priv->project),
- track->contents.data.grafts,
- track->contents.data.excluded);
+ status = brasero_status_new ();
+ brasero_track_get_status (BRASERO_TRACK (track), status);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
- if (res == BRASERO_BURN_OK) {
+ if (brasero_status_get_result (status) == BRASERO_BURN_OK) {
+ brasero_status_free (status);
gtk_widget_set_sensitive (GTK_WIDGET (priv->tree), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (priv->filter), TRUE);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
return BRASERO_DISC_OK;
}
- if (res != BRASERO_BURN_NOT_READY)
+ if (brasero_status_get_result (status) != BRASERO_BURN_NOT_READY) {
+ brasero_status_free (status);
return BRASERO_DISC_ERROR_UNKNOWN;
-
- status = brasero_status_new ();
- brasero_track_get_status (BRASERO_TRACK (priv->project), status);
+ }
message = brasero_notify_message_add (BRASERO_NOTIFY (priv->message),
_("Please wait while the project is loading."),
@@ -1477,53 +1396,153 @@ brasero_data_disc_load_track (BraseroDisc *disc,
gtk_widget_set_sensitive (GTK_WIDGET (priv->tree), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (priv->filter), FALSE);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
-
brasero_status_free (status);
-
- /* The icon */
- if (track->contents.data.icon)
- brasero_track_data_cfg_set_icon (priv->project, track->contents.data.icon, NULL);
-
return BRASERO_DISC_OK;
}
-static BraseroDiscResult
-brasero_data_disc_get_status (BraseroDisc *disc,
- gint *progress,
- gchar **current_task)
+static void
+brasero_data_disc_unset_track (BraseroDataDisc *disc)
{
BraseroDataDiscPrivate *priv;
- BraseroStatus *status;
priv = BRASERO_DATA_DISC_PRIVATE (disc);
- status = brasero_status_new ();
- brasero_track_get_status (BRASERO_TRACK (priv->project), status);
+ if (!priv->project)
+ return;
- if (brasero_status_get_result (status) == BRASERO_BURN_NOT_READY) {
- if (progress)
- *progress = brasero_status_get_progress (status);
+ /* Remove filtered files widget */
+ if (priv->filter) {
+ gtk_widget_destroy (priv->filter);
+ priv->filter = NULL;
+ }
- if (current_task)
- *current_task = brasero_status_get_current_action (status);
+ /* Unload session */
+ if (brasero_track_data_cfg_get_current_medium (BRASERO_TRACK_DATA_CFG (priv->project)))
+ brasero_track_data_cfg_unload_current_medium (BRASERO_TRACK_DATA_CFG (priv->project));
- brasero_status_free (status);
+ if (priv->size_changed_id) {
+ g_source_remove (priv->size_changed_id);
+ priv->size_changed_id = 0;
+ }
- if (priv->loading)
- return BRASERO_DISC_LOADING;
+ if (GTK_WIDGET (disc)->window)
+ gdk_window_set_cursor (GTK_WIDGET (disc)->window, NULL);
- /* This one goes before the next since a node may be loading but not
- * yet in the project and therefore project will look empty */
- return BRASERO_DISC_NOT_READY;
+ /* Hide all toggle actions for session importing */
+ if (gtk_action_group_get_visible (priv->import_group))
+ gtk_action_group_set_visible (priv->import_group, FALSE);
+
+ if (gtk_action_group_get_visible (priv->disc_group))
+ gtk_action_group_set_visible (priv->disc_group, FALSE);
+
+ if (priv->load_errors) {
+ g_slist_foreach (priv->load_errors, (GFunc) g_free , NULL);
+ g_slist_free (priv->load_errors);
+ priv->load_errors = NULL;
}
- brasero_status_free (status);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_2G_file_cb,
+ disc);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_deep_directory_cb,
+ disc);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_name_collision_cb,
+ disc);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_joliet_rename_cb,
+ disc);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_project_loading_cb,
+ disc);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_project_loaded_cb,
+ disc);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_size_changed_cb,
+ disc);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_image_uri_cb,
+ disc);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_unreadable_uri_cb,
+ disc);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_recursive_uri_cb,
+ disc);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_unknown_uri_cb,
+ disc);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_session_available_cb,
+ disc);
+ g_signal_handlers_disconnect_by_func (priv->project,
+ brasero_data_disc_session_loaded_cb,
+ disc);
- if (!gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->project), NULL))
- return BRASERO_DISC_ERROR_EMPTY_SELECTION;
+ g_object_unref (priv->project);
+ priv->project = NULL;
- return BRASERO_DISC_OK;
+ gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree), NULL);
+}
+
+static void
+brasero_data_disc_track_removed (BraseroBurnSession *session,
+ BraseroTrack *track,
+ guint former_position,
+ BraseroDataDisc *disc)
+{
+ g_signal_handlers_disconnect_by_func (session,
+ brasero_data_disc_track_removed,
+ disc);
+
+ brasero_data_disc_unset_track (disc);
+}
+
+static BraseroDiscResult
+brasero_data_disc_set_session_contents (BraseroDisc *self,
+ BraseroBurnSession *session)
+{
+ BraseroBurnResult result = BRASERO_BURN_OK;
+ BraseroDataDiscPrivate *priv;
+ GSList *tracks;
+
+ priv = BRASERO_DATA_DISC_PRIVATE (self);
+
+ brasero_data_disc_unset_track (BRASERO_DATA_DISC (self));
+
+ if (!session)
+ return BRASERO_DISC_OK;
+
+ /* get the track data */
+ tracks = brasero_burn_session_get_tracks (session);
+ if (!tracks) {
+ BraseroTrackDataCfg *data_track;
+
+ /* If it's empty add one */
+ data_track = brasero_track_data_cfg_new ();
+ brasero_burn_session_add_track (session,
+ BRASERO_TRACK (data_track),
+ NULL);
+ brasero_data_disc_set_track (BRASERO_DATA_DISC (self),
+ BRASERO_TRACK_DATA_CFG (data_track));
+ }
+ else for (; tracks; tracks = tracks->next) {
+ BraseroTrack *track;
+
+ track = tracks->data;
+ if (BRASERO_IS_TRACK_DATA_CFG (track))
+ result = brasero_data_disc_set_track (BRASERO_DATA_DISC (self),
+ BRASERO_TRACK_DATA_CFG (track));
+ }
+
+ g_signal_connect (session,
+ "track-removed",
+ G_CALLBACK (brasero_data_disc_track_removed),
+ self);
+
+ return result;
}
static gboolean
@@ -1605,30 +1624,6 @@ brasero_data_disc_add_ui (BraseroDisc *disc,
else
gtk_action_group_set_visible (priv->disc_group, TRUE);
- /* Now let's take care of all the available sessions */
- if (!priv->import_group) {
- GSList *iter;
- GSList *list;
-
- priv->import_group = gtk_action_group_new ("session_import_group");
- gtk_action_group_set_translation_domain (priv->import_group, GETTEXT_PACKAGE);
- gtk_ui_manager_insert_action_group (manager,
- priv->import_group,
- 0);
-
- list = brasero_track_data_cfg_get_available_media (priv->project);
- for (iter = list; iter; iter = iter->next) {
- BraseroMedium *medium;
-
- medium = iter->data;
- brasero_data_disc_import_button_new (BRASERO_DATA_DISC (disc), medium);
- }
- g_slist_foreach (list, (GFunc) g_object_unref, NULL);
- g_slist_free (list);
- }
- else
- gtk_action_group_set_visible (priv->import_group, TRUE);
-
return -1;
}
@@ -2097,44 +2092,9 @@ brasero_data_disc_key_released_cb (GtkTreeView *tree,
}
/**
- *
- */
-
-static void
-brasero_data_disc_contents_added_cb (GtkTreeModel *model,
- GtkTreePath *treepath,
- GtkTreeIter *iter,
- BraseroDataDisc *self)
-{
- brasero_disc_contents_changed (BRASERO_DISC (self), TRUE);
-}
-
-static void
-brasero_data_disc_contents_removed_cb (GtkTreeModel *model,
- GtkTreePath *treepath,
- BraseroDataDisc *self)
-{
- BraseroDataDiscPrivate *priv;
-
- priv = BRASERO_DATA_DISC_PRIVATE (self);
- brasero_disc_contents_changed (BRASERO_DISC (self), gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->project), NULL));
-}
-
-/**
* Misc functions
*/
-gboolean
-brasero_data_disc_set_icon_path (BraseroDataDisc *self,
- const gchar *path,
- GError **error)
-{
- BraseroDataDiscPrivate *priv;
-
- priv = BRASERO_DATA_DISC_PRIVATE (self);
- return brasero_track_data_cfg_set_icon (priv->project, path, error);
-}
-
gchar *
brasero_data_disc_get_scaled_icon_path (BraseroDataDisc *disc)
{
@@ -2151,7 +2111,7 @@ brasero_data_disc_set_right_button_group (BraseroDataDisc *self,
BraseroDataDiscPrivate *priv;
priv = BRASERO_DATA_DISC_PRIVATE (self);
- brasero_file_filtered_set_right_button_group (BRASERO_FILE_FILTERED (priv->filter), size_group);
+ priv->button_size = g_object_ref (size_group);
}
/**
@@ -2171,96 +2131,12 @@ brasero_data_disc_init (BraseroDataDisc *object)
gtk_box_set_spacing (GTK_BOX (object), 8);
- /* the information displayed about how to use this tree */
- priv->notebook = brasero_disc_get_use_info_notebook ();
- gtk_widget_show (priv->notebook);
- gtk_box_pack_start (GTK_BOX (object), priv->notebook, TRUE, TRUE, 0);
-
mainbox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (mainbox);
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), mainbox, NULL);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 0);
-
- priv->project = brasero_track_data_cfg_new ();
-
- g_signal_connect (priv->project,
- "2G-file",
- G_CALLBACK (brasero_data_disc_2G_file_cb),
- object);
- g_signal_connect (priv->project,
- "deep-directory",
- G_CALLBACK (brasero_data_disc_deep_directory_cb),
- object);
- g_signal_connect (priv->project,
- "name-collision",
- G_CALLBACK (brasero_data_disc_name_collision_cb),
- object);
- g_signal_connect (priv->project,
- "joliet-rename",
- G_CALLBACK (brasero_data_disc_joliet_rename_cb),
- object);
-
- g_signal_connect (priv->project,
- "source-loading",
- G_CALLBACK (brasero_data_disc_project_loading_cb),
- object);
- g_signal_connect (priv->project,
- "source-loaded",
- G_CALLBACK (brasero_data_disc_project_loaded_cb),
- object);
-
- /* Use the BraseroTrack "changed" signal for size changes */
- g_signal_connect (priv->project,
- "changed",
- G_CALLBACK (brasero_data_disc_size_changed_cb),
- object);
-
- g_signal_connect (priv->project,
- "row-inserted",
- G_CALLBACK (brasero_data_disc_contents_added_cb),
- object);
- g_signal_connect (priv->project,
- "row-deleted",
- G_CALLBACK (brasero_data_disc_contents_removed_cb),
- object);
-
- g_signal_connect (priv->project,
- "vfs-activity",
- G_CALLBACK (brasero_data_disc_activity_changed_cb),
- object);
- g_signal_connect (priv->project,
- "image-uri",
- G_CALLBACK (brasero_data_disc_image_uri_cb),
- object);
- g_signal_connect (priv->project,
- "unreadable-uri",
- G_CALLBACK (brasero_data_disc_unreadable_uri_cb),
- object);
- g_signal_connect (priv->project,
- "recursive-sym",
- G_CALLBACK (brasero_data_disc_recursive_uri_cb),
- object);
- g_signal_connect (priv->project,
- "unknown-uri",
- G_CALLBACK (brasero_data_disc_unknown_uri_cb),
- object);
-
- g_signal_connect (priv->project,
- "session-available",
- G_CALLBACK (brasero_data_disc_session_available_cb),
- object);
- g_signal_connect (priv->project,
- "session-loaded",
- G_CALLBACK (brasero_data_disc_session_loaded_cb),
- object);
-
- g_signal_connect (priv->project,
- "icon-changed",
- G_CALLBACK (brasero_data_disc_icon_changed_cb),
- object);
+ gtk_box_pack_start (GTK_BOX (object), mainbox, TRUE, TRUE, 0);
/* Tree */
- priv->tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->project));
+ priv->tree = gtk_tree_view_new ();
gtk_tree_view_set_rubber_banding (GTK_TREE_VIEW (priv->tree), TRUE);
/* This must be before connecting to button press event */
@@ -2394,15 +2270,6 @@ brasero_data_disc_init (BraseroDataDisc *object)
ntables_source,
nb_targets_source,
GDK_ACTION_MOVE);
-
- /* filtered files */
- priv->filter = brasero_file_filtered_new (priv->project);
- g_signal_connect (priv->filter,
- "activate",
- G_CALLBACK (brasero_data_disc_filter_expanded_cb),
- object);
- gtk_widget_show (priv->filter);
- gtk_box_pack_end (GTK_BOX (object), priv->filter, FALSE, TRUE, 0);
}
static void
@@ -2412,6 +2279,11 @@ brasero_data_disc_finalize (GObject *object)
priv = BRASERO_DATA_DISC_PRIVATE (object);
+ if (priv->button_size) {
+ g_object_unref (priv->button_size);
+ priv->button_size = NULL;
+ }
+
if (priv->size_changed_id) {
g_source_remove (priv->size_changed_id);
priv->size_changed_id = 0;
@@ -2437,11 +2309,7 @@ brasero_data_disc_iface_disc_init (BraseroDiscIface *iface)
iface->add_uri = brasero_data_disc_add_uri;
iface->delete_selected = brasero_data_disc_delete_selected;
iface->clear = brasero_data_disc_clear;
- iface->reset = brasero_data_disc_reset;
- iface->get_track = brasero_data_disc_get_track;
iface->set_session_contents = brasero_data_disc_set_session_contents;
- iface->load_track = brasero_data_disc_load_track;
- iface->get_status = brasero_data_disc_get_status;
iface->get_selected_uri = brasero_data_disc_get_selected_uri;
iface->add_ui = brasero_data_disc_add_ui;
}
@@ -2496,17 +2364,6 @@ brasero_data_disc_class_init (BraseroDataDiscClass *klass)
object_class->set_property = brasero_data_disc_set_property;
object_class->get_property = brasero_data_disc_get_property;
- brasero_data_disc_signals [ICON_CHANGED] =
- g_signal_new ("icon_changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST|G_SIGNAL_NO_RECURSE,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0,
- G_TYPE_NONE);
-
g_object_class_install_property (object_class,
PROP_REJECT_FILE,
g_param_spec_boolean
diff --git a/src/brasero-data-disc.h b/src/brasero-data-disc.h
index 504273d..b640bb7 100644
--- a/src/brasero-data-disc.h
+++ b/src/brasero-data-disc.h
@@ -56,13 +56,6 @@ GType brasero_data_disc_get_type (void) G_GNUC_CONST;
GtkWidget *
brasero_data_disc_new (void);
-gboolean
-brasero_data_disc_set_icon_path (BraseroDataDisc *disc,
- const gchar *path,
- GError **error);
-gchar *
-brasero_data_disc_get_scaled_icon_path (BraseroDataDisc *disc);
-
void
brasero_data_disc_set_right_button_group (BraseroDataDisc *disc,
GtkSizeGroup *size_group);
diff --git a/src/brasero-disc.c b/src/brasero-disc.c
index 6bed970..7c044e5 100644
--- a/src/brasero-disc.c
+++ b/src/brasero-disc.c
@@ -207,22 +207,6 @@ brasero_disc_get_status (BraseroDisc *disc,
}
BraseroDiscResult
-brasero_disc_get_track (BraseroDisc *disc,
- BraseroDiscTrack *track)
-{
- BraseroDiscIface *iface;
-
- g_return_val_if_fail (BRASERO_IS_DISC (disc), BRASERO_DISC_ERROR_UNKNOWN);
- g_return_val_if_fail (track != NULL, BRASERO_DISC_ERROR_UNKNOWN);
-
- iface = BRASERO_DISC_GET_IFACE (disc);
- if (iface->get_track)
- return (* iface->get_track) (disc, track);
-
- return BRASERO_DISC_ERROR_UNKNOWN;
-}
-
-BraseroDiscResult
brasero_disc_set_session_contents (BraseroDisc *disc,
BraseroBurnSession *session)
{
@@ -237,22 +221,6 @@ brasero_disc_set_session_contents (BraseroDisc *disc,
return BRASERO_DISC_ERROR_UNKNOWN;
}
-BraseroDiscResult
-brasero_disc_load_track (BraseroDisc *disc,
- BraseroDiscTrack *track)
-{
- BraseroDiscIface *iface;
-
- g_return_val_if_fail (BRASERO_IS_DISC (disc), BRASERO_DISC_ERROR_UNKNOWN);
- g_return_val_if_fail (track != NULL, BRASERO_DISC_ERROR_UNKNOWN);
-
- iface = BRASERO_DISC_GET_IFACE (disc);
- if (iface->load_track)
- return (* iface->load_track) (disc, track);
-
- return BRASERO_DISC_ERROR_UNKNOWN;
-}
-
gboolean
brasero_disc_get_selected_uri (BraseroDisc *disc, gchar **uri)
{
@@ -439,7 +407,6 @@ brasero_utils_disc_hide_use_info_drop_cb (GtkWidget *widget,
gboolean return_value = FALSE;
/* The widget must be realized to receive such events. */
- gtk_notebook_set_current_page (notebook, 1);
g_signal_emit_by_name (other_widget,
"drag-drop",
drag_context,
@@ -465,8 +432,6 @@ brasero_utils_disc_hide_use_info_data_received_cb (GtkWidget *widget,
{
GtkWidget *other_widget;
- gtk_notebook_set_current_page (notebook, 1);
-
other_widget = brasero_utils_disc_find_tree_view (notebook);
if (!other_widget)
return;
@@ -570,7 +535,7 @@ brasero_disc_draw_focus_around_help_text (GtkWidget *label,
}
GtkWidget *
-brasero_disc_get_use_info_notebook (void)
+brasero_disc_get_use_info_notebook ()
{
GList *chain;
GtkWidget *frame;
diff --git a/src/brasero-disc.h b/src/brasero-disc.h
index 3305782..4686622 100644
--- a/src/brasero-disc.h
+++ b/src/brasero-disc.h
@@ -84,11 +84,6 @@ struct _BraseroDiscIface {
gint *remaining,
gchar **current_task);
- BraseroDiscResult (*load_track) (BraseroDisc *disc,
- BraseroDiscTrack *track);
- BraseroDiscResult (*get_track) (BraseroDisc *disc,
- BraseroDiscTrack *track);
-
BraseroDiscResult (*set_session_contents) (BraseroDisc *disc,
BraseroBurnSession *session);
@@ -140,13 +135,6 @@ brasero_disc_get_status (BraseroDisc *disc,
gchar **current_task);
BraseroDiscResult
-brasero_disc_get_track (BraseroDisc *disc,
- BraseroDiscTrack *track);
-BraseroDiscResult
-brasero_disc_load_track (BraseroDisc *disc,
- BraseroDiscTrack *track);
-
-BraseroDiscResult
brasero_disc_set_session_contents (BraseroDisc *disc,
BraseroBurnSession *session);
@@ -162,8 +150,4 @@ brasero_disc_contents_changed (BraseroDisc *disc,
void
brasero_disc_selection_changed (BraseroDisc *disc);
-
-GtkWidget *
-brasero_disc_get_use_info_notebook (void);
-
#endif /* DISC_H */
diff --git a/src/brasero-project-manager.c b/src/brasero-project-manager.c
index d181e81..41c7285 100644
--- a/src/brasero-project-manager.c
+++ b/src/brasero-project-manager.c
@@ -748,32 +748,33 @@ brasero_project_manager_iso (BraseroProjectManager *manager,
BraseroProjectType
brasero_project_manager_open_project (BraseroProjectManager *manager,
- BraseroDiscTrack *track,
const gchar *uri,
+ gboolean playlist,
gboolean burn)
{
GtkAction *action;
BraseroProjectType type;
- if (track->type == BRASERO_PROJECT_TYPE_INVALID) {
+ type = brasero_project_open_project (BRASERO_PROJECT (manager->priv->project), uri, playlist);
+ if (type == BRASERO_PROJECT_TYPE_INVALID) {
brasero_project_manager_switch (manager, BRASERO_PROJECT_TYPE_INVALID, NULL, NULL, TRUE);
- return BRASERO_PROJECT_TYPE_INVALID;
+ return type;
}
- brasero_project_manager_switch (manager, track->type, NULL, NULL, FALSE);
- type = brasero_project_open_project (BRASERO_PROJECT (manager->priv->project), track, uri);
- if (type == BRASERO_PROJECT_TYPE_INVALID)
- return type;
+ brasero_project_manager_switch (manager,
+ type,
+ NULL,
+ NULL,
+ FALSE);
if (burn) {
brasero_project_burn (BRASERO_PROJECT (manager->priv->project));
- return track->type;
+ return type;
}
action = gtk_action_group_get_action (manager->priv->action_group, "NewChoose");
gtk_action_set_sensitive (action, TRUE);
-
- return track->type;
+ return type;
}
BraseroProjectType
@@ -784,28 +785,18 @@ brasero_project_manager_open_by_mime (BraseroProjectManager *manager,
/* When our files/description of x-brasero mime type is not properly
* installed, it's returned as application/xml, so check that too. */
if (!strcmp (mime, "application/x-brasero")
- || !strcmp (mime, "application/xml")) {
- BraseroDiscTrack *track = NULL;
-
- if (!brasero_project_open_project_xml (uri, &track, TRUE))
- return BRASERO_PROJECT_TYPE_INVALID;
-
- return brasero_project_manager_open_project (manager, track, uri, FALSE);
- }
+ || !strcmp (mime, "application/xml"))
+ return brasero_project_manager_open_project (manager, uri, FALSE, FALSE);
#ifdef BUILD_PLAYLIST
else if (!strcmp (mime, "audio/x-scpls")
|| !strcmp (mime, "audio/x-ms-asx")
|| !strcmp (mime, "audio/x-mp3-playlist")
- || !strcmp (mime, "audio/x-mpegurl")) {
- BraseroDiscTrack *track = NULL;
+ || !strcmp (mime, "audio/x-mpegurl"))
+ return brasero_project_manager_open_project (manager, uri, TRUE, FALSE);
- if (!brasero_project_open_audio_playlist_project (uri, &track, TRUE))
- return BRASERO_PROJECT_TYPE_INVALID;
- return brasero_project_manager_open_project (manager, track, uri, FALSE);
- }
#endif
else if (!strcmp (mime, "application/x-cd-image")
diff --git a/src/brasero-project-manager.h b/src/brasero-project-manager.h
index d3e891b..4b8c05d 100644
--- a/src/brasero-project-manager.h
+++ b/src/brasero-project-manager.h
@@ -82,8 +82,8 @@ brasero_project_manager_iso (BraseroProjectManager *manager,
BraseroProjectType
brasero_project_manager_open_project (BraseroProjectManager *manager,
- BraseroDiscTrack *track,
const gchar *uri,
+ gboolean playlist,
gboolean burn);
BraseroProjectType
diff --git a/src/brasero-project-name.c b/src/brasero-project-name.c
index bacb91e..714a127 100644
--- a/src/brasero-project-name.c
+++ b/src/brasero-project-name.c
@@ -32,12 +32,17 @@
#include "brasero-medium.h"
#include "brasero-volume.h"
+#include "brasero-session.h"
+#include "brasero-track-data-cfg.h"
+
#include "brasero-project-name.h"
#include "brasero-project-type-chooser.h"
typedef struct _BraseroProjectNamePrivate BraseroProjectNamePrivate;
struct _BraseroProjectNamePrivate
{
+ BraseroBurnSession *session;
+
BraseroProjectType type;
BraseroMedium *medium;
@@ -55,6 +60,170 @@ static guint brasero_project_name_signals [LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (BraseroProjectName, brasero_project_name, GTK_TYPE_ENTRY);
+enum {
+ PROP_0,
+ PROP_SESSION
+};
+
+static void
+brasero_project_name_data_icon_error (BraseroProjectName *project,
+ GError *error)
+{
+ if (error) {
+ brasero_app_alert (brasero_app_get_default (),
+ /* Translators: this is a picture not
+ * a disc image */
+ C_("picture", "Please select another image."),
+ error->message,
+ GTK_MESSAGE_ERROR);
+ }
+ else {
+ brasero_app_alert (brasero_app_get_default (),
+ /* Translators: this is a picture not
+ * a disc image */
+ C_("picture", "Please select another image."),
+ _("Unknown error"),
+ GTK_MESSAGE_ERROR);
+ }
+}
+
+static void
+brasero_project_name_icon_update (BraseroProjectName *self,
+ BraseroTrackDataCfg *track)
+{
+ GError *error = NULL;
+ GdkPixbuf *pixbuf;
+ gchar *icon;
+
+ gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (self),
+ GTK_ENTRY_ICON_PRIMARY,
+ NULL);
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self),
+ GTK_ENTRY_ICON_PRIMARY,
+ NULL);
+
+ icon = brasero_track_data_cfg_get_scaled_icon_path (track);
+ if (!icon) {
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self),
+ GTK_ENTRY_ICON_PRIMARY,
+ "media-optical");
+ return;
+ }
+
+ /* Load and convert the image into a pixbuf */
+ pixbuf = gdk_pixbuf_new_from_file_at_scale (icon,
+ 24,
+ 24,
+ FALSE,
+ &error);
+ g_free (icon);
+
+ if (!pixbuf) {
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self),
+ GTK_ENTRY_ICON_PRIMARY,
+ "media-optical");
+ brasero_project_name_data_icon_error (self, error);
+ g_error_free (error);
+ return;
+ }
+
+ gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (self),
+ GTK_ENTRY_ICON_PRIMARY,
+ pixbuf);
+ g_object_unref (pixbuf);
+}
+
+static void
+brasero_project_name_icon_changed_cb (BraseroTrackDataCfg *track,
+ BraseroProjectName *self)
+{
+ brasero_project_name_icon_update (self, track);
+}
+
+static BraseroTrackDataCfg *
+brasero_project_name_get_track_data_cfg (BraseroProjectName *self)
+{
+ BraseroProjectNamePrivate *priv;
+ GSList *tracks;
+
+ priv = BRASERO_PROJECT_NAME_PRIVATE (self);
+
+ tracks = brasero_burn_session_get_tracks (priv->session);
+ for (; tracks; tracks = tracks->next) {
+ BraseroTrackDataCfg *track;
+
+ track = tracks->data;
+ if (BRASERO_IS_TRACK_DATA_CFG (track))
+ return BRASERO_TRACK_DATA_CFG (track);
+ }
+
+ return NULL;
+}
+
+static void
+brasero_project_name_icon_button_clicked (BraseroProjectName *project,
+ GtkEntryIconPosition position,
+ GdkEvent *event,
+ gpointer NULL_data)
+{
+ BraseroProjectNamePrivate *priv;
+ BraseroTrackDataCfg *track;
+ GtkFileFilter *filter;
+ const gchar *filename;
+ GError *error = NULL;
+ GtkWidget *chooser;
+ gchar *path;
+ gint res;
+
+ priv = BRASERO_PROJECT_NAME_PRIVATE (project);
+
+ track = brasero_project_name_get_track_data_cfg (project);
+ if (!track)
+ return;
+
+ filename = brasero_track_data_cfg_get_icon_path (track);
+
+ chooser = gtk_file_chooser_dialog_new (_("Medium Icon"),
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (project))),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("All files"));
+ gtk_file_filter_add_pattern (filter, "*");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+
+ filter = gtk_file_filter_new ();
+ /* Translators: this is an image, a picture, not a "Disc Image" */
+ gtk_file_filter_set_name (filter, C_("picture", "Image files"));
+ gtk_file_filter_add_mime_type (filter, "image/*");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+
+ if (filename)
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (chooser), filename);
+
+ gtk_widget_show (chooser);
+ res = gtk_dialog_run (GTK_DIALOG (chooser));
+ if (res != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (chooser);
+ return;
+ }
+
+ path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
+ gtk_widget_destroy (chooser);
+
+ /* Get the BraseroTrackDataCfg if any and set the icon */
+ if (!brasero_track_data_cfg_set_icon (track, path, &error)) {
+ if (error) {
+ brasero_project_name_data_icon_error (project, error);
+ g_error_free (error);
+ }
+ }
+ g_free (path);
+}
+
static gchar *
brasero_project_name_truncate_label (const gchar *label)
{
@@ -291,6 +460,11 @@ brasero_project_name_init (BraseroProjectName *object)
priv->label_modified = 0;
g_signal_connect (object,
+ "icon-release",
+ G_CALLBACK (brasero_project_name_icon_button_clicked),
+ NULL);
+
+ g_signal_connect (object,
"insert_text",
G_CALLBACK (brasero_project_name_label_insert_text),
NULL);
@@ -301,6 +475,117 @@ brasero_project_name_init (BraseroProjectName *object)
}
static void
+brasero_project_name_session_changed (BraseroProjectName *self)
+{
+ BraseroTrackType *type;
+ BraseroProjectNamePrivate *priv;
+
+ priv = BRASERO_PROJECT_NAME_PRIVATE (self);
+
+ type = brasero_track_type_new ();
+ brasero_burn_session_get_input_type (priv->session, type);
+ if (brasero_track_type_get_has_data (type)) {
+ BraseroTrackDataCfg *track;
+
+ track = brasero_project_name_get_track_data_cfg (self);
+ if (track) {
+ g_signal_connect (track,
+ "icon-changed",
+ G_CALLBACK (brasero_project_name_icon_changed_cb),
+ self);
+ brasero_project_name_icon_update (self, track);
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (self),
+ GTK_ENTRY_ICON_PRIMARY,
+ _("Select an icon for the disc that will appear in file managers"));
+ }
+ }
+ else {
+ gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (self),
+ GTK_ENTRY_ICON_PRIMARY,
+ NULL);
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self),
+ GTK_ENTRY_ICON_PRIMARY,
+ NULL);
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (self),
+ GTK_ENTRY_ICON_PRIMARY,
+ NULL);
+ }
+
+ brasero_track_type_free (type);
+}
+
+static void
+brasero_project_name_track_added (BraseroBurnSession *session,
+ BraseroTrack *track,
+ BraseroProjectName *self)
+{
+ brasero_project_name_session_changed (self);
+}
+
+static void
+brasero_project_name_track_removed (BraseroBurnSession *session,
+ BraseroTrack *track,
+ guint former_position,
+ BraseroProjectName *self)
+{
+ /* Make sure we don't remain connected */
+ if (BRASERO_IS_TRACK_DATA_CFG (track))
+ g_signal_handlers_disconnect_by_func (track,
+ brasero_project_name_icon_changed_cb,
+ self);
+
+ brasero_project_name_session_changed (self);
+}
+
+static void
+brasero_project_name_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ BraseroProjectNamePrivate *priv;
+
+ priv = BRASERO_PROJECT_NAME_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_SESSION: /* Readable and only writable at creation time */
+ priv->session = g_object_ref (g_value_get_object (value));
+ g_signal_connect (g_value_get_object (value),
+ "track-added",
+ G_CALLBACK (brasero_project_name_track_added),
+ object);
+ g_signal_connect (g_value_get_object (value),
+ "track-removed",
+ G_CALLBACK (brasero_project_name_track_removed),
+ object);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+brasero_project_name_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ BraseroProjectNamePrivate *priv;
+
+ priv = BRASERO_PROJECT_NAME_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_SESSION:
+ g_value_set_object (value, G_OBJECT (priv->session));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
brasero_project_name_finalize (GObject *object)
{
BraseroProjectNamePrivate *priv;
@@ -322,6 +607,9 @@ brasero_project_name_class_init (BraseroProjectNameClass *klass)
g_type_class_add_private (klass, sizeof (BraseroProjectNamePrivate));
object_class->finalize = brasero_project_name_finalize;
+ object_class->set_property = brasero_project_name_set_property;
+ object_class->get_property = brasero_project_name_get_property;
+
brasero_project_name_signals [CHANGED_SIGNAL] =
g_signal_new ("name_changed",
BRASERO_TYPE_PROJECT_NAME,
@@ -332,11 +620,21 @@ brasero_project_name_class_init (BraseroProjectNameClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+
+ g_object_class_install_property (object_class,
+ PROP_SESSION,
+ g_param_spec_object ("session",
+ "The session",
+ "The session to work with",
+ BRASERO_TYPE_BURN_SESSION,
+ G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
}
GtkWidget *
-brasero_project_name_new (void)
+brasero_project_name_new (BraseroBurnSession *session)
{
- return g_object_new (BRASERO_TYPE_PROJECT_NAME, NULL);
+ return g_object_new (BRASERO_TYPE_PROJECT_NAME,
+ "session", session,
+ NULL);
}
diff --git a/src/brasero-project-name.h b/src/brasero-project-name.h
index 53dab48..720feb2 100644
--- a/src/brasero-project-name.h
+++ b/src/brasero-project-name.h
@@ -24,6 +24,8 @@
#include <gtk/gtk.h>
+#include "brasero-session.h"
+
#include "brasero-project-type-chooser.h"
G_BEGIN_DECLS
@@ -51,7 +53,7 @@ struct _BraseroProjectName
GType brasero_project_name_get_type (void) G_GNUC_CONST;
GtkWidget *
-brasero_project_name_new (void);
+brasero_project_name_new (BraseroBurnSession *session);
void
brasero_project_name_set_type (BraseroProjectName *self,
diff --git a/src/brasero-project-parse.c b/src/brasero-project-parse.c
index f3e9b34..9f4eaff 100644
--- a/src/brasero-project-parse.c
+++ b/src/brasero-project-parse.c
@@ -45,92 +45,13 @@
#include "brasero-project-parse.h"
#include "brasero-app.h"
-#include "brasero-track-stream.h"
-#include "brasero-track-data.h"
+#include "brasero-units.h"
+#include "brasero-track-stream-cfg.h"
+#include "brasero-track-data-cfg.h"
+#include "brasero-session.h"
+#include "brasero-tags.h"
-void
-brasero_stream_info_free (BraseroStreamInfo *info)
-{
- if (!info)
- return;
-
- g_free (info->title);
- g_free (info->artist);
- g_free (info->composer);
- g_free (info);
-}
-
-BraseroStreamInfo *
-brasero_stream_info_copy (BraseroStreamInfo *info)
-{
- BraseroStreamInfo *copy;
-
- if (!info)
- return NULL;
-
- copy = g_new0 (BraseroStreamInfo, 1);
-
- copy->title = g_strdup (info->title);
- copy->artist = g_strdup (info->artist);
- copy->composer = g_strdup (info->composer);
- copy->isrc = info->isrc;
-
- return copy;
-}
-
-static void
-brasero_track_clear_song (gpointer data)
-{
- BraseroDiscSong *song;
-
- song = data;
-
- if (song->info)
- brasero_stream_info_free (song->info);
-
- g_free (song->uri);
- g_free (song);
-}
-
-void
-brasero_track_clear (BraseroDiscTrack *track)
-{
- if (!track)
- return;
-
- if (track->label) {
- g_free (track->label);
- track->label = NULL;
- }
-
- if (track->cover) {
- g_free (track->cover);
- track->cover = NULL;
- }
-
- if (track->type == BRASERO_PROJECT_TYPE_AUDIO) {
- g_slist_foreach (track->contents.tracks, (GFunc) brasero_track_clear_song, NULL);
- g_slist_free (track->contents.tracks);
- }
- else if (track->type == BRASERO_PROJECT_TYPE_DATA) {
- g_free (track->contents.data.icon);
- track->contents.data.icon = NULL;
-
- g_slist_foreach (track->contents.data.grafts, (GFunc) brasero_graft_point_free, NULL);
- g_slist_free (track->contents.data.grafts);
- g_slist_foreach (track->contents.data.restored, (GFunc) g_free, NULL);
- g_slist_free (track->contents.data.restored);
- g_slist_foreach (track->contents.data.excluded, (GFunc) g_free, NULL);
- g_slist_free (track->contents.data.excluded);
- }
-}
-
-void
-brasero_track_free (BraseroDiscTrack *track)
-{
- brasero_track_clear (track);
- g_free (track);
-}
+#define BRASERO_PROJECT_VERSION "0.2"
static void
brasero_project_invalid_project_dialog (const char *reason)
@@ -141,14 +62,15 @@ brasero_project_invalid_project_dialog (const char *reason)
GTK_MESSAGE_ERROR);
}
-static gboolean
+static GSList *
_read_graft_point (xmlDocPtr project,
xmlNodePtr graft,
- BraseroDiscTrack *track)
+ GSList *grafts)
{
BraseroGraftPt *retval;
retval = g_new0 (BraseroGraftPt, 1);
+ grafts = g_slist_prepend (grafts, retval);
while (graft) {
if (!xmlStrcmp (graft->name, (const xmlChar *) "uri")) {
xmlChar *uri;
@@ -174,45 +96,35 @@ _read_graft_point (xmlDocPtr project,
if (!retval->path)
goto error;
}
- else if (!xmlStrcmp (graft->name, (const xmlChar *) "excluded")) {
- xmlChar *excluded;
-
- excluded = xmlNodeListGetString (project,
- graft->xmlChildrenNode,
- 1);
- if (!excluded)
- goto error;
-
- track->contents.data.excluded = g_slist_prepend (track->contents.data.excluded,
- xmlURIUnescapeString ((char*) excluded, 0, NULL));
- g_free (excluded);
- }
else if (graft->type == XML_ELEMENT_NODE)
goto error;
graft = graft->next;
}
- track->contents.data.grafts = g_slist_prepend (track->contents.data.grafts, retval);
- return TRUE;
+ return grafts;
error:
- brasero_graft_point_free (retval);
- return FALSE;
+
+ g_slist_foreach (grafts, (GFunc) brasero_graft_point_free, NULL);
+ g_slist_free (grafts);
+
+ return NULL;
}
-static BraseroDiscTrack *
+static BraseroTrack *
_read_data_track (xmlDocPtr project,
xmlNodePtr item)
{
- BraseroDiscTrack *track;
+ BraseroTrackDataCfg *track;
+ GSList *grafts= NULL;
+ GSList *excluded = NULL;
- track = g_new0 (BraseroDiscTrack, 1);
- track->type = BRASERO_PROJECT_TYPE_DATA;
+ track = brasero_track_data_cfg_new ();
while (item) {
if (!xmlStrcmp (item->name, (const xmlChar *) "graft")) {
- if (!_read_graft_point (project, item->xmlChildrenNode, track))
+ if (!(grafts = _read_graft_point (project, item->xmlChildrenNode, grafts)))
goto error;
}
else if (!xmlStrcmp (item->name, (const xmlChar *) "icon")) {
@@ -224,10 +136,8 @@ _read_data_track (xmlDocPtr project,
if (!icon_path)
goto error;
- if (track->contents.data.icon)
- g_free (track->contents.data.icon);
-
- track->contents.data.icon = (gchar *) icon_path;
+ brasero_track_data_cfg_set_icon (track, (gchar *) icon_path, NULL);
+ g_free (icon_path);
}
else if (!xmlStrcmp (item->name, (const xmlChar *) "restored")) {
xmlChar *restored;
@@ -238,20 +148,20 @@ _read_data_track (xmlDocPtr project,
if (!restored)
goto error;
- track->contents.data.restored = g_slist_prepend (track->contents.data.restored, restored);
+ brasero_track_data_cfg_dont_filter_uri (track, (gchar *) restored);
+ g_free (restored);
}
else if (!xmlStrcmp (item->name, (const xmlChar *) "excluded")) {
- xmlChar *excluded;
+ xmlChar *excluded_uri;
- excluded = xmlNodeListGetString (project,
- item->xmlChildrenNode,
- 1);
- if (!excluded)
+ excluded_uri = xmlNodeListGetString (project,
+ item->xmlChildrenNode,
+ 1);
+ if (!excluded_uri)
goto error;
- track->contents.data.excluded = g_slist_prepend (track->contents.data.excluded,
- xmlURIUnescapeString ((char*) excluded, 0, NULL));
- g_free (excluded);
+ excluded = g_slist_prepend (excluded, xmlURIUnescapeString ((char*) excluded_uri, 0, NULL));
+ g_free (excluded_uri);
}
else if (item->type == XML_ELEMENT_NODE)
goto error;
@@ -259,28 +169,38 @@ _read_data_track (xmlDocPtr project,
item = item->next;
}
- track->contents.data.excluded = g_slist_reverse (track->contents.data.excluded);
- track->contents.data.grafts = g_slist_reverse (track->contents.data.grafts);
- return track;
+ grafts = g_slist_reverse (grafts);
+ excluded = g_slist_reverse (excluded);
+ brasero_track_data_set_source (BRASERO_TRACK_DATA (track),
+ grafts,
+ excluded);
+ return BRASERO_TRACK (track);
error:
- brasero_track_free (track);
+
+ g_slist_foreach (grafts, (GFunc) brasero_graft_point_free, NULL);
+ g_slist_free (grafts);
+
+ g_slist_foreach (excluded, (GFunc) g_free, NULL);
+ g_slist_free (excluded);
+
+ g_object_unref (track);
+
return NULL;
}
-static BraseroDiscTrack *
+static BraseroTrack *
_read_audio_track (xmlDocPtr project,
xmlNodePtr uris)
{
- BraseroDiscTrack *track;
- BraseroDiscSong *song;
+ BraseroTrackStreamCfg *track;
- track = g_new0 (BraseroDiscTrack, 1);
- song = NULL;
+ track = brasero_track_stream_cfg_new ();
while (uris) {
if (!xmlStrcmp (uris->name, (const xmlChar *) "uri")) {
xmlChar *uri;
+ gchar *unescaped_uri;
uri = xmlNodeListGetString (project,
uris->xmlChildrenNode,
@@ -288,23 +208,17 @@ _read_audio_track (xmlDocPtr project,
if (!uri)
goto error;
- song = g_new0 (BraseroDiscSong, 1);
- song->uri = g_uri_unescape_string ((char *) uri, NULL);
+ unescaped_uri = g_uri_unescape_string ((char *) uri, NULL);
+ g_free (uri);
- /* to know if this info was set or not */
- song->start = -1;
- song->end = -1;
- g_free (uri);
- track->contents.tracks = g_slist_prepend (track->contents.tracks, song);
+ brasero_track_stream_set_source (BRASERO_TRACK_STREAM (track), unescaped_uri);
+ g_free (unescaped_uri);
}
else if (!xmlStrcmp (uris->name, (const xmlChar *) "silence")) {
gchar *silence;
- if (!song)
- goto error;
-
/* impossible to have two gaps in a row */
- if (song->gap)
+ if (brasero_track_stream_get_gap (BRASERO_TRACK_STREAM (track)) > 0)
goto error;
silence = (gchar *) xmlNodeListGetString (project,
@@ -313,41 +227,45 @@ _read_audio_track (xmlDocPtr project,
if (!silence)
goto error;
- song->gap = (gint64) g_ascii_strtoull (silence, NULL, 10);
+ brasero_track_stream_set_boundaries (BRASERO_TRACK_STREAM (track),
+ -1,
+ -1,
+ g_ascii_strtoull (silence, NULL, 10));
g_free (silence);
}
else if (!xmlStrcmp (uris->name, (const xmlChar *) "start")) {
gchar *start;
- if (!song)
- goto error;
-
start = (gchar *) xmlNodeListGetString (project,
uris->xmlChildrenNode,
1);
if (!start)
goto error;
- song->start = (gint64) g_ascii_strtoull (start, NULL, 10);
+ brasero_track_stream_set_boundaries (BRASERO_TRACK_STREAM (track),
+ -1,
+ g_ascii_strtoull (start, NULL, 10),
+ -1);
g_free (start);
}
else if (!xmlStrcmp (uris->name, (const xmlChar *) "end")) {
gchar *end;
- if (!song)
- goto error;
-
end = (gchar *) xmlNodeListGetString (project,
uris->xmlChildrenNode,
1);
if (!end)
goto error;
- song->end = (gint64) g_ascii_strtoull (end, NULL, 10);
+ brasero_track_stream_set_boundaries (BRASERO_TRACK_STREAM (track),
+ g_ascii_strtoull (end, NULL, 10),
+ -1,
+ -1);
g_free (end);
}
else if (!xmlStrcmp (uris->name, (const xmlChar *) "title")) {
xmlChar *title;
+ gchar *unescaped_title;
title = xmlNodeListGetString (project,
uris->xmlChildrenNode,
@@ -355,17 +273,17 @@ _read_audio_track (xmlDocPtr project,
if (!title)
goto error;
- if (!song->info)
- song->info = g_new0 (BraseroStreamInfo, 1);
-
- if (song->info->title)
- g_free (song->info->title);
+ unescaped_title = g_uri_unescape_string ((char *) title, NULL);
+ g_free (title);
- song->info->title = g_uri_unescape_string ((char *) title, NULL);
- g_free (title);
+ brasero_track_tag_add_string (BRASERO_TRACK (track),
+ BRASERO_TRACK_STREAM_TITLE_TAG,
+ unescaped_title);
+ g_free (unescaped_title);
}
else if (!xmlStrcmp (uris->name, (const xmlChar *) "artist")) {
xmlChar *artist;
+ gchar *unescaped_artist;
artist = xmlNodeListGetString (project,
uris->xmlChildrenNode,
@@ -373,17 +291,17 @@ _read_audio_track (xmlDocPtr project,
if (!artist)
goto error;
- if (!song->info)
- song->info = g_new0 (BraseroStreamInfo, 1);
-
- if (song->info->artist)
- g_free (song->info->artist);
-
- song->info->artist = g_uri_unescape_string ((char *) artist, NULL);
+ unescaped_artist = g_uri_unescape_string ((char *) artist, NULL);
g_free (artist);
+
+ brasero_track_tag_add_string (BRASERO_TRACK (track),
+ BRASERO_TRACK_STREAM_ARTIST_TAG,
+ unescaped_artist);
+ g_free (unescaped_artist);
}
else if (!xmlStrcmp (uris->name, (const xmlChar *) "composer")) {
xmlChar *composer;
+ gchar *unescaped_composer;
composer = xmlNodeListGetString (project,
uris->xmlChildrenNode,
@@ -391,14 +309,13 @@ _read_audio_track (xmlDocPtr project,
if (!composer)
goto error;
- if (!song->info)
- song->info = g_new0 (BraseroStreamInfo, 1);
-
- if (song->info->composer)
- g_free (song->info->composer);
-
- song->info->composer = g_uri_unescape_string ((char *) composer, NULL);
+ unescaped_composer = g_uri_unescape_string ((char *) composer, NULL);
g_free (composer);
+
+ brasero_track_tag_add_string (BRASERO_TRACK (track),
+ BRASERO_TRACK_STREAM_COMPOSER_TAG,
+ unescaped_composer);
+ g_free (unescaped_composer);
}
else if (!xmlStrcmp (uris->name, (const xmlChar *) "isrc")) {
gchar *isrc;
@@ -409,10 +326,9 @@ _read_audio_track (xmlDocPtr project,
if (!isrc)
goto error;
- if (!song->info)
- song->info = g_new0 (BraseroStreamInfo, 1);
-
- song->info->isrc = (gint) g_ascii_strtod (isrc, NULL);
+ brasero_track_tag_add_int (BRASERO_TRACK (track),
+ BRASERO_TRACK_STREAM_ISRC_TAG,
+ (gint) g_ascii_strtod (isrc, NULL));
g_free (isrc);
}
else if (uris->type == XML_ELEMENT_NODE)
@@ -421,57 +337,50 @@ _read_audio_track (xmlDocPtr project,
uris = uris->next;
}
- track->contents.tracks = g_slist_reverse (track->contents.tracks);
- return (BraseroDiscTrack*) track;
+ return BRASERO_TRACK (track);
error:
- brasero_track_free ((BraseroDiscTrack *) track);
+
+ g_object_unref (track);
+
return NULL;
}
static gboolean
_get_tracks (xmlDocPtr project,
xmlNodePtr track_node,
- BraseroDiscTrack **track)
+ BraseroBurnSession *session)
{
- BraseroDiscTrack *newtrack;
+ GSList *tracks = NULL;
+ GSList *iter;
track_node = track_node->xmlChildrenNode;
- newtrack = NULL;
while (track_node) {
- if (!xmlStrcmp (track_node->name, (const xmlChar *) "audio")) {
- if (newtrack)
- goto error;
+ BraseroTrack *newtrack;
- newtrack = _read_audio_track (project,
- track_node->xmlChildrenNode);
+ if (!xmlStrcmp (track_node->name, (const xmlChar *) "audio")) {
+ newtrack = _read_audio_track (project, track_node->xmlChildrenNode);
if (!newtrack)
goto error;
- newtrack->type = BRASERO_PROJECT_TYPE_AUDIO;
+ tracks = g_slist_append (tracks, newtrack);
}
else if (!xmlStrcmp (track_node->name, (const xmlChar *) "data")) {
- if (newtrack)
- goto error;
-
- newtrack = _read_data_track (project,
- track_node->xmlChildrenNode);
+ newtrack = _read_data_track (project, track_node->xmlChildrenNode);
if (!newtrack)
goto error;
+
+ tracks = g_slist_append (tracks, newtrack);
}
else if (!xmlStrcmp (track_node->name, (const xmlChar *) "video")) {
- if (newtrack)
- goto error;
-
- newtrack = _read_audio_track (project,
- track_node->xmlChildrenNode);
+ newtrack = _read_audio_track (project, track_node->xmlChildrenNode);
if (!newtrack)
goto error;
- newtrack->type = BRASERO_PROJECT_TYPE_VIDEO;
+ tracks = g_slist_append (tracks, newtrack);
}
else if (track_node->type == XML_ELEMENT_NODE)
goto error;
@@ -479,23 +388,33 @@ _get_tracks (xmlDocPtr project,
track_node = track_node->next;
}
- if (!newtrack)
+ if (!tracks)
goto error;
- *track = newtrack;
+ for (iter = tracks; iter; iter = iter->next) {
+ BraseroTrack *newtrack;
+
+ newtrack = tracks->data;
+ brasero_burn_session_add_track (session, newtrack, NULL);
+ }
+
+ g_slist_free (tracks);
+
return TRUE;
error :
- if (newtrack)
- brasero_track_free (newtrack);
- brasero_track_free (newtrack);
+ if (tracks) {
+ g_slist_foreach (tracks, (GFunc) g_object_unref, NULL);
+ g_slist_free (tracks);
+ }
+
return FALSE;
}
gboolean
brasero_project_open_project_xml (const gchar *uri,
- BraseroDiscTrack **track,
+ BraseroBurnSession *session,
gboolean warn_user)
{
xmlNodePtr track_node = NULL;
@@ -571,18 +490,29 @@ brasero_project_open_project_xml (const gchar *uri,
item = item->next;
}
- retval = _get_tracks (project, track_node, track);
+ retval = _get_tracks (project, track_node, session);
if (!retval)
goto error;
xmlFreeDoc (project);
- if (track && *track) {
- (*track)->label = label;
- (*track)->cover = cover;
- }
+ brasero_burn_session_set_label (session, label);
+ g_free (label);
+
+ if (cover) {
+ GValue *value;
- return retval;
+ value = g_new0 (GValue, 1);
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, cover);
+ brasero_burn_session_tag_add (session,
+ BRASERO_COVER_URI,
+ value);
+
+ g_free (cover);
+ }
+
+ return retval;
error:
@@ -606,12 +536,9 @@ brasero_project_playlist_playlist_started (TotemPlParser *parser,
GHashTable *metadata,
gpointer user_data)
{
- gchar *string;
- gchar **retval = user_data;
+ BraseroBurnSession *session = user_data;
- string = g_hash_table_lookup (metadata, TOTEM_PL_PARSER_FIELD_TITLE);
- if (string)
- *retval = g_strdup (string);
+ brasero_burn_session_set_label (session, g_hash_table_lookup (metadata, TOTEM_PL_PARSER_FIELD_TITLE));
}
static void
@@ -620,30 +547,21 @@ brasero_project_playlist_entry_parsed (TotemPlParser *parser,
GHashTable *metadata,
gpointer user_data)
{
- BraseroDiscTrack *track = user_data;
- BraseroDiscSong *song;
+ BraseroBurnSession *session = user_data;
+ BraseroTrackStreamCfg *track;
- song = g_new0 (BraseroDiscSong, 1);
- song->uri = g_strdup (uri);
-
- /* to know if this info was set or not */
- song->start = -1;
- song->end = -1;
- track->contents.tracks = g_slist_prepend (track->contents.tracks, song);
+ track = brasero_track_stream_cfg_new ();
+ brasero_track_stream_set_source (BRASERO_TRACK_STREAM (track), uri);
+ brasero_burn_session_add_track (session, BRASERO_TRACK (track), NULL);
}
gboolean
brasero_project_open_audio_playlist_project (const gchar *uri,
- BraseroDiscTrack **track,
+ BraseroBurnSession *session,
gboolean warn_user)
{
- gchar *label = NULL;
TotemPlParser *parser;
TotemPlParserResult result;
- BraseroDiscTrack *new_track;
-
- new_track = g_new0 (BraseroDiscTrack, 1);
- new_track->type = BRASERO_PROJECT_TYPE_AUDIO;
parser = totem_pl_parser_new ();
g_object_set (parser,
@@ -654,30 +572,550 @@ brasero_project_open_audio_playlist_project (const gchar *uri,
g_signal_connect (parser,
"playlist-started",
G_CALLBACK (brasero_project_playlist_playlist_started),
- &label);
+ session);
g_signal_connect (parser,
"entry-parsed",
G_CALLBACK (brasero_project_playlist_entry_parsed),
- new_track);
+ session);
result = totem_pl_parser_parse (parser, uri, FALSE);
if (result != TOTEM_PL_PARSER_RESULT_SUCCESS) {
if (warn_user)
brasero_project_invalid_project_dialog (_("It does not seem to be a valid Brasero project."));
+ }
+
+ g_object_unref (parser);
+
+ return (result == TOTEM_PL_PARSER_RESULT_SUCCESS);
+}
+
+#endif
+
+/**
+ * Project saving
+ */
+
+static gboolean
+_save_audio_track_xml (xmlTextWriter *project,
+ BraseroTrackStream *track)
+{
+ xmlChar *escaped;
+ gchar *start;
+ gint success;
+ gchar *isrc;
+ gchar *uri;
+ gchar *end;
+
+ uri = brasero_track_stream_get_source (track, TRUE);
+ escaped = (unsigned char *) g_uri_escape_string (uri, NULL, FALSE);
+ g_free (uri);
+
+ success = xmlTextWriterWriteElement (project,
+ (xmlChar *) "uri",
+ escaped);
+ g_free (escaped);
+
+ if (success == -1)
+ return FALSE;
+
+ if (brasero_track_stream_get_gap (track) > 0) {
+ gchar *silence;
+
+ silence = g_strdup_printf ("%"G_GINT64_FORMAT, brasero_track_stream_get_gap (track));
+ success = xmlTextWriterWriteElement (project,
+ (xmlChar *) "silence",
+ (xmlChar *) silence);
+
+ g_free (silence);
+ if (success == -1)
+ return FALSE;
+ }
+
+ if (brasero_track_stream_get_end (track) > 0) {
+ /* start of the song */
+ start = g_strdup_printf ("%"G_GINT64_FORMAT, brasero_track_stream_get_start (track));
+ success = xmlTextWriterWriteElement (project,
+ (xmlChar *) "start",
+ (xmlChar *) start);
+
+ g_free (start);
+ if (success == -1)
+ return FALSE;
+
+ /* end of the song */
+ end = g_strdup_printf ("%"G_GINT64_FORMAT, brasero_track_stream_get_end (track));
+ success = xmlTextWriterWriteElement (project,
+ (xmlChar *) "end",
+ (xmlChar *) end);
+
+ g_free (end);
+ if (success == -1)
+ return FALSE;
+ }
+
+ if (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_TITLE_TAG)) {
+ escaped = (unsigned char *) g_uri_escape_string (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_TITLE_TAG), NULL, FALSE);
+ success = xmlTextWriterWriteElement (project,
+ (xmlChar *) "title",
+ escaped);
+ g_free (escaped);
+
+ if (success == -1)
+ return FALSE;
+ }
+
+ if (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ARTIST_TAG)) {
+ escaped = (unsigned char *) g_uri_escape_string (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ARTIST_TAG), NULL, FALSE);
+ success = xmlTextWriterWriteElement (project,
+ (xmlChar *) "artist",
+ escaped);
+ g_free (escaped);
+
+ if (success == -1)
+ return FALSE;
+ }
+
+ if (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_COMPOSER_TAG)) {
+ escaped = (unsigned char *) g_uri_escape_string (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_COMPOSER_TAG), NULL, FALSE);
+ success = xmlTextWriterWriteElement (project,
+ (xmlChar *) "composer",
+ escaped);
+ g_free (escaped);
+ if (success == -1)
+ return FALSE;
+ }
+
+ if (brasero_track_tag_lookup_int (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ISRC_TAG)) {
+ isrc = g_strdup_printf ("%d", brasero_track_tag_lookup_int (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ISRC_TAG));
+ success = xmlTextWriterWriteElement (project,
+ (xmlChar *) "isrc",
+ (xmlChar *) isrc);
+
+ g_free (isrc);
+ if (success == -1)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+_save_data_track_xml (xmlTextWriter *project,
+ BraseroBurnSession *session)
+{
+ gchar *uri;
+ gint success;
+ GSList *iter;
+ GSList *tracks;
+ GSList *grafts;
+ BraseroTrackDataCfg *track;
+
+ tracks = brasero_burn_session_get_tracks (session);
+ track = BRASERO_TRACK_DATA_CFG (tracks->data);
+
+ if (brasero_track_data_cfg_get_icon_path (track)) {
+ /* Write the icon if any */
+ success = xmlTextWriterWriteElement (project, (xmlChar *) "icon", (xmlChar *) brasero_track_data_cfg_get_icon_path (track));
+ if (success < 0)
+ return FALSE;
+ }
+
+ grafts = brasero_track_data_get_grafts (BRASERO_TRACK_DATA (track));
+ for (; grafts; grafts = grafts->next) {
+ BraseroGraftPt *graft;
+
+ graft = grafts->data;
+
+ success = xmlTextWriterStartElement (project, (xmlChar *) "graft");
+ if (success < 0)
+ return FALSE;
+
+ success = xmlTextWriterWriteElement (project, (xmlChar *) "path", (xmlChar *) graft->path);
+ if (success < 0)
+ return FALSE;
+
+ if (graft->uri) {
+ xmlChar *escaped;
+
+ escaped = (unsigned char *) g_uri_escape_string (graft->uri, NULL, FALSE);
+ success = xmlTextWriterWriteElement (project, (xmlChar *) "uri", escaped);
+ g_free (escaped);
+ if (success < 0)
+ return FALSE;
+ }
+
+ success = xmlTextWriterEndElement (project); /* graft */
+ if (success < 0)
+ return FALSE;
+ }
+
+ /* save excluded uris */
+ iter = brasero_track_data_get_excluded (BRASERO_TRACK_DATA (track), FALSE);
+ for (; iter; iter = iter->next) {
+ xmlChar *escaped;
- brasero_track_free (new_track);
+ escaped = xmlURIEscapeStr ((xmlChar *) iter->data, NULL);
+ success = xmlTextWriterWriteElement (project, (xmlChar *) "excluded", (xmlChar *) escaped);
+ g_free (escaped);
+ if (success < 0)
+ return FALSE;
}
- else {
- if (new_track && label)
- new_track->label = label;
- *track = new_track;
+ /* save restored uris */
+ iter = brasero_track_data_cfg_get_restored_list (track);
+ for (; iter; iter = iter->next) {
+ uri = iter->data;
+ success = xmlTextWriterWriteElement (project, (xmlChar *) "restored", (xmlChar *) uri);
+ if (success < 0)
+ return FALSE;
}
+ /* NOTE: we don't write symlinks and unreadable they are useless */
+ return TRUE;
+}
+
+gboolean
+brasero_project_save_project_xml (BraseroBurnSession *session,
+ const gchar *uri)
+{
+ BraseroTrackType *track_type = NULL;
+ xmlTextWriter *project;
+ gboolean retval;
+ GSList *tracks;
+ GValue *value;
+ gint success;
+ gchar *path;
+
+ path = g_filename_from_uri (uri, NULL, NULL);
+ if (!path)
+ return FALSE;
+
+ project = xmlNewTextWriterFilename (path, 0);
+ if (!project) {
+ g_free (path);
+ return FALSE;
+ }
+
+ xmlTextWriterSetIndent (project, 1);
+ xmlTextWriterSetIndentString (project, (xmlChar *) "\t");
+
+ success = xmlTextWriterStartDocument (project,
+ NULL,
+ "UTF8",
+ NULL);
+ if (success < 0)
+ goto error;
+
+ success = xmlTextWriterStartElement (project, (xmlChar *) "braseroproject");
+ if (success < 0)
+ goto error;
+
+ /* write the name of the version */
+ success = xmlTextWriterWriteElement (project,
+ (xmlChar *) "version",
+ (xmlChar *) BRASERO_PROJECT_VERSION);
+ if (success < 0)
+ goto error;
+
+ if (brasero_burn_session_get_label (session)) {
+ success = xmlTextWriterWriteElement (project,
+ (xmlChar *) "label",
+ (xmlChar *) brasero_burn_session_get_label (session));
+
+ if (success < 0)
+ goto error;
+ }
+
+ value = NULL;
+ brasero_burn_session_tag_lookup (session,
+ BRASERO_COVER_URI,
+ &value);
+ if (value) {
+ gchar *escaped;
+
+ escaped = g_uri_escape_string (g_value_get_string (value), NULL, FALSE);
+ success = xmlTextWriterWriteElement (project,
+ (xmlChar *) "cover",
+ (xmlChar *) escaped);
+ g_free (escaped);
+
+ if (success < 0)
+ goto error;
+ }
+
+ success = xmlTextWriterStartElement (project, (xmlChar *) "track");
+ if (success < 0)
+ goto error;
+
+ track_type = brasero_track_type_new ();
+ tracks = brasero_burn_session_get_tracks (session);
+
+ for (; tracks; tracks = tracks->next) {
+ BraseroTrack *track;
+
+ track = tracks->data;
+
+ brasero_track_get_track_type (track, track_type);
+ if (brasero_track_type_get_has_stream (track_type)) {
+ if (BRASERO_STREAM_FORMAT_HAS_VIDEO (brasero_track_type_get_stream_format (track_type)))
+ success = xmlTextWriterStartElement (project, (xmlChar *) "video");
+ else
+ success = xmlTextWriterStartElement (project, (xmlChar *) "audio");
+
+ if (success < 0)
+ goto error;
+
+ retval = _save_audio_track_xml (project, BRASERO_TRACK_STREAM (track));
+ if (!retval)
+ goto error;
+
+ success = xmlTextWriterEndElement (project); /* audio/video */
+ if (success < 0)
+ goto error;
+ }
+ else if (brasero_track_type_get_has_data (track_type)) {
+ success = xmlTextWriterStartElement (project, (xmlChar *) "data");
+ if (success < 0)
+ goto error;
+
+ retval = _save_data_track_xml (project, session);
+ if (!retval)
+ goto error;
+
+ success = xmlTextWriterEndElement (project); /* data */
+ if (success < 0)
+ goto error;
+ }
+ else
+ retval = FALSE;
+ }
+
+ success = xmlTextWriterEndElement (project); /* track */
+ if (success < 0)
+ goto error;
+
+ brasero_track_type_free (track_type);
+
+ success = xmlTextWriterEndElement (project); /* braseroproject */
+ if (success < 0)
+ goto error;
+
+ xmlTextWriterEndDocument (project);
+ xmlFreeTextWriter (project);
+ g_free (path);
+ return TRUE;
+
+error:
+
+ if (track_type)
+ brasero_track_type_free (track_type);
+
+ xmlTextWriterEndDocument (project);
+ xmlFreeTextWriter (project);
+
+ g_remove (path);
+ g_free (path);
+
+ return FALSE;
+}
+
+gboolean
+brasero_project_save_audio_project_plain_text (BraseroBurnSession *session,
+ const gchar *uri)
+{
+ const gchar *title;
+ guint written;
+ GSList *iter;
+ gchar *path;
+ FILE *file;
+
+ path = g_filename_from_uri (uri, NULL, NULL);
+ if (!path)
+ return FALSE;
+
+ file = fopen (path, "w+");
+ g_free (path);
+ if (!file)
+ return FALSE;
+
+ /* write title */
+ title = brasero_burn_session_get_label (session);
+ written = fwrite (title, strlen (title), 1, file);
+ if (written != 1)
+ goto error;
+
+ written = fwrite ("\n", 1, 1, file);
+ if (written != 1)
+ goto error;
+
+ iter = brasero_burn_session_get_tracks (session);
+ for (; iter; iter = iter->next) {
+ BraseroTrackStream *track;
+ const gchar *text;
+ gchar *time;
+ guint64 len;
+ gchar *uri;
+
+ track = iter->data;
+
+ text = brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_TITLE_TAG);
+ written = fwrite (title, 1, strlen (title), file);
+ if (written != strlen (title))
+ goto error;
+
+ len = 0;
+ brasero_track_stream_get_length (track, &len);
+ time = brasero_units_get_time_string (len, TRUE, FALSE);
+ if (time) {
+ written = fwrite ("\t", 1, 1, file);
+ if (written != 1)
+ goto error;
+
+ written = fwrite (time, 1, strlen (time), file);
+ if (written != strlen (time)) {
+ g_free (time);
+ goto error;
+ }
+ g_free (time);
+ }
+
+ text = brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ARTIST_TAG);
+ if (text) {
+ gchar *string;
+
+ written = fwrite ("\t", 1, 1, file);
+ if (written != 1)
+ goto error;
+
+ /* Translators: %s is an artist */
+ string = g_strdup_printf (" by %s", text);
+ written = fwrite (string, 1, strlen (string), file);
+ if (written != strlen (string)) {
+ g_free (string);
+ goto error;
+ }
+ g_free (string);
+ }
+
+ written = fwrite ("\n(", 1, 2, file);
+ if (written != 2)
+ goto error;
+
+ uri = brasero_track_stream_get_source (track, TRUE);
+ written = fwrite (uri, 1, strlen (uri), file);
+ if (written != strlen (uri)) {
+ g_free (uri);
+ goto error;
+ }
+
+ g_free (uri);
+
+ written = fwrite (")", 1, 1, file);
+ if (written != 1)
+ goto error;
+
+ written = fwrite ("\n\n", 1, 2, file);
+ if (written != 2)
+ goto error;
+ }
+
+ fclose (file);
+ return TRUE;
+
+error:
+
+ fclose (file);
+
+ return FALSE;
+}
+
+#ifdef BUILD_PLAYLIST
+
+static void
+brasero_project_save_audio_playlist_entry (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gchar **uri,
+ gchar **title,
+ gboolean *custom_title,
+ gpointer user_data)
+{
+ gtk_tree_model_get (model, iter,
+ 0, uri,
+ 1, title,
+ 2, custom_title,
+ -1);
+}
+
+gboolean
+brasero_project_save_audio_project_playlist (BraseroBurnSession *session,
+ const gchar *uri,
+ BraseroProjectSave type)
+{
+ TotemPlParserType pl_type;
+ TotemPlParser *parser;
+ GtkListStore *model;
+ GtkTreeIter t_iter;
+ gboolean result;
+ GSList *iter;
+ gchar *path;
+
+ path = g_filename_from_uri (uri, NULL, NULL);
+ if (!path)
+ return FALSE;
+
+ parser = totem_pl_parser_new ();
+
+ /* create and populate treemodel */
+ model = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+ iter = brasero_burn_session_get_tracks (session);
+ for (; iter; iter = iter->next) {
+ BraseroTrackStream *track;
+ gchar *uri;
+
+ track = iter->data;
+
+ uri = brasero_track_stream_get_source (track, TRUE);
+ gtk_list_store_append (model, &t_iter);
+ gtk_list_store_set (model, &t_iter,
+ 0, uri,
+ 1, brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_TITLE_TAG),
+ 2, TRUE,
+ -1);
+ g_free (uri);
+ }
+
+ switch (type) {
+ case BRASERO_PROJECT_SAVE_PLAYLIST_M3U:
+ pl_type = TOTEM_PL_PARSER_M3U;
+ break;
+ case BRASERO_PROJECT_SAVE_PLAYLIST_XSPF:
+ pl_type = TOTEM_PL_PARSER_XSPF;
+ break;
+ case BRASERO_PROJECT_SAVE_PLAYLIST_IRIVER_PLA:
+ pl_type = TOTEM_PL_PARSER_IRIVER_PLA;
+ break;
+
+ case BRASERO_PROJECT_SAVE_PLAYLIST_PLS:
+ default:
+ pl_type = TOTEM_PL_PARSER_PLS;
+ break;
+ }
+
+ result = totem_pl_parser_write_with_title (parser,
+ GTK_TREE_MODEL (model),
+ brasero_project_save_audio_playlist_entry,
+ path,
+ brasero_burn_session_get_label (session),
+ pl_type,
+ NULL,
+ NULL);
+
+ g_object_unref (model);
g_object_unref (parser);
+ g_free (path);
- return (result == TOTEM_PL_PARSER_RESULT_SUCCESS);
+ return result;
}
#endif
diff --git a/src/brasero-project-parse.h b/src/brasero-project-parse.h
index e00593e..da3298a 100644
--- a/src/brasero-project-parse.h
+++ b/src/brasero-project-parse.h
@@ -30,11 +30,20 @@
#include <glib.h>
#include "brasero-track.h"
-#include "brasero-track-stream.h"
+#include "brasero-session.h"
G_BEGIN_DECLS
typedef enum {
+ BRASERO_PROJECT_SAVE_XML = 0,
+ BRASERO_PROJECT_SAVE_PLAIN = 1,
+ BRASERO_PROJECT_SAVE_PLAYLIST_PLS = 2,
+ BRASERO_PROJECT_SAVE_PLAYLIST_M3U = 3,
+ BRASERO_PROJECT_SAVE_PLAYLIST_XSPF = 4,
+ BRASERO_PROJECT_SAVE_PLAYLIST_IRIVER_PLA = 5
+} BraseroProjectSave;
+
+typedef enum {
BRASERO_PROJECT_TYPE_INVALID,
BRASERO_PROJECT_TYPE_COPY,
BRASERO_PROJECT_TYPE_ISO,
@@ -43,64 +52,29 @@ typedef enum {
BRASERO_PROJECT_TYPE_VIDEO
} BraseroProjectType;
-struct _BraseroStreamInfo {
- gchar *title;
- gchar *artist;
- gchar *composer;
- gint isrc;
-};
-
-typedef struct _BraseroStreamInfo BraseroStreamInfo;
-
-void
-brasero_stream_info_free (BraseroStreamInfo *info);
-
-BraseroStreamInfo *
-brasero_stream_info_copy (BraseroStreamInfo *info);
-
-struct _BraseroDiscSong {
- gchar *uri;
- gint64 gap;
- gint64 start;
- gint64 end;
-
- BraseroStreamInfo *info;
-};
-typedef struct _BraseroDiscSong BraseroDiscSong;
-
-typedef struct {
- BraseroProjectType type;
- gchar *label;
- gchar *cover;
-
- union {
- struct {
- GSList *grafts;
- GSList *excluded;
- GSList *restored;
- gchar *icon;
- } data;
-
- GSList *tracks; /* BraseroDiscSong */
- } contents;
-} BraseroDiscTrack;
-
-void
-brasero_track_clear (BraseroDiscTrack *track);
-
-void
-brasero_track_free (BraseroDiscTrack *track);
-
gboolean
brasero_project_open_project_xml (const gchar *uri,
- BraseroDiscTrack **track,
+ BraseroBurnSession *session,
gboolean warn_user);
gboolean
brasero_project_open_audio_playlist_project (const gchar *uri,
- BraseroDiscTrack **track,
+ BraseroBurnSession *session,
gboolean warn_user);
+gboolean
+brasero_project_save_project_xml (BraseroBurnSession *session,
+ const gchar *uri);
+
+gboolean
+brasero_project_save_audio_project_plain_text (BraseroBurnSession *session,
+ const gchar *uri);
+
+gboolean
+brasero_project_save_audio_project_playlist (BraseroBurnSession *session,
+ const gchar *uri,
+ BraseroProjectSave type);
+
G_END_DECLS
#endif
diff --git a/src/brasero-project.c b/src/brasero-project.c
index a6cc2e4..acec0e7 100644
--- a/src/brasero-project.c
+++ b/src/brasero-project.c
@@ -88,6 +88,8 @@
#include "brasero-burn-options.h"
#include "brasero-project-name.h"
+#include "brasero-image-properties.h"
+
static void brasero_project_class_init (BraseroProjectClass *klass);
static void brasero_project_init (BraseroProject *sp);
static void brasero_project_iface_uri_container_init (BraseroURIContainerIFace *iface);
@@ -135,22 +137,12 @@ brasero_project_get_proportion (BraseroLayoutObject *object,
gint *center,
gint *footer);
-typedef enum {
- BRASERO_PROJECT_SAVE_XML = 0,
- BRASERO_PROJECT_SAVE_PLAIN = 1,
- BRASERO_PROJECT_SAVE_PLAYLIST_PLS = 2,
- BRASERO_PROJECT_SAVE_PLAYLIST_M3U = 3,
- BRASERO_PROJECT_SAVE_PLAYLIST_XSPF = 4,
- BRASERO_PROJECT_SAVE_PLAYLIST_IRIVER_PLA = 5
-} BraseroProjectSave;
-
struct BraseroProjectPrivate {
BraseroSessionCfg *session;
+ GtkWidget *help;
GtkWidget *selection;
GtkWidget *name_display;
- GtkWidget *button_img;
- GtkWidget *icon_img;
GtkWidget *discs;
GtkWidget *audio;
GtkWidget *data;
@@ -258,6 +250,19 @@ static GObjectClass *parent_class = NULL;
#define BRASERO_RESPONSE_ADD 1976
+enum {
+ TREE_MODEL_ROW = 150,
+ FILE_NODES_ROW,
+ TARGET_URIS_LIST,
+};
+
+static GtkTargetEntry ntables_cd[] = {
+ {"GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, TREE_MODEL_ROW},
+ {"GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, FILE_NODES_ROW},
+ {"text/uri-list", 0, TARGET_URIS_LIST}
+};
+static guint nb_targets_cd = sizeof (ntables_cd) / sizeof (ntables_cd [0]);
+
GType
brasero_project_get_type ()
{
@@ -411,113 +416,344 @@ brasero_project_name_changed_cb (BraseroProjectName *name,
gtk_action_set_sensitive (action, FALSE);
}
-static void
-brasero_project_data_icon_error (BraseroProject *project,
- GError *error)
-{
- if (error) {
- brasero_app_alert (brasero_app_get_default (),
- /* Translators: this is a picture not
- * a disc image */
- C_("picture", "Please select another image."),
- error->message,
- GTK_MESSAGE_ERROR);
- }
- else {
- brasero_app_alert (brasero_app_get_default (),
- /* Translators: this is a picture not
- * a disc image */
- C_("picture", "Please select another image."),
- _("Unknown error"),
- GTK_MESSAGE_ERROR);
+/********************************** help ***************************************/
+static GtkWidget *
+brasero_utils_disc_find_tree_view_in_container (GtkContainer *container)
+{
+ GList *children;
+ GList *iter;
+
+ children = gtk_container_get_children (container);
+ for (iter = children; iter; iter = iter->next) {
+ GtkWidget *widget;
+
+ widget = iter->data;
+ if (GTK_IS_TREE_VIEW (widget)) {
+ g_list_free (children);
+ return widget;
+ }
+
+ if (GTK_IS_CONTAINER (widget)) {
+ widget = brasero_utils_disc_find_tree_view_in_container (GTK_CONTAINER (widget));
+ if (widget) {
+ g_list_free (children);
+ return widget;
+ }
+ }
}
+ g_list_free (children);
+
+ return NULL;
+}
+
+static GtkWidget *
+brasero_utils_disc_find_tree_view (BraseroDisc *widget)
+{
+ return brasero_utils_disc_find_tree_view_in_container (GTK_CONTAINER (widget));
}
static void
-brasero_project_icon_changed_cb (BraseroDisc *disc,
- BraseroProject *project)
+brasero_utils_disc_hide_use_info_leave_cb (GtkWidget *widget,
+ GdkDragContext *drag_context,
+ guint time,
+ BraseroProject *project)
{
- GError *error = NULL;
- GdkPixbuf *pixbuf;
- gchar *icon;
-
- icon = brasero_data_disc_get_scaled_icon_path (BRASERO_DATA_DISC (project->priv->current));
- if (!icon) {
- gtk_image_set_from_icon_name (GTK_IMAGE (project->priv->icon_img),
- "media-optical",
- GTK_ICON_SIZE_LARGE_TOOLBAR);
+ GtkWidget *other_widget;
+
+ other_widget = brasero_utils_disc_find_tree_view (project->priv->current);
+ if (!other_widget)
return;
+
+ g_signal_emit_by_name (other_widget,
+ "drag-leave",
+ drag_context,
+ time);
+}
+
+static gboolean
+brasero_utils_disc_hide_use_info_drop_cb (GtkWidget *widget,
+ GdkDragContext *drag_context,
+ gint x,
+ gint y,
+ guint time,
+ BraseroProject *project)
+{
+ GdkAtom target = GDK_NONE;
+ GtkWidget *other_widget;
+
+ /* here the treeview is not realized so we'll have a warning message
+ * if we ever try to forward the event */
+ other_widget = brasero_utils_disc_find_tree_view (project->priv->current);
+ if (!other_widget)
+ return FALSE;
+
+ target = gtk_drag_dest_find_target (other_widget,
+ drag_context,
+ gtk_drag_dest_get_target_list (GTK_WIDGET (other_widget)));
+
+ if (target != GDK_NONE) {
+ gboolean return_value = FALSE;
+
+ /* The widget must be realized to receive such events. */
+ g_signal_emit_by_name (other_widget,
+ "drag-drop",
+ drag_context,
+ x,
+ y,
+ time,
+ &return_value);
+ return return_value;
}
- /* Load and convert (48x48) the image into a pixbuf */
- pixbuf = gdk_pixbuf_new_from_file_at_scale (icon,
- 48,
- 48,
- FALSE,
- &error);
- g_free (icon);
-
- if (!pixbuf) {
- gtk_image_set_from_icon_name (GTK_IMAGE (project->priv->icon_img),
- "media-optical",
- GTK_ICON_SIZE_LARGE_TOOLBAR);
- brasero_project_data_icon_error (project, error);
- g_error_free (error);
+ return FALSE;
+}
+
+static void
+brasero_utils_disc_hide_use_info_data_received_cb (GtkWidget *widget,
+ GdkDragContext *drag_context,
+ gint x,
+ gint y,
+ GtkSelectionData *data,
+ guint info,
+ guint time,
+ BraseroProject *project)
+{
+ GtkWidget *other_widget;
+
+ other_widget = brasero_utils_disc_find_tree_view (project->priv->current);
+ if (!other_widget)
return;
- }
- gtk_image_set_from_pixbuf (GTK_IMAGE (project->priv->icon_img), pixbuf);
- g_object_unref (pixbuf);
+ g_signal_emit_by_name (other_widget,
+ "drag-data-received",
+ drag_context,
+ x,
+ y,
+ data,
+ info,
+ time);
+}
+
+static gboolean
+brasero_utils_disc_hide_use_info_motion_cb (GtkWidget *widget,
+ GdkDragContext *drag_context,
+ gint x,
+ gint y,
+ guint time,
+ GtkNotebook *notebook)
+{
+ return TRUE;
+}
+
+static gboolean
+brasero_utils_disc_hide_use_info_button_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ BraseroProject *project)
+{
+ GtkWidget *other_widget;
+ gboolean result;
+
+ if (event->button != 3)
+ return TRUE;
+
+ other_widget = brasero_utils_disc_find_tree_view (project->priv->current);
+ if (!other_widget)
+ return TRUE;
+
+ g_signal_emit_by_name (other_widget,
+ "button-press-event",
+ event,
+ &result);
+
+ return result;
}
static void
-brasero_project_icon_button_clicked (GtkWidget *button,
- BraseroProject *project)
+brasero_utils_disc_style_changed_cb (GtkWidget *widget,
+ GtkStyle *previous,
+ GtkWidget *event_box)
{
- GtkFileFilter *filter;
- GError *error = NULL;
- GtkWidget *chooser;
- gchar *path;
- gint res;
+ /* The widget (a treeview here) needs to be realized to get proper style */
+ gtk_widget_realize (widget);
+ gtk_widget_modify_bg (event_box, GTK_STATE_NORMAL, &widget->style->base[GTK_STATE_NORMAL]);
+}
+
+static void
+brasero_utils_disc_realized_cb (GtkWidget *event_box,
+ BraseroProject *project)
+{
+ GtkWidget *widget;
- if (!BRASERO_IS_DATA_DISC (project->priv->current))
+ widget = brasero_utils_disc_find_tree_view (BRASERO_DISC (project->priv->data));
+
+ if (!widget || !GTK_IS_TREE_VIEW (widget))
return;
- chooser = gtk_file_chooser_dialog_new (_("Medium Icon"),
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (project))),
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
+ /* The widget (a treeview here) needs to be realized to get proper style */
+ gtk_widget_realize (widget);
+ gtk_widget_modify_bg (event_box, GTK_STATE_NORMAL, &widget->style->base[GTK_STATE_NORMAL]);
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("All files"));
- gtk_file_filter_add_pattern (filter, "*");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+ g_signal_handlers_disconnect_by_func (widget,
+ brasero_utils_disc_style_changed_cb,
+ event_box);
+ g_signal_connect (widget,
+ "style-set",
+ G_CALLBACK (brasero_utils_disc_style_changed_cb),
+ event_box);
+}
- filter = gtk_file_filter_new ();
- /* Translators: this is an image, a picture, not a "Disc Image" */
- gtk_file_filter_set_name (filter, C_("picture", "Image files"));
- gtk_file_filter_add_mime_type (filter, "image/*");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+static gboolean
+brasero_disc_draw_focus_around_help_text (GtkWidget *label,
+ GdkEventExpose *event,
+ gpointer NULL_data)
+{
+ if (!gtk_widget_is_focus (label))
+ return FALSE;
- gtk_widget_show (chooser);
- res = gtk_dialog_run (GTK_DIALOG (chooser));
- if (res != GTK_RESPONSE_OK) {
- gtk_widget_destroy (chooser);
- return;
- }
+ gtk_paint_focus (label->style,
+ label->window,
+ GTK_STATE_NORMAL,
+ &event->area,
+ label,
+ NULL,
+ label->style->xthickness, label->style->ythickness,
+ label->allocation.width - label->style->xthickness * 2,
+ label->allocation.height - label->style->ythickness * 2);
+ return FALSE;
+}
- path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
- gtk_widget_destroy (chooser);
+static GtkWidget *
+brasero_disc_get_use_info_notebook (BraseroProject *project)
+{
+ GList *chain;
+ GtkWidget *frame;
+ GtkWidget *notebook;
+ GtkWidget *event_box;
+ GtkWidget *first_use;
+ gchar *message_add, *message_add_header;
+ gchar *message_remove, *message_remove_header;
+ gchar *first_use_message;
+
+ notebook = gtk_notebook_new ();
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
+
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
+ frame,
+ NULL);
+
+ /* Now this event box must be 'transparent' to have the same background
+ * color as a treeview */
+ event_box = gtk_event_box_new ();
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), TRUE);
+ gtk_drag_dest_set (event_box,
+ GTK_DEST_DEFAULT_MOTION,
+ ntables_cd,
+ nb_targets_cd,
+ GDK_ACTION_COPY|
+ GDK_ACTION_MOVE);
+
+ /* the following signals need to be forwarded to the widget underneath */
+ g_signal_connect (event_box,
+ "drag-motion",
+ G_CALLBACK (brasero_utils_disc_hide_use_info_motion_cb),
+ project);
+ g_signal_connect (event_box,
+ "drag-leave",
+ G_CALLBACK (brasero_utils_disc_hide_use_info_leave_cb),
+ project);
+ g_signal_connect (event_box,
+ "drag-drop",
+ G_CALLBACK (brasero_utils_disc_hide_use_info_drop_cb),
+ project);
+ g_signal_connect (event_box,
+ "button-press-event",
+ G_CALLBACK (brasero_utils_disc_hide_use_info_button_cb),
+ project);
+ g_signal_connect (event_box,
+ "drag-data-received",
+ G_CALLBACK (brasero_utils_disc_hide_use_info_data_received_cb),
+ project);
- if (!brasero_data_disc_set_icon_path (BRASERO_DATA_DISC (project->priv->current), path, &error)) {
- if (error) {
- brasero_project_data_icon_error (project, error);
- g_error_free (error);
- }
- }
- g_free (path);
+ gtk_container_add (GTK_CONTAINER (frame), event_box);
+
+ /* Translators: this messages will appear as a list of possible
+ * actions, like:
+ * To add/remove files you can:
+ * * perform action one
+ * * perform action two
+ * The full message will be showed in the main area of an empty
+ * project, suggesting users how to add and remove items to project.
+ * You simply have to translate messages in the best form
+ * for a list of actions. */
+ message_add_header = g_strconcat ("<big>", _("To add files to this project you can:"), "\n</big>", NULL);
+ message_add = g_strconcat ("\t* ", _("click the \"Add\" button to show a selection dialog"), "\n",
+ "\t* ", _("select files in the selection pane and click the \"Add\" button"), "\n",
+ "\t* ", _("drag files in this area from the selection pane or from the file manager"), "\n",
+ "\t* ", _("double click on files in the selection pane"), "\n",
+ "\t* ", _("copy files (from file manager for example) and paste in this area"), "\n",
+ NULL);
+
+ message_remove_header = g_strconcat ("<big>", _("To remove files from this project you can:"), "\n</big>", NULL);
+ message_remove = g_strconcat ("\t* ", _("click on the \"Remove\" button to remove selected items in this area"), "\n",
+ "\t* ", _("drag and release items out from this area"), "\n",
+ "\t* ", _("select items in this area, and choose \"Remove\" from context menu"), "\n",
+ "\t* ", _("select items in this area, and press \"Delete\" key"), "\n",
+ NULL);
+
+
+ first_use_message = g_strconcat ("<span foreground='grey50'>",
+ message_add_header, message_add,
+ "\n\n\n",
+ message_remove_header, message_remove,
+ "</span>", NULL);
+ first_use = gtk_label_new (first_use_message);
+ gtk_misc_set_alignment (GTK_MISC (first_use), 0.50, 0.30);
+ gtk_label_set_selectable (GTK_LABEL (first_use), TRUE);
+ gtk_label_set_ellipsize (GTK_LABEL (first_use), PANGO_ELLIPSIZE_END);
+ g_free (first_use_message);
+
+ gtk_misc_set_padding (GTK_MISC (first_use), 24, 0);
+ gtk_label_set_justify (GTK_LABEL (first_use), GTK_JUSTIFY_LEFT);
+ gtk_label_set_use_markup (GTK_LABEL (first_use), TRUE);
+ gtk_container_add (GTK_CONTAINER (event_box), first_use);
+
+ /* This is meant for accessibility so that screen readers can read it */
+ g_object_set (first_use,
+ "can-focus", TRUE,
+ NULL);
+
+ g_signal_connect_after (first_use,
+ "expose-event",
+ G_CALLBACK (brasero_disc_draw_focus_around_help_text),
+ NULL);
+
+ /* We don't want to have the whole text selected */
+ g_object_set (gtk_widget_get_settings (first_use),
+ "gtk-label-select-on-focus", FALSE,
+ NULL);
+
+ chain = g_list_prepend (NULL, first_use);
+ gtk_container_set_focus_chain (GTK_CONTAINER (frame), chain);
+ g_list_free (chain);
+
+ /* This gets all events and forward them to treeview */
+ gtk_event_box_set_above_child (GTK_EVENT_BOX (event_box), TRUE);
+
+ g_free (message_add_header);
+ g_free (message_add);
+ g_free (message_remove_header);
+ g_free (message_remove);
+
+ g_signal_connect (event_box,
+ "realize",
+ G_CALLBACK (brasero_utils_disc_realized_cb),
+ project);
+
+ gtk_widget_show_all (notebook);
+ return notebook;
}
/********************************** size ***************************************/
@@ -731,6 +967,7 @@ brasero_project_is_valid (BraseroSessionCfg *session,
}
else if (valid == BRASERO_SESSION_EMPTY) {
project->priv->empty = TRUE;
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (project->priv->help), 1);
}
else if (valid == BRASERO_SESSION_NO_OUTPUT) {
brasero_notify_message_add (BRASERO_NOTIFY (project->priv->message),
@@ -764,6 +1001,9 @@ brasero_project_is_valid (BraseroSessionCfg *session,
BRASERO_NOTIFY_CONTEXT_SIZE);
}
+ if (BRASERO_SESSION_IS_VALID (valid) || valid == BRASERO_SESSION_NOT_READY)
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (project->priv->help), 0);
+
if (BRASERO_SESSION_IS_VALID (valid)) {
project->priv->empty = FALSE;
project->priv->oversized = FALSE;
@@ -790,10 +1030,8 @@ brasero_project_init (BraseroProject *obj)
GtkSizeGroup *size_group;
GtkWidget *alignment;
GtkWidget *selector;
- GtkWidget *button;
GtkWidget *label;
GtkWidget *table;
- GtkWidget *image;
GtkWidget *box;
obj->priv = g_new0 (BraseroProjectPrivate, 1);
@@ -838,9 +1076,10 @@ brasero_project_init (BraseroProject *obj)
gtk_widget_show (box);
gtk_box_pack_end (GTK_BOX (obj), box, FALSE, TRUE, 0);
- table = gtk_table_new (4, 2, FALSE);
+ table = gtk_table_new (3, 2, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 0);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
+ gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_widget_show (table);
gtk_box_pack_end (GTK_BOX (obj), table, FALSE, TRUE, 0);
@@ -849,8 +1088,8 @@ brasero_project_init (BraseroProject *obj)
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_widget_show (label);
gtk_table_attach (GTK_TABLE (table), label,
- 1, 2,
0, 1,
+ 1, 2,
GTK_FILL,
GTK_EXPAND,
0, 0);
@@ -860,8 +1099,8 @@ brasero_project_init (BraseroProject *obj)
obj->priv->selection = selector;
gtk_table_attach (GTK_TABLE (table), selector,
- 2, 3,
- 0, 1,
+ 1, 2,
+ 1, 2,
GTK_FILL|GTK_EXPAND,
GTK_FILL|GTK_EXPAND,
0, 0);
@@ -870,20 +1109,8 @@ brasero_project_init (BraseroProject *obj)
size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
- /* Properties/options buttons */
- button = brasero_medium_properties_new (obj->priv->session);
- gtk_size_group_add_widget (GTK_SIZE_GROUP (size_group), button);
- gtk_widget_show (button);
- gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
- gtk_table_attach (GTK_TABLE (table), button,
- 3, 4,
- 0, 1,
- GTK_FILL,
- GTK_EXPAND,
- 0, 0);
-
/* burn button set insensitive since there are no files in the selection */
- obj->priv->burn = brasero_utils_make_button (_("_Burn"),
+ obj->priv->burn = brasero_utils_make_button (_("_Burn..."),
NULL,
"media-optical-burn",
GTK_ICON_SIZE_BUTTON);
@@ -902,56 +1129,28 @@ brasero_project_init (BraseroProject *obj)
gtk_widget_show (alignment);
gtk_container_add (GTK_CONTAINER (alignment), obj->priv->burn);
gtk_table_attach (GTK_TABLE (table), alignment,
- 3, 4,
+ 2, 3,
1, 2,
GTK_FILL,
GTK_EXPAND,
0, 0);
- /* icon */
- image = gtk_image_new_from_icon_name ("media-optical", GTK_ICON_SIZE_LARGE_TOOLBAR);
- gtk_widget_show (image);
- obj->priv->icon_img = image;
-
- button = gtk_button_new ();
- gtk_widget_show (button);
- gtk_button_set_image (GTK_BUTTON (button), image);
- obj->priv->button_img = button;
-
- gtk_widget_set_tooltip_text (button, _("Select an icon for the disc that will appear in file managers"));
-
- g_signal_connect (button,
- "clicked",
- G_CALLBACK (brasero_project_icon_button_clicked),
- obj);
-
- alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
- gtk_widget_show (alignment);
- gtk_container_add (GTK_CONTAINER (alignment), button);
-
- gtk_table_attach (GTK_TABLE (table), alignment,
- 0, 1,
- 0, 2,
- GTK_FILL,
- GTK_FILL|GTK_EXPAND,
- 0, 0);
-
/* Name widget */
label = gtk_label_new_with_mnemonic (_("_Name:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_widget_show (label);
gtk_table_attach (GTK_TABLE (table), label,
- 1, 2,
- 1, 2,
+ 0, 1,
+ 0, 1,
GTK_FILL,
GTK_EXPAND,
0, 0);
- obj->priv->name_display = brasero_project_name_new ();
+ obj->priv->name_display = brasero_project_name_new (BRASERO_BURN_SESSION (obj->priv->session));
gtk_widget_show (obj->priv->name_display);
gtk_table_attach (GTK_TABLE (table), obj->priv->name_display,
- 2, 3,
1, 2,
+ 0, 1,
GTK_EXPAND|GTK_FILL,
GTK_EXPAND|GTK_FILL,
0, 0);
@@ -979,10 +1178,6 @@ brasero_project_init (BraseroProject *obj)
"selection-changed",
G_CALLBACK (brasero_project_selection_changed_cb),
obj);
- g_signal_connect (obj->priv->data,
- "icon-changed",
- G_CALLBACK (brasero_project_icon_changed_cb),
- obj);
obj->priv->video = brasero_video_disc_new ();
gtk_widget_show (obj->priv->video);
@@ -991,6 +1186,9 @@ brasero_project_init (BraseroProject *obj)
G_CALLBACK (brasero_project_selection_changed_cb),
obj);
+ obj->priv->help = brasero_disc_get_use_info_notebook (obj);
+ gtk_widget_show (obj->priv->help);
+
obj->priv->discs = gtk_notebook_new ();
gtk_widget_show (obj->priv->discs);
gtk_notebook_set_show_border (GTK_NOTEBOOK (obj->priv->discs), FALSE);
@@ -1003,8 +1201,11 @@ brasero_project_init (BraseroProject *obj)
gtk_notebook_prepend_page (GTK_NOTEBOOK (obj->priv->discs),
obj->priv->audio, NULL);
+ gtk_notebook_prepend_page (GTK_NOTEBOOK (obj->priv->help),
+ obj->priv->discs, NULL);
+
gtk_box_pack_start (GTK_BOX (obj),
- obj->priv->discs,
+ obj->priv->help,
TRUE,
TRUE,
0);
@@ -1087,166 +1288,6 @@ brasero_project_get_boundaries (BraseroURIContainer *container,
end);
}
-/******************** useful function to wait when burning/saving **************/
-static gboolean
-_wait_for_ready_state (GtkWidget *dialog)
-{
- gchar *current_task = NULL;
- GtkProgressBar *progress;
- BraseroDiscResult status;
- BraseroProject *project;
- gint remaining = 0;
- gint initial;
-
- project = g_object_get_data (G_OBJECT (dialog), "Project");
- if (project->priv->oversized
- || !project->priv->current
- || !project->priv->project_status) {
- gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
- return FALSE;
- }
-
- progress = g_object_get_data (G_OBJECT (dialog), "ProgressBar");
- initial = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), "Remaining"));
- status = brasero_disc_get_status (project->priv->current, &remaining, ¤t_task);
- if (status == BRASERO_DISC_NOT_READY || status == BRASERO_DISC_LOADING) {
- gchar *string;
- gchar *size_str;
-
- if (initial <= 0 || remaining <= 0)
- gtk_progress_bar_pulse (progress);
- else
- gtk_progress_bar_set_fraction (progress, (gdouble) ((gdouble) (initial - remaining) / (gdouble) initial));
-
- if (current_task) {
- GtkWidget *current_action;
-
- current_action = g_object_get_data (G_OBJECT (dialog), "CurrentAction");
- string = g_strdup_printf ("<i>%s</i>", current_task);
- g_free (current_task);
-
- gtk_label_set_markup (GTK_LABEL (current_action), string);
- g_free (string);
- }
-
- string = brasero_project_get_sectors_string (project->priv->sectors,
- !BRASERO_IS_DATA_DISC (project->priv->current));
-
- size_str = g_strdup_printf (_("Project estimated size: %s"), string);
- g_free (string);
-
- gtk_progress_bar_set_text (progress, size_str);
- g_free (size_str);
-
- return TRUE;
- }
-
- gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- return FALSE;
-}
-
-static BraseroDiscResult
-brasero_project_check_status (BraseroProject *project,
- BraseroDisc *disc)
-{
- int id;
- int answer;
- GtkWidget *box;
- GtkWidget *dialog;
- gchar *current_task;
- GtkWidget *progress;
- gint remaining = -1;
- BraseroDiscResult result;
- GtkWidget *current_action;
-
- current_task = NULL;
- result = brasero_disc_get_status (disc, &remaining, ¤t_task);
- if (result != BRASERO_DISC_NOT_READY && result != BRASERO_DISC_LOADING)
- return result;
-
- /* we are not ready to create tracks presumably because
- * data or audio has not finished to explore a directory
- * or get the metadata of a song or a film */
-
- /* This dialog can run as a standalone window when run from nautilus
- * to burn burn:// URI contents. */
- dialog = brasero_app_dialog (brasero_app_get_default (),
- _("Please wait until the estimation of the project size is completed."),
- GTK_BUTTONS_CANCEL,
- GTK_MESSAGE_OTHER);
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("All files from the project need to be analysed to complete this operation."));
-
- gtk_window_set_title (GTK_WINDOW (dialog), _("Project Size Estimation"));
-
- box = gtk_vbox_new (FALSE, 4);
- gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->vbox),
- box,
- TRUE,
- TRUE,
- 0);
-
- progress = gtk_progress_bar_new ();
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), " ");
- gtk_box_pack_start (GTK_BOX (box),
- progress,
- TRUE,
- TRUE,
- 0);
-
- if (current_task) {
- gchar *string;
-
- string = g_strdup_printf ("<i>%s</i>", current_task);
- g_free (current_task);
-
- current_action = gtk_label_new (string);
- g_free (string);
- }
- else
- current_action = gtk_label_new ("");
-
- gtk_label_set_use_markup (GTK_LABEL (current_action), TRUE);
- gtk_misc_set_alignment (GTK_MISC (current_action), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (box),
- current_action,
- FALSE,
- TRUE,
- 0);
-
- gtk_widget_show_all (dialog);
- gtk_progress_bar_pulse (GTK_PROGRESS_BAR (progress));
-
- g_object_set_data (G_OBJECT (dialog), "CurrentAction", current_action);
- g_object_set_data (G_OBJECT (dialog), "ProgressBar", progress);
- g_object_set_data (G_OBJECT (dialog), "Remaining", GINT_TO_POINTER (remaining));
- g_object_set_data (G_OBJECT (dialog), "Project", project);
-
- id = g_timeout_add (100,
- (GSourceFunc) _wait_for_ready_state,
- dialog);
-
- project->priv->project_status = dialog;
- answer = gtk_dialog_run (GTK_DIALOG (dialog));
- g_source_remove (id);
-
- gtk_widget_destroy (dialog);
-
- if (!project->priv->project_status)
- return BRASERO_DISC_CANCELLED;
-
- project->priv->project_status = NULL;
-
- if (answer != GTK_RESPONSE_OK)
- return BRASERO_DISC_CANCELLED;
- else if (project->priv->oversized)
- return BRASERO_DISC_ERROR_SIZE;
-
- return brasero_disc_get_status (disc, NULL, NULL);
-}
-
-/******************************** burning **************************************/
static void
brasero_project_no_song_dialog (BraseroProject *project)
{
@@ -1265,6 +1306,43 @@ brasero_project_no_file_dialog (BraseroProject *project)
GTK_MESSAGE_WARNING);
}
+static BraseroBurnResult
+brasero_project_check_status (BraseroProject *project)
+{
+ GtkWidget *dialog;
+ BraseroStatus *status;
+ GtkResponseType response;
+ BraseroBurnResult result;
+
+ status = brasero_status_new ();
+ brasero_burn_session_get_status (BRASERO_BURN_SESSION (project->priv->session), status);
+ result = brasero_status_get_result (status);
+ brasero_status_free (status);
+
+ if (result == BRASERO_BURN_ERR) {
+ /* At the moment the only error possible is an empty project */
+ if (BRASERO_IS_AUDIO_DISC (project->priv->current))
+ brasero_project_no_song_dialog (project);
+ else
+ brasero_project_no_file_dialog (project);
+
+ return BRASERO_BURN_ERR;
+ }
+
+ if (result == BRASERO_BURN_OK)
+ return BRASERO_BURN_OK;
+
+ dialog = brasero_status_dialog_new (BRASERO_BURN_SESSION (project->priv->session),
+ gtk_widget_get_toplevel (GTK_WIDGET (project)));
+
+ gtk_widget_show (dialog);
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ return (response == GTK_RESPONSE_OK)? BRASERO_BURN_OK:BRASERO_BURN_CANCEL;
+}
+
+/******************************** burning **************************************/
static void
brasero_project_setup_session (BraseroProject *project,
BraseroBurnSession *session)
@@ -1286,31 +1364,110 @@ brasero_project_setup_session (BraseroProject *project,
}
}
-void
-brasero_project_burn (BraseroProject *project)
+static gboolean
+brasero_project_drive_properties (BraseroProject *project)
{
- BraseroDiscResult result;
+ GtkWidget *medium_prop;
+ GtkResponseType answer;
+ BraseroDrive *drive;
+ GtkWidget *toplevel;
+ gchar *display_name;
+ GtkWidget *button;
+ GtkWidget *dialog;
+ GtkWidget *box;
+ gchar *header;
- result = brasero_project_check_status (project, project->priv->current);
- if (result == BRASERO_DISC_CANCELLED)
- return;
+ /* Build dialog */
+ medium_prop = brasero_drive_properties_new (project->priv->session);
+ gtk_widget_show (medium_prop);
- if (result == BRASERO_DISC_ERROR_SIZE)
- return;
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (project));
- if (result == BRASERO_DISC_ERROR_EMPTY_SELECTION) {
- if (BRASERO_IS_AUDIO_DISC (project->priv->current))
- brasero_project_no_song_dialog (project);
- else
- brasero_project_no_file_dialog (project);
+ drive = brasero_burn_session_get_burner (BRASERO_BURN_SESSION (project->priv->session));
+ display_name = brasero_drive_get_display_name (drive);
+ header = g_strdup_printf (_("Properties of %s"), display_name);
+ g_free (display_name);
+
+ dialog = gtk_dialog_new_with_buttons (header,
+ GTK_WINDOW (toplevel),
+ GTK_DIALOG_MODAL|
+ GTK_DIALOG_NO_SEPARATOR|
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ NULL);
+ g_free (header);
- return;
- }
+ button = brasero_utils_make_button (_("_Burn"),
+ NULL,
+ "media-optical-burn",
+ GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (button);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog),
+ button,
+ GTK_RESPONSE_OK);
+
+ box = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_pack_start (GTK_BOX (box), medium_prop, TRUE, TRUE, 0);
+
+ /* launch the dialog */
+ gtk_widget_show (dialog);
+ answer = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
- if (result != BRASERO_DISC_OK)
+ return (answer == GTK_RESPONSE_OK);
+}
+
+static gboolean
+brasero_project_image_properties (BraseroProject *project)
+{
+ GtkResponseType answer;
+ GtkWidget *toplevel;
+ GtkWidget *button;
+ GtkWidget *dialog;
+
+ /* Build dialog */
+ dialog = brasero_image_properties_new ();
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (project));
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
+ gtk_window_set_position (GTK_WINDOW (toplevel), GTK_WIN_POS_CENTER_ON_PARENT);
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+ button = brasero_utils_make_button (_("_Burn"),
+ NULL,
+ "media-optical-burn",
+ GTK_ICON_SIZE_BUTTON);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog),
+ button,
+ GTK_RESPONSE_OK);
+
+ brasero_image_properties_set_session (BRASERO_IMAGE_PROPERTIES (dialog), project->priv->session);
+
+ /* launch the dialog */
+ gtk_widget_show (dialog);
+ answer = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ return (answer == GTK_RESPONSE_OK);
+}
+
+void
+brasero_project_burn (BraseroProject *project)
+{
+ gboolean res = FALSE;
+
+ if (!brasero_burn_session_is_dest_file (BRASERO_BURN_SESSION (project->priv->session)))
+ res = brasero_project_drive_properties (project);
+ else
+ res = brasero_project_image_properties (project);
+
+ if (!res)
return;
project->priv->is_burning = 1;
+ brasero_project_setup_session (project, BRASERO_BURN_SESSION (project->priv->session));
/* This is to stop the preview widget from playing */
brasero_uri_container_uri_selected (BRASERO_URI_CONTAINER (project));
@@ -1343,17 +1500,7 @@ brasero_project_create_audio_cover (BraseroProject *project,
static void
brasero_project_reset (BraseroProject *project)
{
- brasero_burn_session_set_flags (BRASERO_BURN_SESSION (project->priv->session),
- BRASERO_BURN_FLAG_NONE);
- brasero_burn_session_add_track (BRASERO_BURN_SESSION (project->priv->session),
- NULL,
- NULL);
-}
-
-static void
-brasero_project_switch (BraseroProject *project, BraseroProjectType type)
-{
- GtkAction *action;
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (project->priv->help), 1);
if (project->priv->project_status) {
gtk_widget_hide (project->priv->project_status);
@@ -1362,26 +1509,16 @@ brasero_project_switch (BraseroProject *project, BraseroProjectType type)
project->priv->project_status = NULL;
}
- gtk_image_set_from_icon_name (GTK_IMAGE (project->priv->icon_img),
- "media-optical",
- GTK_ICON_SIZE_LARGE_TOOLBAR);
-
if (project->priv->current) {
brasero_disc_set_session_contents (project->priv->current, NULL);
project->priv->current = NULL;
}
- brasero_project_reset (project);
-
if (project->priv->chooser) {
gtk_widget_destroy (project->priv->chooser);
project->priv->chooser = NULL;
}
- project->priv->empty = 1;
- project->priv->burnt = 0;
- project->priv->modified = 0;
-
if (project->priv->project) {
g_free (project->priv->project);
project->priv->project = NULL;
@@ -1396,40 +1533,45 @@ brasero_project_switch (BraseroProject *project, BraseroProjectType type)
if (project->priv->merge_id > 0)
gtk_ui_manager_remove_ui (project->priv->manager,
project->priv->merge_id);
-g_object_ref (project->priv->session);
- if (type == BRASERO_PROJECT_TYPE_AUDIO) {
- gtk_widget_hide (project->priv->button_img);
- project->priv->current = BRASERO_DISC (project->priv->audio);
- project->priv->merge_id = brasero_disc_add_ui (project->priv->current,
- project->priv->manager,
- project->priv->message);
+ project->priv->empty = 1;
+ project->priv->burnt = 0;
+ project->priv->modified = 0;
+ brasero_burn_session_set_flags (BRASERO_BURN_SESSION (project->priv->session),
+ BRASERO_BURN_FLAG_NONE);
+ brasero_burn_session_add_track (BRASERO_BURN_SESSION (project->priv->session),
+ NULL,
+ NULL);
+
+ brasero_notify_message_remove (BRASERO_NOTIFY (project->priv->message), BRASERO_NOTIFY_CONTEXT_SIZE);
+ brasero_notify_message_remove (BRASERO_NOTIFY (project->priv->message), BRASERO_NOTIFY_CONTEXT_LOADING);
+ brasero_notify_message_remove (BRASERO_NOTIFY (project->priv->message), BRASERO_NOTIFY_CONTEXT_MULTISESSION);
+}
+
+static void
+brasero_project_switch (BraseroProject *project, BraseroProjectType type)
+{
+ GtkAction *action;
+
+ /* FIXME: */
+ g_object_ref (project->priv->session);
+
+ if (type == BRASERO_PROJECT_TYPE_AUDIO) {
+ project->priv->current = BRASERO_DISC (project->priv->audio);
gtk_notebook_set_current_page (GTK_NOTEBOOK (project->priv->discs), 0);
brasero_medium_selection_show_media_type (BRASERO_MEDIUM_SELECTION (project->priv->selection),
BRASERO_MEDIA_TYPE_WRITABLE);
}
else if (type == BRASERO_PROJECT_TYPE_DATA) {
- gtk_widget_show (project->priv->button_img);
-
project->priv->current = BRASERO_DISC (project->priv->data);
- project->priv->merge_id = brasero_disc_add_ui (project->priv->current,
- project->priv->manager,
- project->priv->message);
-
gtk_notebook_set_current_page (GTK_NOTEBOOK (project->priv->discs), 1);
brasero_medium_selection_show_media_type (BRASERO_MEDIUM_SELECTION (project->priv->selection),
BRASERO_MEDIA_TYPE_WRITABLE|
BRASERO_MEDIA_TYPE_FILE);
}
else if (type == BRASERO_PROJECT_TYPE_VIDEO) {
- gtk_widget_hide (project->priv->button_img);
-
project->priv->current = BRASERO_DISC (project->priv->video);
- project->priv->merge_id = brasero_disc_add_ui (project->priv->current,
- project->priv->manager,
- project->priv->message);
-
gtk_notebook_set_current_page (GTK_NOTEBOOK (project->priv->discs), 2);
brasero_medium_selection_show_media_type (BRASERO_MEDIUM_SELECTION (project->priv->selection),
BRASERO_MEDIA_TYPE_WRITABLE|
@@ -1438,8 +1580,13 @@ g_object_ref (project->priv->session);
brasero_dest_selection_choose_best (BRASERO_DEST_SELECTION (project->priv->selection));
- if (project->priv->current)
- brasero_disc_set_session_contents (project->priv->current, BRASERO_BURN_SESSION (project->priv->session));
+ if (project->priv->current) {
+ project->priv->merge_id = brasero_disc_add_ui (project->priv->current,
+ project->priv->manager,
+ project->priv->message);
+ brasero_disc_set_session_contents (project->priv->current,
+ BRASERO_BURN_SESSION (project->priv->session));
+ }
brasero_notify_message_remove (BRASERO_NOTIFY (project->priv->message), BRASERO_NOTIFY_CONTEXT_SIZE);
@@ -1464,6 +1611,7 @@ g_object_ref (project->priv->session);
void
brasero_project_set_audio (BraseroProject *project, GSList *uris)
{
+ brasero_project_reset (project);
brasero_project_switch (project, BRASERO_PROJECT_TYPE_AUDIO);
for (; uris; uris = uris->next) {
@@ -1478,6 +1626,7 @@ void
brasero_project_set_data (BraseroProject *project,
GSList *uris)
{
+ brasero_project_reset (project);
brasero_project_switch (project, BRASERO_PROJECT_TYPE_DATA);
for (; uris; uris = uris->next) {
@@ -1491,6 +1640,7 @@ brasero_project_set_data (BraseroProject *project,
void
brasero_project_set_video (BraseroProject *project, GSList *uris)
{
+ brasero_project_reset (project);
brasero_project_switch (project, BRASERO_PROJECT_TYPE_VIDEO);
for (; uris; uris = uris->next) {
@@ -2047,48 +2197,85 @@ brasero_project_set_uri (BraseroProject *project,
gtk_action_set_sensitive (action, FALSE);
}
+static BraseroProjectType
+brasero_project_get_session_type (BraseroProject *project)
+{
+ BraseroTrackType *session_type;
+ BraseroProjectType type;
+
+ session_type = brasero_track_type_new ();
+ brasero_burn_session_get_input_type (BRASERO_BURN_SESSION (project->priv->session), session_type);
+
+ if (brasero_track_type_get_has_stream (session_type)) {
+ if (BRASERO_STREAM_FORMAT_HAS_VIDEO (brasero_track_type_get_stream_format (session_type)))
+ type = BRASERO_PROJECT_TYPE_VIDEO;
+ else
+ type = BRASERO_PROJECT_TYPE_AUDIO;
+ }
+ else if (brasero_track_type_get_has_data (session_type))
+ type = BRASERO_PROJECT_TYPE_DATA;
+ else
+ type = BRASERO_PROJECT_TYPE_INVALID;
+
+ brasero_track_type_free (session_type);
+
+ return type;
+}
+
/******************************* Projects **************************************/
BraseroProjectType
-brasero_project_open_project (BraseroProject *project,
- BraseroDiscTrack *track,
- const gchar *uri) /* escaped */
+brasero_project_open_project_real (BraseroProject *project,
+ const gchar *uri, /* escaped */
+ gboolean playlist,
+ gboolean warn_user)
{
+ GValue *value;
BraseroProjectType type;
- if (!track)
- return BRASERO_PROJECT_TYPE_INVALID;
+ brasero_project_reset (project);
- if (track->type == BRASERO_PROJECT_TYPE_AUDIO)
- type = BRASERO_PROJECT_TYPE_AUDIO;
- else if (track->type == BRASERO_PROJECT_TYPE_DATA)
- type = BRASERO_PROJECT_TYPE_DATA;
- else if (track->type == BRASERO_PROJECT_TYPE_VIDEO)
- type = BRASERO_PROJECT_TYPE_VIDEO;
+#ifdef BUILD_PLAYLIST
+
+ if (playlist) {
+ if (!brasero_project_open_audio_playlist_project (uri, BRASERO_BURN_SESSION (project->priv->session), warn_user))
+ return BRASERO_PROJECT_TYPE_INVALID;
+ }
else
+
+#endif
+
+ if (!brasero_project_open_project_xml (uri, BRASERO_BURN_SESSION (project->priv->session), warn_user))
return BRASERO_PROJECT_TYPE_INVALID;
+ type = brasero_project_get_session_type (project);
+ if (type == BRASERO_PROJECT_TYPE_INVALID)
+ return type;
+
brasero_project_switch (project, type);
- if (track->label) {
+ if (brasero_burn_session_get_label (BRASERO_BURN_SESSION (project->priv->session))) {
g_signal_handlers_block_by_func (project->priv->name_display,
brasero_project_name_changed_cb,
project);
- gtk_entry_set_text (GTK_ENTRY (project->priv->name_display), track->label);
+ gtk_entry_set_text (GTK_ENTRY (project->priv->name_display),
+ brasero_burn_session_get_label (BRASERO_BURN_SESSION (project->priv->session)));
g_signal_handlers_unblock_by_func (project->priv->name_display,
brasero_project_name_changed_cb,
project);
}
- if (track->cover) {
+ value = NULL;
+ brasero_burn_session_tag_lookup (BRASERO_BURN_SESSION (project->priv->session),
+ BRASERO_COVER_URI,
+ &value);
+ if (value) {
if (project->priv->cover)
g_free (project->priv->cover);
- project->priv->cover = g_strdup (track->cover);
+ project->priv->cover = g_strdup (g_value_get_string (value));
}
- brasero_disc_load_track (project->priv->current, track);
project->priv->modified = 0;
-
if (uri)
brasero_project_set_uri (project, uri, type);
@@ -2096,41 +2283,18 @@ brasero_project_open_project (BraseroProject *project,
}
BraseroProjectType
-brasero_project_load_session (BraseroProject *project, const gchar *uri)
+brasero_project_open_project (BraseroProject *project,
+ const gchar *uri,
+ gboolean playlist) /* escaped */
{
- BraseroDiscTrack *track = NULL;
- BraseroProjectType type;
-
- if (!brasero_project_open_project_xml (uri, &track, FALSE))
- return BRASERO_PROJECT_TYPE_INVALID;
-
- if (track->type == BRASERO_PROJECT_TYPE_AUDIO)
- type = BRASERO_PROJECT_TYPE_AUDIO;
- else if (track->type == BRASERO_PROJECT_TYPE_DATA)
- type = BRASERO_PROJECT_TYPE_DATA;
- else if (track->type == BRASERO_PROJECT_TYPE_VIDEO)
- type = BRASERO_PROJECT_TYPE_VIDEO;
- else {
- brasero_track_free (track);
- return BRASERO_PROJECT_TYPE_INVALID;
- }
-
- brasero_project_switch (project, type);
-
- g_signal_handlers_block_by_func (project->priv->name_display,
- brasero_project_name_changed_cb,
- project);
- gtk_entry_set_text (GTK_ENTRY (project->priv->name_display), (gchar *) track->label);
- g_signal_handlers_unblock_by_func (project->priv->name_display,
- brasero_project_name_changed_cb,
- project);
-
- brasero_disc_load_track (project->priv->current, track);
- brasero_track_free (track);
-
- project->priv->modified = 0;
+ return brasero_project_open_project_real (project, uri, playlist, TRUE);
+}
- return type;
+BraseroProjectType
+brasero_project_load_session (BraseroProject *project,
+ const gchar *uri)
+{
+ return brasero_project_open_project_real (project, uri, FALSE, FALSE);
}
/******************************** save project *********************************/
@@ -2190,542 +2354,19 @@ brasero_project_save_project_dialog (BraseroProject *project,
}
static gboolean
-_save_audio_track_xml (xmlTextWriter *project,
- BraseroDiscTrack *track)
-{
- GSList *iter;
- gint success;
-
- for (iter = track->contents.tracks; iter; iter = iter->next) {
- BraseroDiscSong *song;
- BraseroStreamInfo *info;
- xmlChar *escaped;
- gchar *start;
- gchar *isrc;
- gchar *end;
-
- song = iter->data;
- info = song->info;
-
- escaped = (unsigned char *) g_uri_escape_string (song->uri, NULL, FALSE);
- success = xmlTextWriterWriteElement (project,
- (xmlChar *) "uri",
- escaped);
- g_free (escaped);
-
- if (success == -1)
- return FALSE;
-
- if (song->gap) {
- gchar *silence;
-
- silence = g_strdup_printf ("%"G_GINT64_FORMAT, song->gap);
- success = xmlTextWriterWriteElement (project,
- (xmlChar *) "silence",
- (xmlChar *) silence);
-
- g_free (silence);
- if (success == -1)
- return FALSE;
- }
-
- if (song->end > 0) {
- /* start of the song */
- start = g_strdup_printf ("%"G_GINT64_FORMAT, song->start);
- success = xmlTextWriterWriteElement (project,
- (xmlChar *) "start",
- (xmlChar *) start);
-
- g_free (start);
- if (success == -1)
- return FALSE;
-
- /* end of the song */
- end = g_strdup_printf ("%"G_GINT64_FORMAT, song->end);
- success = xmlTextWriterWriteElement (project,
- (xmlChar *) "end",
- (xmlChar *) end);
-
- g_free (end);
- if (success == -1)
- return FALSE;
- }
-
- if (!info)
- continue;
-
- if (info->title) {
- escaped = (unsigned char *) g_uri_escape_string (info->title, NULL, FALSE);
- success = xmlTextWriterWriteElement (project,
- (xmlChar *) "title",
- escaped);
- g_free (escaped);
-
- if (success == -1)
- return FALSE;
- }
-
- if (info->artist) {
- escaped = (unsigned char *) g_uri_escape_string (info->artist, NULL, FALSE);
- success = xmlTextWriterWriteElement (project,
- (xmlChar *) "artist",
- escaped);
- g_free (escaped);
-
- if (success == -1)
- return FALSE;
- }
-
- if (info->composer) {
- escaped = (unsigned char *) g_uri_escape_string (info->composer, NULL, FALSE);
- success = xmlTextWriterWriteElement (project,
- (xmlChar *) "composer",
- escaped);
- g_free (escaped);
-
- if (success == -1)
- return FALSE;
- }
-
- if (info->isrc) {
- isrc = g_strdup_printf ("%d", info->isrc);
- success = xmlTextWriterWriteElement (project,
- (xmlChar *) "isrc",
- (xmlChar *) isrc);
-
- g_free (isrc);
- if (success == -1)
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static gboolean
-_save_data_track_xml (xmlTextWriter *project,
- BraseroDiscTrack *track)
-{
- gchar *uri;
- gint success;
- GSList *iter;
- GSList *grafts;
- BraseroGraftPt *graft;
-
- if (track->contents.data.icon) {
- /* Write the icon if any */
- success = xmlTextWriterWriteElement (project, (xmlChar *) "icon", (xmlChar *) track->contents.data.icon);
- if (success < 0)
- return FALSE;
- }
-
- for (grafts = track->contents.data.grafts; grafts; grafts = grafts->next) {
- graft = grafts->data;
-
- success = xmlTextWriterStartElement (project, (xmlChar *) "graft");
- if (success < 0)
- return FALSE;
-
- success = xmlTextWriterWriteElement (project, (xmlChar *) "path", (xmlChar *) graft->path);
- if (success < 0)
- return FALSE;
-
- if (graft->uri) {
- xmlChar *escaped;
-
- escaped = (unsigned char *) g_uri_escape_string (graft->uri, NULL, FALSE);
- success = xmlTextWriterWriteElement (project, (xmlChar *) "uri", escaped);
- g_free (escaped);
- if (success < 0)
- return FALSE;
- }
-
- success = xmlTextWriterEndElement (project); /* graft */
- if (success < 0)
- return FALSE;
- }
-
- /* save excluded uris */
- for (iter = track->contents.data.excluded; iter; iter = iter->next) {
- xmlChar *escaped;
-
- escaped = xmlURIEscapeStr ((xmlChar *) iter->data, NULL);
- success = xmlTextWriterWriteElement (project, (xmlChar *) "excluded", (xmlChar *) escaped);
- g_free (escaped);
- if (success < 0)
- return FALSE;
- }
-
- /* save restored uris */
- for (iter = track->contents.data.restored; iter; iter = iter->next) {
- uri = iter->data;
- success = xmlTextWriterWriteElement (project, (xmlChar *) "restored", (xmlChar *) uri);
- if (success < 0)
- return FALSE;
- }
-
- /* NOTE: we don't write symlinks and unreadable they are useless */
- return TRUE;
-}
-
-static gboolean
-brasero_project_save_project_xml (BraseroProject *proj,
- const gchar *uri,
- BraseroDiscTrack *track,
- gboolean use_dialog)
-{
- xmlTextWriter *project;
- gboolean retval;
- gint success;
- gchar *path;
-
- path = g_filename_from_uri (uri, NULL, NULL);
- if (!path)
- return FALSE;
-
- project = xmlNewTextWriterFilename (path, 0);
- if (!project) {
- g_free (path);
-
- if (use_dialog)
- brasero_project_not_saved_dialog (proj);
-
- return FALSE;
- }
-
- xmlTextWriterSetIndent (project, 1);
- xmlTextWriterSetIndentString (project, (xmlChar *) "\t");
-
- success = xmlTextWriterStartDocument (project,
- NULL,
- "UTF8",
- NULL);
- if (success < 0)
- goto error;
-
- success = xmlTextWriterStartElement (project, (xmlChar *) "braseroproject");
- if (success < 0)
- goto error;
-
- /* write the name of the version */
- success = xmlTextWriterWriteElement (project,
- (xmlChar *) "version",
- (xmlChar *) BRASERO_PROJECT_VERSION);
- if (success < 0)
- goto error;
-
- success = xmlTextWriterWriteElement (project,
- (xmlChar *) "label",
- (xmlChar *) gtk_entry_get_text (GTK_ENTRY (proj->priv->name_display)));
- if (success < 0)
- goto error;
-
- if (proj->priv->cover) {
- gchar *escaped;
-
- escaped = g_uri_escape_string (proj->priv->cover, NULL, FALSE);
- success = xmlTextWriterWriteElement (project,
- (xmlChar *) "cover",
- (xmlChar *) escaped);
- g_free (escaped);
-
- if (success < 0)
- goto error;
- }
-
- success = xmlTextWriterStartElement (project, (xmlChar *) "track");
- if (success < 0)
- goto error;
-
- if (track->type == BRASERO_PROJECT_TYPE_AUDIO) {
- success = xmlTextWriterStartElement (project, (xmlChar *) "audio");
- if (success < 0)
- goto error;
-
- retval = _save_audio_track_xml (project, track);
- if (!retval)
- goto error;
-
- success = xmlTextWriterEndElement (project); /* audio */
- if (success < 0)
- goto error;
- }
- else if (track->type == BRASERO_PROJECT_TYPE_DATA) {
- success = xmlTextWriterStartElement (project, (xmlChar *) "data");
- if (success < 0)
- goto error;
-
- retval = _save_data_track_xml (project, track);
- if (!retval)
- goto error;
-
- success = xmlTextWriterEndElement (project); /* data */
- if (success < 0)
- goto error;
- }
- else if (track->type == BRASERO_PROJECT_TYPE_VIDEO) {
- success = xmlTextWriterStartElement (project, (xmlChar *) "video");
- if (success < 0)
- goto error;
-
- retval = _save_audio_track_xml (project, track);
- if (!retval)
- goto error;
-
- success = xmlTextWriterEndElement (project); /* audio */
- if (success < 0)
- goto error;
- }
- else
- retval = FALSE;
-
- success = xmlTextWriterEndElement (project); /* track */
- if (success < 0)
- goto error;
-
- success = xmlTextWriterEndElement (project); /* braseroproject */
- if (success < 0)
- goto error;
-
- xmlTextWriterEndDocument (project);
- xmlFreeTextWriter (project);
- g_free (path);
- return TRUE;
-
-error:
-
- xmlTextWriterEndDocument (project);
- xmlFreeTextWriter (project);
-
- g_remove (path);
- g_free (path);
-
- if (use_dialog)
- brasero_project_not_saved_dialog (proj);
-
- return FALSE;
-}
-
-static gboolean
-brasero_project_save_audio_project_plain_text (BraseroProject *proj,
- const gchar *uri,
- BraseroDiscTrack *track,
- gboolean use_dialog)
-{
- const gchar *title;
- guint written;
- GSList *iter;
- gchar *path;
- FILE *file;
-
- path = g_filename_from_uri (uri, NULL, NULL);
- if (!path)
- return FALSE;
-
- file = fopen (path, "w+");
- g_free (path);
- if (!file) {
- if (use_dialog)
- brasero_project_not_saved_dialog (proj);
-
- return FALSE;
- }
-
- /* write title */
- title = gtk_entry_get_text (GTK_ENTRY (proj->priv->name_display));
- written = fwrite (title, strlen (title), 1, file);
- if (written != 1)
- goto error;
-
- written = fwrite ("\n", 1, 1, file);
- if (written != 1)
- goto error;
-
- for (iter = track->contents.tracks; iter; iter = iter->next) {
- BraseroDiscSong *song;
- BraseroStreamInfo *info;
- gchar *time;
-
- song = iter->data;
- info = song->info;
-
- written = fwrite (info->title, 1, strlen (info->title), file);
- if (written != strlen (info->title))
- goto error;
-
- time = brasero_units_get_time_string (song->end - song->start, TRUE, FALSE);
- if (time) {
- written = fwrite ("\t", 1, 1, file);
- if (written != 1)
- goto error;
-
- written = fwrite (time, 1, strlen (time), file);
- if (written != strlen (time)) {
- g_free (time);
- goto error;
- }
- g_free (time);
- }
-
- if (info->artist) {
- gchar *string;
-
- written = fwrite ("\t", 1, 1, file);
- if (written != 1)
- goto error;
-
- /* Translators: %s is an artist */
- string = g_strdup_printf (" by %s", info->artist);
- written = fwrite (string, 1, strlen (string), file);
- if (written != strlen (string)) {
- g_free (string);
- goto error;
- }
- g_free (string);
- }
-
- written = fwrite ("\n(", 1, 2, file);
- if (written != 2)
- goto error;
-
- written = fwrite (song->uri, 1, strlen (song->uri), file);
- if (written != strlen (song->uri))
- goto error;
-
- written = fwrite (")", 1, 1, file);
- if (written != 1)
- goto error;
-
- written = fwrite ("\n\n", 1, 2, file);
- if (written != 2)
- goto error;
- }
-
- fclose (file);
- return TRUE;
-
-error:
- fclose (file);
-
- if (use_dialog)
- brasero_project_not_saved_dialog (proj);
-
- return FALSE;
-}
-
-#ifdef BUILD_PLAYLIST
-
-static void
-brasero_project_save_audio_playlist_entry (GtkTreeModel *model,
- GtkTreeIter *iter,
- gchar **uri,
- gchar **title,
- gboolean *custom_title,
- gpointer user_data)
-{
- gtk_tree_model_get (model, iter,
- 0, uri,
- 1, title,
- 2, custom_title,
- -1);
-}
-
-static gboolean
-brasero_project_save_audio_project_playlist (BraseroProject *proj,
- const gchar *uri,
- BraseroProjectSave type,
- BraseroDiscTrack *track,
- gboolean use_dialog)
-{
- TotemPlParserType pl_type;
- TotemPlParser *parser;
- GtkListStore *model;
- GtkTreeIter t_iter;
- gboolean result;
- GSList *iter;
- gchar *path;
-
- path = g_filename_from_uri (uri, NULL, NULL);
- if (!path)
- return FALSE;
-
- parser = totem_pl_parser_new ();
-
- /* create and populate treemodel */
- model = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
- for (iter = track->contents.tracks; iter; iter = iter->next) {
- BraseroDiscSong *song;
- BraseroStreamInfo *info;
-
- song = iter->data;
- info = song->info;
-
- gtk_list_store_append (model, &t_iter);
- gtk_list_store_set (model, &t_iter,
- 0, song->uri,
- 1, info->title,
- 2, TRUE,
- -1);
- }
-
- switch (type) {
- case BRASERO_PROJECT_SAVE_PLAYLIST_M3U:
- pl_type = TOTEM_PL_PARSER_M3U;
- break;
- case BRASERO_PROJECT_SAVE_PLAYLIST_XSPF:
- pl_type = TOTEM_PL_PARSER_XSPF;
- break;
- case BRASERO_PROJECT_SAVE_PLAYLIST_IRIVER_PLA:
- pl_type = TOTEM_PL_PARSER_IRIVER_PLA;
- break;
-
- case BRASERO_PROJECT_SAVE_PLAYLIST_PLS:
- default:
- pl_type = TOTEM_PL_PARSER_PLS;
- break;
- }
-
- result = totem_pl_parser_write_with_title (parser,
- GTK_TREE_MODEL (model),
- brasero_project_save_audio_playlist_entry,
- path,
- gtk_entry_get_text (GTK_ENTRY (proj->priv->name_display)),
- pl_type,
- NULL,
- NULL);
- if (!result && use_dialog)
- brasero_project_not_saved_dialog (proj);
-
- if (result)
- brasero_project_add_to_recents (proj, uri, FALSE);
-
- g_object_unref (model);
- g_object_unref (parser);
- g_free (path);
-
- return result;
-}
-
-#endif
-
-static gboolean
brasero_project_save_project_real (BraseroProject *project,
const gchar *uri,
BraseroProjectSave save_type)
{
BraseroDiscResult result;
BraseroProjectType type;
- BraseroDiscTrack track;
g_return_val_if_fail (uri != NULL || project->priv->project != NULL, FALSE);
- result = brasero_project_check_status (project, project->priv->current);
- if (result != BRASERO_DISC_OK)
+ result = brasero_project_check_status (project);
+ if (result != BRASERO_BURN_OK)
return FALSE;
- bzero (&track, sizeof (track));
-
- result = brasero_disc_get_track (project->priv->current, &track);
if (result == BRASERO_DISC_ERROR_EMPTY_SELECTION) {
if (BRASERO_IS_AUDIO_DISC (project->priv->current))
brasero_project_no_song_dialog (project);
@@ -2739,50 +2380,40 @@ brasero_project_save_project_real (BraseroProject *project,
return FALSE;
}
- if (track.type == BRASERO_PROJECT_TYPE_AUDIO)
- type = BRASERO_PROJECT_TYPE_AUDIO;
- else if (track.type == BRASERO_PROJECT_TYPE_DATA)
- type = BRASERO_PROJECT_TYPE_DATA;
- else if (track.type == BRASERO_PROJECT_TYPE_VIDEO)
- type = BRASERO_PROJECT_TYPE_VIDEO;
- else {
- brasero_track_clear (&track);
- return BRASERO_PROJECT_TYPE_INVALID;
- }
+ type = brasero_project_get_session_type (project);
if (save_type == BRASERO_PROJECT_SAVE_XML
- || track.type == BRASERO_PROJECT_TYPE_DATA) {
+ || type == BRASERO_PROJECT_TYPE_DATA) {
brasero_project_set_uri (project, uri, type);
- if (!brasero_project_save_project_xml (project,
- uri ? uri : project->priv->project,
- &track,
- TRUE))
+ if (!brasero_project_save_project_xml (BRASERO_BURN_SESSION (project->priv->session),
+ uri ? uri : project->priv->project)) {
+ brasero_project_not_saved_dialog (project);
return FALSE;
+ }
project->priv->modified = 0;
}
else if (save_type == BRASERO_PROJECT_SAVE_PLAIN) {
- if (!brasero_project_save_audio_project_plain_text (project,
- uri,
- &track,
- TRUE))
+ if (!brasero_project_save_audio_project_plain_text (BRASERO_BURN_SESSION (project->priv->session),
+ uri)) {
+ brasero_project_not_saved_dialog (project);
return FALSE;
+ }
}
#ifdef BUILD_PLAYLIST
else {
- if (!brasero_project_save_audio_project_playlist (project,
+ if (!brasero_project_save_audio_project_playlist (BRASERO_BURN_SESSION (project->priv->session),
uri,
- save_type,
- &track,
- TRUE))
+ save_type)) {
+ brasero_project_not_saved_dialog (project);
return FALSE;
+ }
}
#endif
- brasero_track_clear (&track);
return TRUE;
}
@@ -2892,8 +2523,6 @@ brasero_project_save_session (BraseroProject *project,
gchar **saved_uri,
gboolean show_cancel)
{
- BraseroDiscTrack track;
-
if (!project->priv->current) {
if (saved_uri)
*saved_uri = NULL;
@@ -2975,18 +2604,10 @@ brasero_project_save_session (BraseroProject *project,
return FALSE;
}
- bzero (&track, sizeof (track));
- if (brasero_disc_get_track (project->priv->current, &track) == BRASERO_DISC_OK) {
- /* NOTE: is this right? because brasero could not shut itself
- * down if an error occurs. */
- if (!brasero_project_save_project_xml (project,
- uri,
- &track,
- FALSE))
- return TRUE;
- }
-
- brasero_track_clear (&track);
+ /* NOTE: is this right? because brasero could not shut itself
+ * down if an error occurs. */
+ if (!brasero_project_save_project_xml (BRASERO_BURN_SESSION (project->priv->session), uri))
+ return TRUE;
if (saved_uri)
*saved_uri = g_strdup (uri);
diff --git a/src/brasero-project.h b/src/brasero-project.h
index 945f3ff..e65adca 100644
--- a/src/brasero-project.h
+++ b/src/brasero-project.h
@@ -83,8 +83,8 @@ brasero_project_set_source (BraseroProject *project,
BraseroProjectType
brasero_project_open_project (BraseroProject *project,
- BraseroDiscTrack *track,
- const gchar *uri);
+ const gchar *uri,
+ gboolean playlist);
gboolean
brasero_project_save_project (BraseroProject *project);
diff --git a/src/brasero-video-disc.c b/src/brasero-video-disc.c
index 176b84d..35fdf93 100644
--- a/src/brasero-video-disc.c
+++ b/src/brasero-video-disc.c
@@ -50,7 +50,6 @@
typedef struct _BraseroVideoDiscPrivate BraseroVideoDiscPrivate;
struct _BraseroVideoDiscPrivate
{
- GtkWidget *notebook;
GtkWidget *tree;
GtkWidget *message;
@@ -217,7 +216,6 @@ brasero_video_disc_name_edited_cb (GtkCellRendererText *cellrenderertext,
static BraseroDiscResult
brasero_video_disc_add_uri_real (BraseroVideoDisc *self,
const gchar *uri,
- BraseroStreamInfo *info,
gint pos,
gint64 start,
gint64 end,
@@ -240,22 +238,6 @@ brasero_video_disc_add_uri_real (BraseroVideoDisc *self,
brasero_track_stream_set_source (BRASERO_TRACK_STREAM (track), uri);
brasero_track_stream_set_boundaries (BRASERO_TRACK_STREAM (track), start, end, 0);
- if (info) {
- brasero_track_tag_add_string (BRASERO_TRACK (track),
- BRASERO_TRACK_STREAM_TITLE_TAG,
- info->title);
- brasero_track_tag_add_string (BRASERO_TRACK (track),
- BRASERO_TRACK_STREAM_ARTIST_TAG,
- info->artist);
- brasero_track_tag_add_string (BRASERO_TRACK (track),
- BRASERO_TRACK_STREAM_COMPOSER_TAG,
- info->composer);
-
- brasero_track_tag_add_int (BRASERO_TRACK (track),
- BRASERO_TRACK_STREAM_ISRC_TAG,
- info->isrc);
- }
-
/* insert it in the session */
session = brasero_video_tree_model_get_session (BRASERO_VIDEO_TREE_MODEL (model));
if (pos > 0) {
@@ -270,8 +252,6 @@ brasero_video_disc_add_uri_real (BraseroVideoDisc *self,
*path_return = brasero_video_tree_model_track_to_path (BRASERO_VIDEO_TREE_MODEL (model),
BRASERO_TRACK (track));
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
-
return BRASERO_DISC_OK;
}
@@ -286,7 +266,6 @@ brasero_video_disc_add_uri (BraseroDisc *self,
priv = BRASERO_VIDEO_DISC_PRIVATE (self);
result = brasero_video_disc_add_uri_real (BRASERO_VIDEO_DISC (self),
uri,
- NULL,
-1,
-1,
-1,
@@ -327,7 +306,6 @@ brasero_video_disc_add_directory_contents_result (GObject *obj,
/* Add a video file and set all information */
brasero_video_disc_add_uri_real (BRASERO_VIDEO_DISC (obj),
uri,
- NULL,
index,
-1,
-1,
@@ -913,7 +891,6 @@ brasero_video_disc_clipboard_text_cb (GtkClipboard *clipboard,
brasero_video_disc_add_uri_real (self,
uri,
- NULL,
-1,
-1,
-1,
@@ -1169,15 +1146,9 @@ brasero_video_disc_init (BraseroVideoDisc *object)
priv = BRASERO_VIDEO_DISC_PRIVATE (object);
- /* the information displayed about how to use this tree */
- priv->notebook = brasero_disc_get_use_info_notebook ();
- gtk_widget_show (priv->notebook);
- gtk_box_pack_start (GTK_BOX (object), priv->notebook, TRUE, TRUE, 0);
-
mainbox = gtk_vbox_new (FALSE, 12);
gtk_widget_show (mainbox);
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), mainbox, NULL);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 0);
+ gtk_box_pack_start (GTK_BOX (object), mainbox, TRUE, TRUE, 0);
priv->tree = gtk_tree_view_new ();
egg_tree_multi_drag_add_drag_support (GTK_TREE_VIEW (priv->tree));
@@ -1370,82 +1341,6 @@ brasero_video_disc_set_session_contents (BraseroDisc *self,
return BRASERO_DISC_OK;
}
-static BraseroDiscResult
-brasero_video_disc_get_track (BraseroDisc *disc,
- BraseroDiscTrack *disc_track)
-{
- GSList *iter;
- GSList *tracks;
- GtkTreeModel *model;
- BraseroSessionCfg *session;
- BraseroVideoDiscPrivate *priv;
-
- disc_track->type = BRASERO_PROJECT_TYPE_VIDEO;
-
- priv = BRASERO_VIDEO_DISC_PRIVATE (disc);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->tree));
- session = brasero_video_tree_model_get_session (BRASERO_VIDEO_TREE_MODEL (model));
- tracks = brasero_burn_session_get_tracks (BRASERO_BURN_SESSION (session));
-
- for (iter = tracks; iter; iter = iter->next) {
- BraseroDiscSong *song;
- BraseroTrack *track;
-
- track = iter->data;
-
- song = g_new0 (BraseroDiscSong, 1);
- song->uri = brasero_track_stream_get_source (BRASERO_TRACK_STREAM (track), TRUE);
- song->start = brasero_track_stream_get_start (BRASERO_TRACK_STREAM (track));
- song->end = brasero_track_stream_get_end (BRASERO_TRACK_STREAM (track));
-
- song->info = g_new0 (BraseroStreamInfo, 1);
- song->info->artist = g_strdup (brasero_track_tag_lookup_string (BRASERO_TRACK (track),
- BRASERO_TRACK_STREAM_ARTIST_TAG));
- song->info->title = g_strdup (brasero_track_tag_lookup_string (BRASERO_TRACK (track),
- BRASERO_TRACK_STREAM_TITLE_TAG));
- song->info->composer = g_strdup (brasero_track_tag_lookup_string (BRASERO_TRACK (track),
- BRASERO_TRACK_STREAM_COMPOSER_TAG));
- song->info->isrc = brasero_track_tag_lookup_int (BRASERO_TRACK (track),
- BRASERO_TRACK_STREAM_ISRC_TAG);
-
- disc_track->contents.tracks = g_slist_append (disc_track->contents.tracks, song);
- }
-
- return BRASERO_DISC_OK;
-}
-
-static BraseroDiscResult
-brasero_video_disc_load_track (BraseroDisc *disc,
- BraseroDiscTrack *track)
-{
- GSList *iter;
- BraseroVideoDiscPrivate *priv;
-
- g_return_val_if_fail (track->type == BRASERO_PROJECT_TYPE_VIDEO, FALSE);
-
- if (track->contents.tracks == NULL)
- return BRASERO_DISC_ERROR_EMPTY_SELECTION;
-
- priv = BRASERO_VIDEO_DISC_PRIVATE (disc);
- priv->loading = g_slist_length (track->contents.tracks);
-
- for (iter = track->contents.tracks; iter; iter = iter->next) {
- BraseroDiscSong *song;
-
- song = iter->data;
- brasero_video_disc_add_uri_real (BRASERO_VIDEO_DISC (disc),
- song->uri,
- song->info,
- -1,
- song->start,
- song->end,
- NULL);
- }
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1);
-
- return BRASERO_DISC_OK;
-}
-
static void
brasero_video_disc_iface_disc_init (BraseroDiscIface *iface)
{
@@ -1454,9 +1349,6 @@ brasero_video_disc_iface_disc_init (BraseroDiscIface *iface)
iface->set_session_contents = brasero_video_disc_set_session_contents;
- iface->get_track = brasero_video_disc_get_track;
- iface->load_track = brasero_video_disc_load_track;
-
iface->get_selected_uri = brasero_video_disc_get_selected_uri;
iface->add_ui = brasero_video_disc_add_ui;
}
diff --git a/src/brasero-video-tree-model.c b/src/brasero-video-tree-model.c
index c4795b0..1dabb0b 100644
--- a/src/brasero-video-tree-model.c
+++ b/src/brasero-video-tree-model.c
@@ -304,7 +304,9 @@ brasero_video_tree_model_get_value (GtkTreeModel *model,
case BRASERO_VIDEO_TREE_MODEL_INDEX:
tracks = brasero_burn_session_get_tracks (BRASERO_BURN_SESSION (priv->session));
g_value_init (value, G_TYPE_STRING);
- g_value_set_string_take_ownership (value, g_strdup_printf ("%02i", g_slist_index (tracks, track) + 1));
+ text = g_strdup_printf ("%02i", g_slist_index (tracks, track) + 1);
+ g_value_set_string (value, text);
+ g_free (text);
return;
case BRASERO_VIDEO_TREE_MODEL_INDEX_NUM:
@@ -1037,6 +1039,15 @@ brasero_video_tree_model_set_session (BraseroVideoTreeModel *model,
priv = BRASERO_VIDEO_TREE_MODEL_PRIVATE (model);
if (priv->session) {
+ g_signal_handlers_disconnect_by_func (priv->session,
+ brasero_video_tree_model_track_added,
+ model);
+ g_signal_handlers_disconnect_by_func (priv->session,
+ brasero_video_tree_model_track_removed,
+ model);
+ g_signal_handlers_disconnect_by_func (priv->session,
+ brasero_video_tree_model_track_changed,
+ model);
g_object_unref (priv->session);
priv->session = NULL;
}
@@ -1089,6 +1100,20 @@ brasero_video_tree_model_finalize (GObject *object)
priv = BRASERO_VIDEO_TREE_MODEL_PRIVATE (object);
+ if (priv->session) {
+ g_signal_handlers_disconnect_by_func (priv->session,
+ brasero_video_tree_model_track_added,
+ object);
+ g_signal_handlers_disconnect_by_func (priv->session,
+ brasero_video_tree_model_track_removed,
+ object);
+ g_signal_handlers_disconnect_by_func (priv->session,
+ brasero_video_tree_model_track_changed,
+ object);
+ g_object_unref (priv->session);
+ priv->session = NULL;
+ }
+
if (priv->gaps) {
g_slist_free (priv->gaps);
priv->gaps = NULL;
diff --git a/src/main.c b/src/main.c
index aaf26e6..56bc0f2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -268,7 +268,6 @@ brasero_app_open_project (BraseroApp *app,
gboolean playlist,
gboolean burn)
{
- BraseroDiscTrack *track = NULL;
BraseroProjectType type;
GtkWidget *manager;
GFile *file;
@@ -280,23 +279,11 @@ brasero_app_open_project (BraseroApp *app,
uri = g_file_get_uri (file);
g_object_unref (file);
-#ifdef BUILD_PLAYLIST
-
- if (playlist)
- type = brasero_project_open_audio_playlist_project (uri, &track, TRUE);
- else
-
-#endif
-
- type = brasero_project_open_project_xml (uri, &track, TRUE);
-
- if (type == BRASERO_PROJECT_TYPE_INVALID)
- return FALSE;
-
manager = brasero_app_get_project_manager (app);
- brasero_project_manager_open_project (BRASERO_PROJECT_MANAGER (manager), track, uri, burn);
+ type = brasero_project_manager_open_project (BRASERO_PROJECT_MANAGER (manager), uri, playlist, burn);
+ g_free (uri);
- return TRUE;
+ return (type != BRASERO_PROJECT_TYPE_INVALID);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]