brasero r1881 - in trunk: . src
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r1881 - in trunk: . src
- Date: Fri, 6 Feb 2009 20:08:36 +0000 (UTC)
Author: philippr
Date: Fri Feb 6 20:08:36 2009
New Revision: 1881
URL: http://svn.gnome.org/viewvc/brasero?rev=1881&view=rev
Log:
2009-02-06 Philippe Rouquier <ykw localhost localdomain>
Move project parsing out of brasero-project
Also fix a couple of issues when launching brasero for a one shot operation.
* src/Makefile.am:
* src/brasero-app.c (brasero_app_recent_open):
* src/brasero-audio-disc.c (brasero_audio_disc_get_track),
(brasero_audio_disc_load_track):
* src/brasero-data-disc.c (brasero_data_disc_get_track):
* src/brasero-disc.c:
* src/brasero-disc.h:
* src/brasero-project-manager.c (brasero_project_manager_switch),
(brasero_project_manager_open_project),
(brasero_project_manager_open_by_mime),
(brasero_project_manager_open_uri),
(brasero_project_manager_open_cb):
* src/brasero-project-manager.h:
* src/brasero-project-type-chooser.h:
* src/brasero-project.c (_wait_for_ready_state),
(brasero_project_check_status), (brasero_project_open_project),
(brasero_project_load_session), (brasero_project_save_project_xml),
(brasero_project_save_project_real):
* src/brasero-project.h:
* src/brasero-video-disc.c (brasero_video_disc_get_track),
(brasero_video_disc_load_track):
* src/main.c (brasero_app_open_project),
(brasero_app_parse_options):
Make sure filenames are UTF-8 encoded.
* src/brasero-data-tree-model.c
(brasero_data_tree_model_get_value):
Modified:
trunk/ChangeLog
trunk/src/Makefile.am
trunk/src/brasero-app.c
trunk/src/brasero-audio-disc.c
trunk/src/brasero-data-disc.c
trunk/src/brasero-data-tree-model.c
trunk/src/brasero-disc.c
trunk/src/brasero-disc.h
trunk/src/brasero-project-manager.c
trunk/src/brasero-project-manager.h
trunk/src/brasero-project-type-chooser.h
trunk/src/brasero-project.c
trunk/src/brasero-project.h
trunk/src/brasero-video-disc.c
trunk/src/main.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Fri Feb 6 20:08:36 2009
@@ -221,7 +221,9 @@
eggsmclient.c \
eggsmclient.h \
eggsmclient-private.h \
- eggsmclient-xsmp.c
+ eggsmclient-xsmp.c \
+ brasero-project-parse.c \
+ brasero-project-parse.h
if BUILD_INOTIFY
brasero_SOURCES += brasero-file-monitor.c brasero-file-monitor.h
Modified: trunk/src/brasero-app.c
==============================================================================
--- trunk/src/brasero-app.c (original)
+++ trunk/src/brasero-app.c Fri Feb 6 20:08:36 2009
@@ -1149,6 +1149,8 @@
return;
}
+ /* Make sure it is no longer one shot */
+ brasero_project_manager_set_oneshot (BRASERO_PROJECT_MANAGER (priv->projects), FALSE);
brasero_project_manager_open_by_mime (BRASERO_PROJECT_MANAGER (priv->projects),
uri,
mime);
Modified: trunk/src/brasero-audio-disc.c
==============================================================================
--- trunk/src/brasero-audio-disc.c (original)
+++ trunk/src/brasero-audio-disc.c Fri Feb 6 20:08:36 2009
@@ -1954,7 +1954,7 @@
if (!gtk_tree_model_get_iter_first (model, &iter))
return BRASERO_DISC_ERROR_EMPTY_SELECTION;
- track->type = BRASERO_DISC_TRACK_AUDIO;
+ track->type = BRASERO_PROJECT_TYPE_AUDIO;
song = NULL;
do {
@@ -2188,7 +2188,7 @@
{
GSList *iter;
- g_return_val_if_fail (track->type == BRASERO_DISC_TRACK_AUDIO, FALSE);
+ g_return_val_if_fail (track->type == BRASERO_PROJECT_TYPE_AUDIO, FALSE);
if (track->contents.tracks == NULL)
return BRASERO_DISC_ERROR_EMPTY_SELECTION;
Modified: trunk/src/brasero-data-disc.c
==============================================================================
--- trunk/src/brasero-data-disc.c (original)
+++ trunk/src/brasero-data-disc.c Fri Feb 6 20:08:36 2009
@@ -1510,7 +1510,7 @@
if (!grafts)
return BRASERO_DISC_ERROR_EMPTY_SELECTION;
- track->type = BRASERO_DISC_TRACK_DATA;
+ track->type = BRASERO_PROJECT_TYPE_DATA;
track->contents.data.grafts = grafts;
track->contents.data.excluded = unreadable;
Modified: trunk/src/brasero-data-tree-model.c
==============================================================================
--- trunk/src/brasero-data-tree-model.c (original)
+++ trunk/src/brasero-data-tree-model.c Fri Feb 6 20:08:36 2009
@@ -480,10 +480,23 @@
g_value_set_boolean (value, (node->is_imported == FALSE) && node->is_selected);
return;
- case BRASERO_DATA_TREE_MODEL_NAME:
+ case BRASERO_DATA_TREE_MODEL_NAME: {
+ gchar *filename;
+
g_value_init (value, G_TYPE_STRING);
- g_value_set_string (value, BRASERO_FILE_NODE_NAME (node));
+ filename = g_filename_to_utf8 (BRASERO_FILE_NODE_NAME (node),
+ -1,
+ NULL,
+ NULL,
+ NULL);
+ if (filename)
+ g_value_set_string (value, filename);
+ else /* Glib section on g_convert advise to use a string like
+ * "Invalid Filename". */
+ g_value_set_string (value, BRASERO_FILE_NODE_NAME (node));
+
return;
+ }
case BRASERO_DATA_TREE_MODEL_MIME_DESC:
g_value_init (value, G_TYPE_STRING);
Modified: trunk/src/brasero-disc.c
==============================================================================
--- trunk/src/brasero-disc.c (original)
+++ trunk/src/brasero-disc.c Fri Feb 6 20:08:36 2009
@@ -716,44 +716,3 @@
return notebook;
}
-/************************************ ******************************************/
-static void
-brasero_track_clear_song (gpointer data)
-{
- BraseroDiscSong *song;
-
- song = data;
-
- if (song->info)
- brasero_song_info_free (song->info);
-
- g_free (song->uri);
- g_free (song);
-}
-
-void
-brasero_track_clear (BraseroDiscTrack *track)
-{
- if (!track)
- return;
-
- if (track->type == BRASERO_DISC_TRACK_AUDIO) {
- g_slist_foreach (track->contents.tracks, (GFunc) brasero_track_clear_song, NULL);
- g_slist_free (track->contents.tracks);
- }
- else if (track->type == BRASERO_DISC_TRACK_DATA) {
- 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);
-}
Modified: trunk/src/brasero-disc.h
==============================================================================
--- trunk/src/brasero-disc.h (original)
+++ trunk/src/brasero-disc.h Fri Feb 6 20:08:36 2009
@@ -1,5 +1,5 @@
/***************************************************************************
- * disc.h
+ * brasero-disc.h
*
* dim nov 27 14:58:13 2005
* Copyright 2005 Rouquier Philippe
@@ -32,6 +32,7 @@
#include <gtk/gtk.h>
+#include "brasero-project-parse.h"
#include "burn-basics.h"
#include "burn-session.h"
@@ -63,37 +64,6 @@
BRASERO_DISC_ERROR_UNKNOWN
} BraseroDiscResult;
-typedef enum {
- BRASERO_DISC_TRACK_NONE = 0,
- BRASERO_DISC_TRACK_AUDIO,
- BRASERO_DISC_TRACK_VIDEO,
- BRASERO_DISC_TRACK_DATA,
-} BraseroDiscTrackType;
-
-struct _BraseroDiscSong {
- gchar *uri;
- gint64 gap;
- gint64 start;
- gint64 end;
-
- BraseroSongInfo *info;
-};
-typedef struct _BraseroDiscSong BraseroDiscSong;
-
-typedef struct {
- BraseroDiscTrackType type;
-
- union {
- struct {
- GSList *grafts;
- GSList *excluded;
- GSList *restored;
- } data;
-
- GSList *tracks; /* BraseroDiscSong */
- } contents;
-} BraseroDiscTrack;
-
typedef struct _BraseroDisc BraseroDisc;
typedef struct _BraseroDiscIface BraseroDiscIface;
@@ -198,10 +168,6 @@
void
brasero_disc_selection_changed (BraseroDisc *disc);
-void
-brasero_track_clear (BraseroDiscTrack *track);
-void
-brasero_track_free (BraseroDiscTrack *track);
GtkWidget *
brasero_disc_get_use_info_notebook (void);
Modified: trunk/src/brasero-project-manager.c
==============================================================================
--- trunk/src/brasero-project-manager.c (original)
+++ trunk/src/brasero-project-manager.c Fri Feb 6 20:08:36 2009
@@ -544,7 +544,6 @@
action = gtk_action_group_get_action (manager->priv->action_group, "NewChoose");
manager->priv->type = type;
-
if (type == BRASERO_PROJECT_TYPE_INVALID) {
brasero_layout_load (BRASERO_LAYOUT (manager->priv->layout), BRASERO_LAYOUT_NONE);
brasero_project_set_none (BRASERO_PROJECT (manager->priv->project));
@@ -761,75 +760,34 @@
BraseroProjectType
brasero_project_manager_open_project (BraseroProjectManager *manager,
- const gchar *uri)
+ BraseroDiscTrack *track,
+ const gchar *uri,
+ gboolean burn)
{
- BraseroProjectType type;
GtkAction *action;
+ BraseroProjectType type;
- gtk_widget_show (manager->priv->layout);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (manager), 1);
- type = brasero_project_open_project (BRASERO_PROJECT (manager->priv->project), uri);
-
- manager->priv->type = type;
- if (type == BRASERO_PROJECT_TYPE_INVALID) {
+ if (track->type == BRASERO_PROJECT_TYPE_INVALID) {
brasero_project_manager_switch (manager, BRASERO_PROJECT_TYPE_INVALID, NULL, NULL, TRUE);
return BRASERO_PROJECT_TYPE_INVALID;
}
- if (type == BRASERO_PROJECT_TYPE_DATA)
- brasero_layout_load (BRASERO_LAYOUT (manager->priv->layout), BRASERO_LAYOUT_DATA);
- else
- brasero_layout_load (BRASERO_LAYOUT (manager->priv->layout), BRASERO_LAYOUT_AUDIO);
-
- action = gtk_action_group_get_action (manager->priv->action_group, "NewChoose");
- gtk_action_set_sensitive (action, TRUE);
-
- return type;
-}
-
-void
-brasero_project_manager_burn_project (BraseroProjectManager *manager,
- const gchar *uri)
-{
- BraseroProjectType type;
-
- brasero_project_manager_set_oneshot (manager, TRUE);
- type = brasero_project_open_project (BRASERO_PROJECT (manager->priv->project), uri);
+ 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;
-
- manager->priv->type = type;
- brasero_project_burn (BRASERO_PROJECT (manager->priv->project));
-}
-
-#ifdef BUILD_PLAYLIST
-
-BraseroProjectType
-brasero_project_manager_open_playlist (BraseroProjectManager *manager,
- const gchar *uri)
-{
- BraseroProjectType type;
- GtkAction *action;
-
- gtk_widget_show (manager->priv->layout);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (manager), 1);
- type = brasero_project_open_playlist (BRASERO_PROJECT (manager->priv->project), uri);
- manager->priv->type = type;
+ return type;
- if (type == BRASERO_PROJECT_TYPE_INVALID) {
- brasero_project_manager_switch (manager, BRASERO_PROJECT_TYPE_INVALID, NULL, NULL, TRUE);
- return BRASERO_PROJECT_TYPE_INVALID;
+ if (burn) {
+ brasero_project_burn (BRASERO_PROJECT (manager->priv->project));
+ return track->type;
}
- brasero_layout_load (BRASERO_LAYOUT (manager->priv->layout), BRASERO_LAYOUT_AUDIO);
action = gtk_action_group_get_action (manager->priv->action_group, "NewChoose");
gtk_action_set_sensitive (action, TRUE);
- return BRASERO_PROJECT_TYPE_AUDIO;
+ return track->type;
}
-#endif
-
BraseroProjectType
brasero_project_manager_open_by_mime (BraseroProjectManager *manager,
const gchar *uri,
@@ -838,16 +796,28 @@
/* 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"))
- return brasero_project_manager_open_project (manager, uri);
+ || !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);
+ }
#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"))
- return brasero_project_manager_open_playlist (manager, uri);
+ || !strcmp (mime, "audio/x-mpegurl")) {
+ BraseroDiscTrack *track = NULL;
+
+ 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")
@@ -873,7 +843,7 @@
/* FIXME: make that asynchronous */
/* NOTE: don't follow symlink because we want to identify them */
file = g_file_new_for_commandline_arg (uri_arg);
- if (file)
+ if (!file)
return BRASERO_PROJECT_TYPE_INVALID;
info = g_file_query_info (file,
@@ -966,7 +936,6 @@
gint answer;
GtkWidget *chooser;
GtkWidget *toplevel;
- BraseroProjectType type;
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (manager));
chooser = gtk_file_chooser_dialog_new (_("Open Project"),
@@ -990,7 +959,7 @@
gtk_widget_destroy (chooser);
manager->priv->oneshot = FALSE;
- type = brasero_project_manager_open_uri (manager, uri);
+ brasero_project_manager_open_uri (manager, uri);
g_free (uri);
}
Modified: trunk/src/brasero-project-manager.h
==============================================================================
--- trunk/src/brasero-project-manager.h (original)
+++ trunk/src/brasero-project-manager.h Fri Feb 6 20:08:36 2009
@@ -33,6 +33,7 @@
#include <gtk/gtk.h>
#include "brasero-medium.h"
+#include "brasero-project-parse.h"
#include "brasero-project-type-chooser.h"
G_BEGIN_DECLS
@@ -78,17 +79,12 @@
void
brasero_project_manager_iso (BraseroProjectManager *manager,
const gchar *uri);
-void
-brasero_project_manager_burn_project (BraseroProjectManager *manager,
- const gchar *uri);
-
-BraseroProjectType
-brasero_project_manager_open_playlist (BraseroProjectManager *manager,
- const gchar *uri);
BraseroProjectType
brasero_project_manager_open_project (BraseroProjectManager *manager,
- const gchar *uri);
+ BraseroDiscTrack *track,
+ const gchar *uri,
+ gboolean burn);
BraseroProjectType
brasero_project_manager_open_by_mime (BraseroProjectManager *manager,
Modified: trunk/src/brasero-project-type-chooser.h
==============================================================================
--- trunk/src/brasero-project-type-chooser.h (original)
+++ trunk/src/brasero-project-type-chooser.h Fri Feb 6 20:08:36 2009
@@ -32,6 +32,8 @@
#include <gtk/gtk.h>
+#include "brasero-project-parse.h"
+
G_BEGIN_DECLS
#define BRASERO_TYPE_PROJECT_TYPE_CHOOSER (brasero_project_type_chooser_get_type ())
@@ -48,15 +50,6 @@
BraseroProjectTypeChooserPrivate *priv;
} BraseroProjectTypeChooser;
-typedef enum {
- BRASERO_PROJECT_TYPE_INVALID,
- BRASERO_PROJECT_TYPE_COPY,
- BRASERO_PROJECT_TYPE_ISO,
- BRASERO_PROJECT_TYPE_AUDIO,
- BRASERO_PROJECT_TYPE_DATA,
- BRASERO_PROJECT_TYPE_VIDEO
-} BraseroProjectType;
-
typedef struct {
GtkEventBoxClass parent_class;
Modified: trunk/src/brasero-project.c
==============================================================================
--- trunk/src/brasero-project.c (original)
+++ trunk/src/brasero-project.c Fri Feb 6 20:08:36 2009
@@ -24,12 +24,12 @@
* Boston, MA 02110-1301, USA.
*/
-#include <string.h>
-
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
+#include <string.h>
+
#include <glib.h>
#include <glib/gstdio.h>
#include <glib/gi18n.h>
@@ -73,6 +73,7 @@
#include "brasero-disc-message.h"
#include "brasero-file-chooser.h"
#include "brasero-notify.h"
+#include "brasero-project-parse.h"
#include "brasero-burn-options.h"
#include "brasero-project-name.h"
@@ -702,6 +703,7 @@
{
gchar *current_task = NULL;
GtkProgressBar *progress;
+ BraseroDiscResult status;
BraseroProject *project;
gint remaining = 0;
gint initial;
@@ -714,7 +716,8 @@
progress = g_object_get_data (G_OBJECT (dialog), "ProgressBar");
initial = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), "Remaining"));
- if (brasero_disc_get_status (project->priv->current, &remaining, ¤t_task) == BRASERO_DISC_NOT_READY) {
+ 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;
@@ -768,7 +771,7 @@
current_task = NULL;
result = brasero_disc_get_status (disc, &remaining, ¤t_task);
- if (result != BRASERO_DISC_NOT_READY)
+ if (result != BRASERO_DISC_NOT_READY && result != BRASERO_DISC_LOADING)
return result;
/* we are not ready to create tracks presumably because
@@ -1647,640 +1650,69 @@
}
/******************************* Projects **************************************/
-static void
-brasero_project_invalid_project_dialog (BraseroProject *project,
- const char *reason)
-{
- brasero_app_alert (brasero_app_get_default (),
- _("Error while loading the project."),
- reason,
- GTK_MESSAGE_ERROR);
-}
-
-static gboolean
-_read_graft_point (xmlDocPtr project,
- xmlNodePtr graft,
- BraseroDiscTrack *track)
-{
- BraseroGraftPt *retval;
-
- retval = g_new0 (BraseroGraftPt, 1);
- while (graft) {
- if (!xmlStrcmp (graft->name, (const xmlChar *) "uri")) {
- xmlChar *uri;
-
- if (retval->uri)
- goto error;
-
- uri = xmlNodeListGetString (project,
- graft->xmlChildrenNode,
- 1);
- retval->uri = g_uri_unescape_string ((char *)uri, NULL);
- g_free (uri);
- if (!retval->uri)
- goto error;
- }
- else if (!xmlStrcmp (graft->name, (const xmlChar *) "path")) {
- if (retval->path)
- goto error;
-
- retval->path = (char *) xmlNodeListGetString (project,
- graft->xmlChildrenNode,
- 1);
- 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;
-
-error:
- brasero_graft_point_free (retval);
- return FALSE;
-}
-
-static BraseroDiscTrack *
-_read_data_track (xmlDocPtr project,
- xmlNodePtr item)
-{
- BraseroDiscTrack *track;
-
- track = g_new0 (BraseroDiscTrack, 1);
- track->type = BRASERO_DISC_TRACK_DATA;
-
- while (item) {
- if (!xmlStrcmp (item->name, (const xmlChar *) "graft")) {
- if (!_read_graft_point (project, item->xmlChildrenNode, track))
- goto error;
- }
- else if (!xmlStrcmp (item->name, (const xmlChar *) "restored")) {
- xmlChar *restored;
-
- restored = xmlNodeListGetString (project,
- item->xmlChildrenNode,
- 1);
- if (!restored)
- goto error;
-
- track->contents.data.restored = g_slist_prepend (track->contents.data.restored, restored);
- }
- else if (!xmlStrcmp (item->name, (const xmlChar *) "excluded")) {
- xmlChar *excluded;
-
- excluded = xmlNodeListGetString (project,
- item->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 (item->type == XML_ELEMENT_NODE)
- goto error;
-
- 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;
-
-error:
- brasero_track_free (track);
- return NULL;
-}
-
-static BraseroDiscTrack *
-_read_audio_track (xmlDocPtr project,
- xmlNodePtr uris)
-{
- BraseroDiscTrack *track;
- BraseroDiscSong *song;
-
- track = g_new0 (BraseroDiscTrack, 1);
- song = NULL;
-
- while (uris) {
- if (!xmlStrcmp (uris->name, (const xmlChar *) "uri")) {
- xmlChar *uri;
-
- uri = xmlNodeListGetString (project,
- uris->xmlChildrenNode,
- 1);
- if (!uri)
- goto error;
-
- song = g_new0 (BraseroDiscSong, 1);
- song->uri = g_uri_unescape_string ((char *) uri, NULL);
-
- /* 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);
- }
- 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)
- goto error;
-
- silence = (gchar *) xmlNodeListGetString (project,
- uris->xmlChildrenNode,
- 1);
- if (!silence)
- goto error;
-
- song->gap = (gint64) 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);
- 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);
- g_free (end);
- }
- else if (!xmlStrcmp (uris->name, (const xmlChar *) "title")) {
- xmlChar *title;
-
- title = xmlNodeListGetString (project,
- uris->xmlChildrenNode,
- 1);
- if (!title)
- goto error;
-
- if (!song->info)
- song->info = g_new0 (BraseroSongInfo, 1);
-
- if (song->info->title)
- g_free (song->info->title);
-
- song->info->title = g_uri_unescape_string ((char *) title, NULL);
- g_free (title);
- }
- else if (!xmlStrcmp (uris->name, (const xmlChar *) "artist")) {
- xmlChar *artist;
-
- artist = xmlNodeListGetString (project,
- uris->xmlChildrenNode,
- 1);
- if (!artist)
- goto error;
-
- if (!song->info)
- song->info = g_new0 (BraseroSongInfo, 1);
-
- if (song->info->artist)
- g_free (song->info->artist);
-
- song->info->artist = g_uri_unescape_string ((char *) artist, NULL);
- g_free (artist);
- }
- else if (!xmlStrcmp (uris->name, (const xmlChar *) "composer")) {
- xmlChar *composer;
-
- composer = xmlNodeListGetString (project,
- uris->xmlChildrenNode,
- 1);
- if (!composer)
- goto error;
-
- if (!song->info)
- song->info = g_new0 (BraseroSongInfo, 1);
-
- if (song->info->composer)
- g_free (song->info->composer);
-
- song->info->composer = g_uri_unescape_string ((char *) composer, NULL);
- g_free (composer);
- }
- else if (!xmlStrcmp (uris->name, (const xmlChar *) "isrc")) {
- gchar *isrc;
-
- isrc = (gchar *) xmlNodeListGetString (project,
- uris->xmlChildrenNode,
- 1);
- if (!isrc)
- goto error;
-
- if (!song->info)
- song->info = g_new0 (BraseroSongInfo, 1);
-
- song->info->isrc = (gint) g_ascii_strtod (isrc, NULL);
- g_free (isrc);
- }
- else if (uris->type == XML_ELEMENT_NODE)
- goto error;
-
- uris = uris->next;
- }
-
- track->contents.tracks = g_slist_reverse (track->contents.tracks);
- return (BraseroDiscTrack*) track;
-
-error:
- brasero_track_free ((BraseroDiscTrack *) track);
- return NULL;
-}
-
-static gboolean
-_get_tracks (xmlDocPtr project,
- xmlNodePtr track_node,
- BraseroDiscTrack **track)
-{
- BraseroDiscTrack *newtrack;
-
- track_node = track_node->xmlChildrenNode;
-
- newtrack = NULL;
- while (track_node) {
- if (!xmlStrcmp (track_node->name, (const xmlChar *) "audio")) {
- if (newtrack)
- goto error;
-
- newtrack = _read_audio_track (project,
- track_node->xmlChildrenNode);
- if (!newtrack)
- goto error;
-
- newtrack->type = BRASERO_DISC_TRACK_AUDIO;
- }
- else if (!xmlStrcmp (track_node->name, (const xmlChar *) "data")) {
- if (newtrack)
- goto error;
-
- newtrack = _read_data_track (project,
- track_node->xmlChildrenNode);
-
- if (!newtrack)
- goto error;
- }
- else if (!xmlStrcmp (track_node->name, (const xmlChar *) "video")) {
- if (newtrack)
- goto error;
-
- newtrack = _read_audio_track (project,
- track_node->xmlChildrenNode);
-
- if (!newtrack)
- goto error;
-
- newtrack->type = BRASERO_DISC_TRACK_VIDEO;
- }
- else if (track_node->type == XML_ELEMENT_NODE)
- goto error;
-
- track_node = track_node->next;
- }
-
- if (!newtrack)
- goto error;
-
- *track = newtrack;
- return TRUE;
-
-error :
- if (newtrack)
- brasero_track_free (newtrack);
-
- brasero_track_free (newtrack);
- return FALSE;
-}
-
-static gboolean
-brasero_project_open_project_xml (BraseroProject *proj,
- const gchar *uri,
- gchar **label,
- gchar **cover,
- BraseroDiscTrack **track,
- gboolean warn_user)
-{
- xmlNodePtr track_node = NULL;
- xmlDocPtr project;
- xmlNodePtr item;
- gboolean retval;
- gchar *path;
-
- path = g_filename_from_uri (uri, NULL, NULL);
- if (!path)
- return FALSE;
-
- /* start parsing xml doc */
- project = xmlParseFile (path);
- g_free (path);
-
- if (!project) {
- if (warn_user)
- brasero_project_invalid_project_dialog (proj, _("The project could not be opened."));
-
- return FALSE;
- }
-
- /* parses the "header" */
- item = xmlDocGetRootElement (project);
- if (!item) {
- if (warn_user)
- brasero_project_invalid_project_dialog (proj, _("The file is empty."));
-
- xmlFreeDoc (project);
- return FALSE;
- }
-
- if (xmlStrcmp (item->name, (const xmlChar *) "braseroproject")
- || item->next)
- goto error;
-
- item = item->children;
- while (item) {
- if (!xmlStrcmp (item->name, (const xmlChar *) "version")) {
- /* simply ignore it */
- }
- else if (!xmlStrcmp (item->name, (const xmlChar *) "label")) {
- *label = (gchar *) xmlNodeListGetString (project,
- item->xmlChildrenNode,
- 1);
- if (!(*label))
- goto error;
- }
- else if (!xmlStrcmp (item->name, (const xmlChar *) "cover")) {
- xmlChar *escaped;
-
- escaped = xmlNodeListGetString (project,
- item->xmlChildrenNode,
- 1);
- if (!escaped)
- goto error;
-
- *cover = g_uri_unescape_string ((char *) escaped, NULL);
- g_free (escaped);
- }
- else if (!xmlStrcmp (item->name, (const xmlChar *) "track")) {
- if (track_node)
- goto error;
-
- track_node = item;
- }
- else if (item->type == XML_ELEMENT_NODE)
- goto error;
-
- item = item->next;
- }
-
- retval = _get_tracks (project, track_node, track);
- xmlFreeDoc (project);
-
- if (!retval && warn_user)
- brasero_project_invalid_project_dialog (proj, _("It does not seem to be a valid Brasero project."));
-
- return retval;
-
-error:
-
- xmlFreeDoc (project);
- if (warn_user)
- brasero_project_invalid_project_dialog (proj, _("It does not seem to be a valid Brasero project."));
-
- return FALSE;
-}
-
BraseroProjectType
brasero_project_open_project (BraseroProject *project,
+ BraseroDiscTrack *track,
const gchar *uri) /* escaped */
{
- BraseroDiscTrack *track = NULL;
BraseroProjectType type;
- gchar *label = NULL;
- gchar *cover = NULL;
-
- if (!uri || *uri =='\0')
- return BRASERO_PROJECT_TYPE_INVALID;
- if (!brasero_project_open_project_xml (project, uri, &label, &cover, &track, TRUE))
+ if (!track)
return BRASERO_PROJECT_TYPE_INVALID;
brasero_project_update_project_size (project, 0);
- if (track->type == BRASERO_DISC_TRACK_AUDIO)
+ if (track->type == BRASERO_PROJECT_TYPE_AUDIO)
type = BRASERO_PROJECT_TYPE_AUDIO;
- else if (track->type == BRASERO_DISC_TRACK_DATA)
+ else if (track->type == BRASERO_PROJECT_TYPE_DATA)
type = BRASERO_PROJECT_TYPE_DATA;
- else if (track->type == BRASERO_DISC_TRACK_VIDEO)
+ else if (track->type == BRASERO_PROJECT_TYPE_VIDEO)
type = BRASERO_PROJECT_TYPE_VIDEO;
- else {
- brasero_track_free (track);
+ else
return BRASERO_PROJECT_TYPE_INVALID;
- }
brasero_project_switch (project, type);
- if (label) {
+ if (track->label) {
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), label);
- g_free (label);
-
+ gtk_entry_set_text (GTK_ENTRY (project->priv->name_display), track->label);
g_signal_handlers_unblock_by_func (project->priv->name_display,
brasero_project_name_changed_cb,
project);
}
- if (cover) {
+ if (track->cover) {
if (project->priv->cover)
g_free (project->priv->cover);
- project->priv->cover = cover;
+ project->priv->cover = g_strdup (track->cover);
}
brasero_disc_load_track (project->priv->current, track);
- brasero_track_free (track);
-
project->priv->modified = 0;
- brasero_project_set_uri (project, uri, type);
- return type;
-}
-
-#ifdef BUILD_PLAYLIST
-
-static void
-brasero_project_playlist_playlist_started (TotemPlParser *parser,
- const gchar *uri,
- GHashTable *metadata,
- gpointer user_data)
-{
- gchar *string;
- gchar **retval = user_data;
-
- string = g_hash_table_lookup (metadata, TOTEM_PL_PARSER_FIELD_TITLE);
- if (string)
- *retval = g_strdup (string);
-}
-
-static void
-brasero_project_playlist_entry_parsed (TotemPlParser *parser,
- const gchar *uri,
- GHashTable *metadata,
- gpointer user_data)
-{
- BraseroDiscTrack *track = user_data;
- BraseroDiscSong *song;
-
- 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);
-}
-
-static gboolean
-brasero_project_open_audio_playlist_project (BraseroProject *proj,
- const gchar *uri,
- gchar **label,
- BraseroDiscTrack **track,
- gboolean warn_user)
-{
- TotemPlParser *parser;
- TotemPlParserResult result;
- BraseroDiscTrack *new_track;
-
- new_track = g_new0 (BraseroDiscTrack, 1);
- new_track->type = BRASERO_DISC_TRACK_AUDIO;
-
- parser = totem_pl_parser_new ();
- g_object_set (parser,
- "recurse", FALSE,
- "disable-unsafe", TRUE,
- NULL);
-
- g_signal_connect (parser,
- "playlist-started",
- G_CALLBACK (brasero_project_playlist_playlist_started),
- &label);
-
- g_signal_connect (parser,
- "entry-parsed",
- G_CALLBACK (brasero_project_playlist_entry_parsed),
- new_track);
-
- result = totem_pl_parser_parse (parser, uri, FALSE);
- if (result != TOTEM_PL_PARSER_RESULT_SUCCESS) {
- if (warn_user)
- brasero_project_invalid_project_dialog (proj, _("It does not seem to be a valid Brasero project."));
-
- brasero_track_free (new_track);
- }
- else
- *track = new_track;
-
- g_object_unref (parser);
-
- return (result == TOTEM_PL_PARSER_RESULT_SUCCESS);
-}
-
-BraseroProjectType
-brasero_project_open_playlist (BraseroProject *project,
- const gchar *uri) /* escaped */
-{
- BraseroDiscTrack *track = NULL;
- gchar *label = NULL;
-
- if (!uri || *uri =='\0')
- return BRASERO_PROJECT_TYPE_INVALID;
-
- if (!brasero_project_open_audio_playlist_project (project, uri, &label, &track, TRUE))
- return BRASERO_PROJECT_TYPE_INVALID;
-
- brasero_project_update_project_size (project, 0);
- brasero_project_switch (project, BRASERO_PROJECT_TYPE_AUDIO);
-
- if (label) {
- 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 *) 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);
-
- brasero_project_add_to_recents (project, uri, FALSE);
- project->priv->modified = 0;
+ if (uri)
+ brasero_project_set_uri (project, uri, type);
- return BRASERO_PROJECT_TYPE_AUDIO;
+ return type;
}
-#endif
-
BraseroProjectType
brasero_project_load_session (BraseroProject *project, const gchar *uri)
{
BraseroDiscTrack *track = NULL;
BraseroProjectType type;
- gchar *label;
- gchar *cover;
- if (!brasero_project_open_project_xml (project, uri, &label, &cover, &track, FALSE))
+ if (!brasero_project_open_project_xml (uri, &track, FALSE))
return BRASERO_PROJECT_TYPE_INVALID;
- if (track->type == BRASERO_DISC_TRACK_AUDIO)
+ if (track->type == BRASERO_PROJECT_TYPE_AUDIO)
type = BRASERO_PROJECT_TYPE_AUDIO;
- else if (track->type == BRASERO_DISC_TRACK_DATA)
+ else if (track->type == BRASERO_PROJECT_TYPE_DATA)
type = BRASERO_PROJECT_TYPE_DATA;
- else if (track->type == BRASERO_DISC_TRACK_VIDEO)
+ else if (track->type == BRASERO_PROJECT_TYPE_VIDEO)
type = BRASERO_PROJECT_TYPE_VIDEO;
else {
brasero_track_free (track);
@@ -2292,7 +1724,7 @@
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 *) label);
+ 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);
@@ -2602,7 +2034,7 @@
if (success < 0)
goto error;
- if (track->type == BRASERO_DISC_TRACK_AUDIO) {
+ if (track->type == BRASERO_PROJECT_TYPE_AUDIO) {
success = xmlTextWriterStartElement (project, (xmlChar *) "audio");
if (success < 0)
goto error;
@@ -2615,7 +2047,7 @@
if (success < 0)
goto error;
}
- else if (track->type == BRASERO_DISC_TRACK_DATA) {
+ else if (track->type == BRASERO_PROJECT_TYPE_DATA) {
success = xmlTextWriterStartElement (project, (xmlChar *) "data");
if (success < 0)
goto error;
@@ -2628,7 +2060,7 @@
if (success < 0)
goto error;
}
- else if (track->type == BRASERO_DISC_TRACK_VIDEO) {
+ else if (track->type == BRASERO_PROJECT_TYPE_VIDEO) {
success = xmlTextWriterStartElement (project, (xmlChar *) "video");
if (success < 0)
goto error;
@@ -2903,11 +2335,11 @@
return FALSE;
}
- if (track.type == BRASERO_DISC_TRACK_AUDIO)
+ if (track.type == BRASERO_PROJECT_TYPE_AUDIO)
type = BRASERO_PROJECT_TYPE_AUDIO;
- else if (track.type == BRASERO_DISC_TRACK_DATA)
+ else if (track.type == BRASERO_PROJECT_TYPE_DATA)
type = BRASERO_PROJECT_TYPE_DATA;
- else if (track.type == BRASERO_DISC_TRACK_VIDEO)
+ else if (track.type == BRASERO_PROJECT_TYPE_VIDEO)
type = BRASERO_PROJECT_TYPE_VIDEO;
else {
brasero_track_clear (&track);
@@ -2915,7 +2347,7 @@
}
if (save_type == BRASERO_PROJECT_SAVE_XML
- || track.type == BRASERO_DISC_TRACK_DATA) {
+ || track.type == BRASERO_PROJECT_TYPE_DATA) {
brasero_project_set_uri (project, uri, type);
if (!brasero_project_save_project_xml (project,
uri ? uri : project->priv->project,
Modified: trunk/src/brasero-project.h
==============================================================================
--- trunk/src/brasero-project.h (original)
+++ trunk/src/brasero-project.h Fri Feb 6 20:08:36 2009
@@ -82,11 +82,8 @@
BraseroURIContainer *source);
BraseroProjectType
-brasero_project_open_playlist (BraseroProject *project,
- const gchar *uri);
-
-BraseroProjectType
brasero_project_open_project (BraseroProject *project,
+ BraseroDiscTrack *track,
const gchar *uri);
gboolean
Modified: trunk/src/brasero-video-disc.c
==============================================================================
--- trunk/src/brasero-video-disc.c (original)
+++ trunk/src/brasero-video-disc.c Fri Feb 6 20:08:36 2009
@@ -1383,7 +1383,7 @@
BraseroVideoProject *project;
BraseroVideoDiscPrivate *priv;
- disc_track->type = BRASERO_DISC_TRACK_VIDEO;
+ disc_track->type = BRASERO_PROJECT_TYPE_VIDEO;
priv = BRASERO_VIDEO_DISC_PRIVATE (disc);
project = BRASERO_VIDEO_PROJECT (gtk_tree_view_get_model (GTK_TREE_VIEW (priv->tree)));
@@ -1418,7 +1418,7 @@
BraseroVideoProject *project;
BraseroVideoDiscPrivate *priv;
- g_return_val_if_fail (track->type == BRASERO_DISC_TRACK_VIDEO, FALSE);
+ g_return_val_if_fail (track->type == BRASERO_PROJECT_TYPE_VIDEO, FALSE);
if (track->contents.tracks == NULL)
return BRASERO_DISC_ERROR_EMPTY_SELECTION;
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Fri Feb 6 20:08:36 2009
@@ -269,6 +269,39 @@
return;
}
+static gboolean
+brasero_app_open_project (BraseroApp *app,
+ const gchar *path,
+ gboolean playlist,
+ gboolean burn)
+{
+ BraseroDiscTrack *track = NULL;
+ BraseroProjectType type;
+ GtkWidget *manager;
+ GFile *file;
+ gchar *uri;
+
+ brasero_app_create_mainwin (app);
+
+ file = g_file_new_for_commandline_arg (path);
+ uri = g_file_get_uri (file);
+ g_object_unref (file);
+
+ if (playlist)
+ type = brasero_project_open_audio_playlist_project (uri, &track, TRUE);
+ else
+ 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_set_oneshot (BRASERO_PROJECT_MANAGER (manager), TRUE);
+ brasero_project_manager_open_project (BRASERO_PROJECT_MANAGER (manager), track, uri, burn);
+
+ return TRUE;
+}
+
static void
brasero_app_parse_options (BraseroApp *app)
{
@@ -319,42 +352,12 @@
manager = brasero_app_get_project_manager (app);
brasero_project_manager_empty (BRASERO_PROJECT_MANAGER (manager));
}
- else if (copy_project) {
- gchar *device = NULL;
-
- /* Make sure there is only one file in the remaining list for
- * specifying the source device. It could be extended to let
- * the user specify the destination device as well */
- if (files
- && files [0] != NULL
- && files [1] == NULL)
- device = files [0];
-
- brasero_app_copy_disc (app, device, cover_project);
- return;
- }
- else if (iso_uri) {
- GFile *file;
- gchar *uri;
-
- file = g_file_new_for_commandline_arg (iso_uri);
- uri = g_file_get_uri (file);
- g_object_unref (file);
-
- brasero_app_burn_image (app, uri);
- return;
- }
else if (project_uri) {
- brasero_app_create_mainwin (app);
- manager = brasero_app_get_project_manager (app);
- brasero_project_manager_set_oneshot (BRASERO_PROJECT_MANAGER (manager), TRUE);
- BRASERO_PROJECT_OPEN_URI (manager, brasero_project_manager_open_project, project_uri);
+ brasero_app_open_project (app, project_uri, FALSE, FALSE);
}
else if (burn_project_uri) {
- brasero_app_create_mainwin (app);
- manager = brasero_app_get_project_manager (app);
- brasero_project_manager_set_oneshot (BRASERO_PROJECT_MANAGER (manager), TRUE);
- BRASERO_PROJECT_OPEN_URI (manager, brasero_project_manager_burn_project, burn_project_uri);
+ brasero_app_open_project (app, burn_project_uri, FALSE, TRUE);
+
if (g_remove (burn_project_uri) != 0) {
gchar *path;
@@ -364,21 +367,19 @@
}
return;
}
- else if (open_ncb) {
- brasero_handle_burn_uri (app, manager);
- return;
- }
#ifdef BUILD_PLAYLIST
else if (playlist_uri) {
- brasero_app_create_mainwin (app);
- manager = brasero_app_get_project_manager (app);
- BRASERO_PROJECT_OPEN_URI (manager, brasero_project_manager_open_playlist, playlist_uri);
+ brasero_app_open_project (app, playlist_uri, TRUE, FALSE);
}
#endif
+ else if (open_ncb) {
+ brasero_handle_burn_uri (app, manager);
+ return;
+ }
else if (audio_project) {
brasero_app_create_mainwin (app);
manager = brasero_app_get_project_manager (app);
@@ -394,6 +395,31 @@
manager = brasero_app_get_project_manager (app);
BRASERO_PROJECT_OPEN_LIST (manager, brasero_project_manager_video, files);
}
+ else if (copy_project) {
+ gchar *device = NULL;
+
+ /* Make sure there is only one file in the remaining list for
+ * specifying the source device. It could be extended to let
+ * the user specify the destination device as well */
+ if (files
+ && files [0] != NULL
+ && files [1] == NULL)
+ device = files [0];
+
+ brasero_app_copy_disc (app, device, cover_project);
+ return;
+ }
+ else if (iso_uri) {
+ GFile *file;
+ gchar *uri;
+
+ file = g_file_new_for_commandline_arg (iso_uri);
+ uri = g_file_get_uri (file);
+ g_object_unref (file);
+
+ brasero_app_burn_image (app, uri);
+ return;
+ }
else if (disc_blank) {
gchar *device = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]