45
45
#include "brasero-project-parse.h"
46
46
#include "brasero-app.h"
48
#include "brasero-track-stream.h"
49
#include "brasero-track-data.h"
52
brasero_stream_info_free (BraseroStreamInfo *info)
58
g_free (info->artist);
59
g_free (info->composer);
64
brasero_stream_info_copy (BraseroStreamInfo *info)
66
BraseroStreamInfo *copy;
71
copy = g_new0 (BraseroStreamInfo, 1);
73
copy->title = g_strdup (info->title);
74
copy->artist = g_strdup (info->artist);
75
copy->composer = g_strdup (info->composer);
76
copy->isrc = info->isrc;
82
brasero_track_clear_song (gpointer data)
84
BraseroDiscSong *song;
89
brasero_stream_info_free (song->info);
96
brasero_track_clear (BraseroDiscTrack *track)
102
g_free (track->label);
107
g_free (track->cover);
111
if (track->type == BRASERO_PROJECT_TYPE_AUDIO) {
112
g_slist_foreach (track->contents.tracks, (GFunc) brasero_track_clear_song, NULL);
113
g_slist_free (track->contents.tracks);
115
else if (track->type == BRASERO_PROJECT_TYPE_DATA) {
116
g_free (track->contents.data.icon);
117
track->contents.data.icon = NULL;
119
g_slist_foreach (track->contents.data.grafts, (GFunc) brasero_graft_point_free, NULL);
120
g_slist_free (track->contents.data.grafts);
121
g_slist_foreach (track->contents.data.restored, (GFunc) g_free, NULL);
122
g_slist_free (track->contents.data.restored);
123
g_slist_foreach (track->contents.data.excluded, (GFunc) g_free, NULL);
124
g_slist_free (track->contents.data.excluded);
129
brasero_track_free (BraseroDiscTrack *track)
131
brasero_track_clear (track);
48
#include "brasero-units.h"
49
#include "brasero-track-stream-cfg.h"
50
#include "brasero-track-data-cfg.h"
51
#include "brasero-session.h"
52
#include "brasero-tags.h"
54
#define BRASERO_PROJECT_VERSION "0.2"
136
57
brasero_project_invalid_project_dialog (const char *reason)
138
59
brasero_app_alert (brasero_app_get_default (),
139
_("Error while loading the project"),
60
_("Error while loading the project."),
141
62
GTK_MESSAGE_ERROR);
145
66
_read_graft_point (xmlDocPtr project,
147
BraseroDiscTrack *track)
149
70
BraseroGraftPt *retval;
151
72
retval = g_new0 (BraseroGraftPt, 1);
73
grafts = g_slist_prepend (grafts, retval);
153
75
if (!xmlStrcmp (graft->name, (const xmlChar *) "uri")) {
608
_save_audio_track_xml (xmlTextWriter *project,
609
BraseroTrackStream *track)
618
uri = brasero_track_stream_get_source (track, TRUE);
619
escaped = (unsigned char *) g_uri_escape_string (uri, NULL, FALSE);
622
success = xmlTextWriterWriteElement (project,
630
if (brasero_track_stream_get_gap (track) > 0) {
633
silence = g_strdup_printf ("%"G_GINT64_FORMAT, brasero_track_stream_get_gap (track));
634
success = xmlTextWriterWriteElement (project,
635
(xmlChar *) "silence",
636
(xmlChar *) silence);
643
if (brasero_track_stream_get_end (track) > 0) {
644
/* start of the song */
645
start = g_strdup_printf ("%"G_GINT64_FORMAT, brasero_track_stream_get_start (track));
646
success = xmlTextWriterWriteElement (project,
654
/* end of the song */
655
end = g_strdup_printf ("%"G_GINT64_FORMAT, brasero_track_stream_get_end (track));
656
success = xmlTextWriterWriteElement (project,
665
if (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_TITLE_TAG)) {
666
escaped = (unsigned char *) g_uri_escape_string (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_TITLE_TAG), NULL, FALSE);
667
success = xmlTextWriterWriteElement (project,
676
if (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ARTIST_TAG)) {
677
escaped = (unsigned char *) g_uri_escape_string (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ARTIST_TAG), NULL, FALSE);
678
success = xmlTextWriterWriteElement (project,
679
(xmlChar *) "artist",
687
if (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_COMPOSER_TAG)) {
688
escaped = (unsigned char *) g_uri_escape_string (brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_COMPOSER_TAG), NULL, FALSE);
689
success = xmlTextWriterWriteElement (project,
690
(xmlChar *) "composer",
697
if (brasero_track_tag_lookup_int (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ISRC_TAG)) {
698
isrc = g_strdup_printf ("%d", brasero_track_tag_lookup_int (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ISRC_TAG));
699
success = xmlTextWriterWriteElement (project,
712
_save_data_track_xml (xmlTextWriter *project,
713
BraseroBurnSession *session)
720
BraseroTrackDataCfg *track;
722
tracks = brasero_burn_session_get_tracks (session);
723
track = BRASERO_TRACK_DATA_CFG (tracks->data);
725
if (brasero_track_data_cfg_get_icon_path (track)) {
726
/* Write the icon if any */
727
success = xmlTextWriterWriteElement (project, (xmlChar *) "icon", (xmlChar *) brasero_track_data_cfg_get_icon_path (track));
732
grafts = brasero_track_data_get_grafts (BRASERO_TRACK_DATA (track));
733
for (; grafts; grafts = grafts->next) {
734
BraseroGraftPt *graft;
736
graft = grafts->data;
738
success = xmlTextWriterStartElement (project, (xmlChar *) "graft");
742
success = xmlTextWriterWriteElement (project, (xmlChar *) "path", (xmlChar *) graft->path);
749
escaped = (unsigned char *) g_uri_escape_string (graft->uri, NULL, FALSE);
750
success = xmlTextWriterWriteElement (project, (xmlChar *) "uri", escaped);
756
success = xmlTextWriterEndElement (project); /* graft */
761
/* save excluded uris */
762
iter = brasero_track_data_get_excluded (BRASERO_TRACK_DATA (track), FALSE);
763
for (; iter; iter = iter->next) {
766
escaped = xmlURIEscapeStr ((xmlChar *) iter->data, NULL);
767
success = xmlTextWriterWriteElement (project, (xmlChar *) "excluded", (xmlChar *) escaped);
773
/* save restored uris */
774
iter = brasero_track_data_cfg_get_restored_list (track);
775
for (; iter; iter = iter->next) {
777
success = xmlTextWriterWriteElement (project, (xmlChar *) "restored", (xmlChar *) uri);
782
/* NOTE: we don't write symlinks and unreadable they are useless */
787
brasero_project_save_project_xml (BraseroBurnSession *session,
790
BraseroTrackType *track_type = NULL;
791
xmlTextWriter *project;
798
path = g_filename_from_uri (uri, NULL, NULL);
802
project = xmlNewTextWriterFilename (path, 0);
808
xmlTextWriterSetIndent (project, 1);
809
xmlTextWriterSetIndentString (project, (xmlChar *) "\t");
811
success = xmlTextWriterStartDocument (project,
818
success = xmlTextWriterStartElement (project, (xmlChar *) "braseroproject");
822
/* write the name of the version */
823
success = xmlTextWriterWriteElement (project,
824
(xmlChar *) "version",
825
(xmlChar *) BRASERO_PROJECT_VERSION);
829
if (brasero_burn_session_get_label (session)) {
830
success = xmlTextWriterWriteElement (project,
832
(xmlChar *) brasero_burn_session_get_label (session));
839
brasero_burn_session_tag_lookup (session,
845
escaped = g_uri_escape_string (g_value_get_string (value), NULL, FALSE);
846
success = xmlTextWriterWriteElement (project,
848
(xmlChar *) escaped);
855
success = xmlTextWriterStartElement (project, (xmlChar *) "track");
859
track_type = brasero_track_type_new ();
860
tracks = brasero_burn_session_get_tracks (session);
862
for (; tracks; tracks = tracks->next) {
865
track = tracks->data;
867
brasero_track_get_track_type (track, track_type);
868
if (brasero_track_type_get_has_stream (track_type)) {
869
if (BRASERO_STREAM_FORMAT_HAS_VIDEO (brasero_track_type_get_stream_format (track_type)))
870
success = xmlTextWriterStartElement (project, (xmlChar *) "video");
872
success = xmlTextWriterStartElement (project, (xmlChar *) "audio");
877
retval = _save_audio_track_xml (project, BRASERO_TRACK_STREAM (track));
881
success = xmlTextWriterEndElement (project); /* audio/video */
885
else if (brasero_track_type_get_has_data (track_type)) {
886
success = xmlTextWriterStartElement (project, (xmlChar *) "data");
890
retval = _save_data_track_xml (project, session);
894
success = xmlTextWriterEndElement (project); /* data */
902
success = xmlTextWriterEndElement (project); /* track */
906
brasero_track_type_free (track_type);
908
success = xmlTextWriterEndElement (project); /* braseroproject */
912
xmlTextWriterEndDocument (project);
913
xmlFreeTextWriter (project);
920
brasero_track_type_free (track_type);
922
xmlTextWriterEndDocument (project);
923
xmlFreeTextWriter (project);
932
brasero_project_save_audio_project_plain_text (BraseroBurnSession *session,
941
path = g_filename_from_uri (uri, NULL, NULL);
945
file = fopen (path, "w+");
951
title = brasero_burn_session_get_label (session);
952
written = fwrite (title, strlen (title), 1, file);
956
written = fwrite ("\n", 1, 1, file);
960
iter = brasero_burn_session_get_tracks (session);
961
for (; iter; iter = iter->next) {
962
BraseroTrackStream *track;
970
text = brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_TITLE_TAG);
971
written = fwrite (title, 1, strlen (title), file);
972
if (written != strlen (title))
976
brasero_track_stream_get_length (track, &len);
977
time = brasero_units_get_time_string (len, TRUE, FALSE);
979
written = fwrite ("\t", 1, 1, file);
983
written = fwrite (time, 1, strlen (time), file);
984
if (written != strlen (time)) {
991
text = brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ARTIST_TAG);
995
written = fwrite ("\t", 1, 1, file);
999
/* Translators: %s is an artist */
1000
string = g_strdup_printf (" by %s", text);
1001
written = fwrite (string, 1, strlen (string), file);
1002
if (written != strlen (string)) {
1009
written = fwrite ("\n(", 1, 2, file);
1013
uri = brasero_track_stream_get_source (track, TRUE);
1014
written = fwrite (uri, 1, strlen (uri), file);
1015
if (written != strlen (uri)) {
1022
written = fwrite (")", 1, 1, file);
1026
written = fwrite ("\n\n", 1, 2, file);
1041
#ifdef BUILD_PLAYLIST
1044
brasero_project_save_audio_playlist_entry (GtkTreeModel *model,
1048
gboolean *custom_title,
1051
gtk_tree_model_get (model, iter,
1059
brasero_project_save_audio_project_playlist (BraseroBurnSession *session,
1061
BraseroProjectSave type)
1063
TotemPlParserType pl_type;
1064
TotemPlParser *parser;
1065
GtkListStore *model;
1071
path = g_filename_from_uri (uri, NULL, NULL);
1075
parser = totem_pl_parser_new ();
1077
/* create and populate treemodel */
1078
model = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
1079
iter = brasero_burn_session_get_tracks (session);
1080
for (; iter; iter = iter->next) {
1081
BraseroTrackStream *track;
1086
uri = brasero_track_stream_get_source (track, TRUE);
1087
gtk_list_store_append (model, &t_iter);
1088
gtk_list_store_set (model, &t_iter,
1090
1, brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_TITLE_TAG),
1097
case BRASERO_PROJECT_SAVE_PLAYLIST_M3U:
1098
pl_type = TOTEM_PL_PARSER_M3U;
1100
case BRASERO_PROJECT_SAVE_PLAYLIST_XSPF:
1101
pl_type = TOTEM_PL_PARSER_XSPF;
1103
case BRASERO_PROJECT_SAVE_PLAYLIST_IRIVER_PLA:
1104
pl_type = TOTEM_PL_PARSER_IRIVER_PLA;
1107
case BRASERO_PROJECT_SAVE_PLAYLIST_PLS:
1109
pl_type = TOTEM_PL_PARSER_PLS;
1113
result = totem_pl_parser_write_with_title (parser,
1114
GTK_TREE_MODEL (model),
1115
brasero_project_save_audio_playlist_entry,
1117
brasero_burn_session_get_label (session),
1122
g_object_unref (model);
1123
g_object_unref (parser);