~mfisch/brasero/update-to-3.8.0

« back to all changes in this revision

Viewing changes to src/brasero-project-parse.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2009-07-14 14:13:00 UTC
  • mfrom: (1.1.25 upstream)
  • Revision ID: james.westby@ubuntu.com-20090714141300-e08q13sp48b2xzwd
Tags: 2.27.4-0ubuntu1
* New upstream release: (LP: #399112)
  - Hal support removed, now relies on GIO only for drives/media probing
  - New layout for size reporting in data/audio/video project
  - Lot's of bug fixes
  - Fixed some memleaks
  - Bump libbrasero-media version to reflect changes (important to packagers)
  - Fix #582261 – brasero shows 0% done, while continues burning disc
  - Fix #582513 – Bogus VIDEO_TS directory error if AUDIO_TS directory present
  - Fix #573805 – "Increase compatibility with Windows systems"?
  - Fix #585190 – remove 0 from 03 % status
  - Fix #586744 – Use AS_HELP_STRING for configure switches
  - Fix #584793 – Poor language in warning dialog when attempting to burn an audio CD onto a CDRW
  - Fix #580617 – Brasero floods .xsession-errors log with "Unknown (or already deleted) monitored directory" warnings
  - Fix #563501 – Brasero burning window shouldn't try to show drive speed while is converting audio files
  - Fix #485719 – Burn dialog CD icon
  - Fix #585481 – Deep hierarchy warning
  - Fix #554070 – The need of a "replace all" and "replace non" button
  - Fix #582461 – Brasero hangs at normalizing tracks
  - Fix #587284 – nautilus hangs every time
  - Fix #574093 – Caret visible in instructions for project creation
  - Fix #581742 – port from HAL to DeviceKit-disks
  - Fix #573801 – Bad error message when burning empty burn:///
  - Fix #573486 – Various i18n and string issues for good
  - Fix #587399 – License clarification
  - Fix #587554 – Unclear meaning of text
  - Fix #582979 – brasero should not include Categories in mime handler .desktop files
  - Fix #586040 – duplicated command listed in open-with dialog
  - Fixes for #573486 – Various i18n and string issues
* debian/control.in:
  - Add in missing comma in brasero suggests

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include "brasero-project-parse.h"
46
46
#include "brasero-app.h"
47
47
 
48
 
#include "brasero-track-stream.h"
49
 
#include "brasero-track-data.h"
50
 
 
51
 
void
52
 
brasero_stream_info_free (BraseroStreamInfo *info)
53
 
{
54
 
        if (!info)
55
 
                return;
56
 
 
57
 
        g_free (info->title);
58
 
        g_free (info->artist);
59
 
        g_free (info->composer);
60
 
        g_free (info);
61
 
}
62
 
 
63
 
BraseroStreamInfo *
64
 
brasero_stream_info_copy (BraseroStreamInfo *info)
65
 
{
66
 
        BraseroStreamInfo *copy;
67
 
 
68
 
        if (!info)
69
 
                return NULL;
70
 
 
71
 
        copy = g_new0 (BraseroStreamInfo, 1);
72
 
 
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;
77
 
 
78
 
        return copy;
79
 
}
80
 
 
81
 
static void
82
 
brasero_track_clear_song (gpointer data)
83
 
{
84
 
        BraseroDiscSong *song;
85
 
 
86
 
        song = data;
87
 
 
88
 
        if (song->info)
89
 
                brasero_stream_info_free (song->info);
90
 
 
91
 
        g_free (song->uri);
92
 
        g_free (song);
93
 
}
94
 
 
95
 
void
96
 
brasero_track_clear (BraseroDiscTrack *track)
97
 
{
98
 
        if (!track)
99
 
                return;
100
 
 
101
 
        if (track->label) {
102
 
                g_free (track->label);
103
 
                track->label = NULL;
104
 
        }
105
 
 
106
 
        if (track->cover) {
107
 
                g_free (track->cover);
108
 
                track->cover = NULL;
109
 
        }
110
 
 
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);
114
 
        }
115
 
        else if (track->type == BRASERO_PROJECT_TYPE_DATA) {
116
 
                g_free (track->contents.data.icon);
117
 
                track->contents.data.icon = NULL;
118
 
 
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);
125
 
        }
126
 
}
127
 
 
128
 
void
129
 
brasero_track_free (BraseroDiscTrack *track)
130
 
{
131
 
        brasero_track_clear (track);
132
 
        g_free (track);
133
 
}
 
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"
 
53
 
 
54
#define BRASERO_PROJECT_VERSION "0.2"
134
55
 
135
56
static void
136
57
brasero_project_invalid_project_dialog (const char *reason)
137
58
{
138
59
        brasero_app_alert (brasero_app_get_default (),
139
 
                           _("Error while loading the project"),
 
60
                           _("Error while loading the project."),
140
61
                           reason,
141
62
                           GTK_MESSAGE_ERROR);
142
63
}
143
64
 
144
 
static gboolean
 
65
static GSList *
145
66
_read_graft_point (xmlDocPtr project,
146
67
                   xmlNodePtr graft,
147
 
                   BraseroDiscTrack *track)
 
68
                   GSList *grafts)
148
69
{
149
70
        BraseroGraftPt *retval;
150
71
 
151
72
        retval = g_new0 (BraseroGraftPt, 1);
 
73
        grafts = g_slist_prepend (grafts, retval);
152
74
        while (graft) {
153
75
                if (!xmlStrcmp (graft->name, (const xmlChar *) "uri")) {
154
76
                        xmlChar *uri;
174
96
                        if (!retval->path)
175
97
                                goto error;
176
98
                }
177
 
                else if (!xmlStrcmp (graft->name, (const xmlChar *) "excluded")) {
178
 
                        xmlChar *excluded;
179
 
 
180
 
                        excluded = xmlNodeListGetString (project,
181
 
                                                         graft->xmlChildrenNode,
182
 
                                                         1);
183
 
                        if (!excluded)
184
 
                                goto error;
185
 
 
186
 
                        track->contents.data.excluded = g_slist_prepend (track->contents.data.excluded,
187
 
                                                                         xmlURIUnescapeString ((char*) excluded, 0, NULL));
188
 
                        g_free (excluded);
189
 
                }
190
99
                else if (graft->type == XML_ELEMENT_NODE)
191
100
                        goto error;
192
101
 
193
102
                graft = graft->next;
194
103
        }
195
104
 
196
 
        track->contents.data.grafts = g_slist_prepend (track->contents.data.grafts, retval);
197
 
        return TRUE;
 
105
        return grafts;
198
106
 
199
107
error:
200
 
        brasero_graft_point_free (retval);
201
 
        return FALSE;
 
108
 
 
109
        g_slist_foreach (grafts, (GFunc) brasero_graft_point_free, NULL);
 
110
        g_slist_free (grafts);
 
111
 
 
112
        return NULL;
202
113
}
203
114
 
204
 
static BraseroDiscTrack *
 
115
static BraseroTrack *
205
116
_read_data_track (xmlDocPtr project,
206
117
                  xmlNodePtr item)
207
118
{
208
 
        BraseroDiscTrack *track;
 
119
        BraseroTrackDataCfg *track;
 
120
        GSList *grafts= NULL;
 
121
        GSList *excluded = NULL;
209
122
 
210
 
        track = g_new0 (BraseroDiscTrack, 1);
211
 
        track->type = BRASERO_PROJECT_TYPE_DATA;
 
123
        track = brasero_track_data_cfg_new ();
212
124
 
213
125
        while (item) {
214
126
                if (!xmlStrcmp (item->name, (const xmlChar *) "graft")) {
215
 
                        if (!_read_graft_point (project, item->xmlChildrenNode, track))
 
127
                        if (!(grafts = _read_graft_point (project, item->xmlChildrenNode, grafts)))
216
128
                                goto error;
217
129
                }
218
130
                else if (!xmlStrcmp (item->name, (const xmlChar *) "icon")) {
224
136
                        if (!icon_path)
225
137
                                goto error;
226
138
 
227
 
                        if (track->contents.data.icon)
228
 
                                g_free (track->contents.data.icon);
229
 
 
230
 
                        track->contents.data.icon = (gchar *) icon_path;
 
139
                        brasero_track_data_cfg_set_icon (track, (gchar *) icon_path, NULL);
 
140
                        g_free (icon_path);
231
141
                }
232
142
                else if (!xmlStrcmp (item->name, (const xmlChar *) "restored")) {
233
143
                        xmlChar *restored;
238
148
                        if (!restored)
239
149
                                goto error;
240
150
 
241
 
                        track->contents.data.restored = g_slist_prepend (track->contents.data.restored, restored);
 
151
                        brasero_track_data_cfg_dont_filter_uri (track, (gchar *) restored);
 
152
                        g_free (restored);
242
153
                }
243
154
                else if (!xmlStrcmp (item->name, (const xmlChar *) "excluded")) {
244
 
                        xmlChar *excluded;
 
155
                        xmlChar *excluded_uri;
245
156
 
246
 
                        excluded = xmlNodeListGetString (project,
247
 
                                                         item->xmlChildrenNode,
248
 
                                                         1);
249
 
                        if (!excluded)
 
157
                        excluded_uri = xmlNodeListGetString (project,
 
158
                                                             item->xmlChildrenNode,
 
159
                                                             1);
 
160
                        if (!excluded_uri)
250
161
                                goto error;
251
162
 
252
 
                        track->contents.data.excluded = g_slist_prepend (track->contents.data.excluded,
253
 
                                                                         xmlURIUnescapeString ((char*) excluded, 0, NULL));
254
 
                        g_free (excluded);
 
163
                        excluded = g_slist_prepend (excluded, xmlURIUnescapeString ((char*) excluded_uri, 0, NULL));
 
164
                        g_free (excluded_uri);
255
165
                }
256
166
                else if (item->type == XML_ELEMENT_NODE)
257
167
                        goto error;
259
169
                item = item->next;
260
170
        }
261
171
 
262
 
        track->contents.data.excluded = g_slist_reverse (track->contents.data.excluded);
263
 
        track->contents.data.grafts = g_slist_reverse (track->contents.data.grafts);
264
 
        return track;
 
172
        grafts = g_slist_reverse (grafts);
 
173
        excluded = g_slist_reverse (excluded);
 
174
        brasero_track_data_set_source (BRASERO_TRACK_DATA (track),
 
175
                                                           grafts,
 
176
                                                           excluded);
 
177
        return BRASERO_TRACK (track);
265
178
 
266
179
error:
267
 
        brasero_track_free (track);
 
180
 
 
181
        g_slist_foreach (grafts, (GFunc) brasero_graft_point_free, NULL);
 
182
        g_slist_free (grafts);
 
183
 
 
184
        g_slist_foreach (excluded, (GFunc) g_free, NULL);
 
185
        g_slist_free (excluded);
 
186
 
 
187
        g_object_unref (track);
 
188
 
268
189
        return NULL;
269
190
}
270
191
 
271
 
static BraseroDiscTrack *
 
192
static BraseroTrack *
272
193
_read_audio_track (xmlDocPtr project,
273
 
                   xmlNodePtr uris)
 
194
                   xmlNodePtr uris,
 
195
                   gboolean is_video)
274
196
{
275
 
        BraseroDiscTrack *track;
276
 
        BraseroDiscSong *song;
 
197
        BraseroTrackStreamCfg *track;
277
198
 
278
 
        track = g_new0 (BraseroDiscTrack, 1);
279
 
        song = NULL;
 
199
        track = brasero_track_stream_cfg_new ();
280
200
 
281
201
        while (uris) {
282
202
                if (!xmlStrcmp (uris->name, (const xmlChar *) "uri")) {
283
203
                        xmlChar *uri;
 
204
                        gchar *unescaped_uri;
284
205
 
285
206
                        uri = xmlNodeListGetString (project,
286
207
                                                    uris->xmlChildrenNode,
288
209
                        if (!uri)
289
210
                                goto error;
290
211
 
291
 
                        song = g_new0 (BraseroDiscSong, 1);
292
 
                        song->uri = g_uri_unescape_string ((char *) uri, NULL);
293
 
 
294
 
                        /* to know if this info was set or not */
295
 
                        song->start = -1;
296
 
                        song->end = -1;
297
 
                        g_free (uri);
298
 
                        track->contents.tracks = g_slist_prepend (track->contents.tracks, song);
 
212
                        unescaped_uri = g_uri_unescape_string ((char *) uri, NULL);
 
213
                        g_free (uri);
 
214
 
 
215
                        brasero_track_stream_set_source (BRASERO_TRACK_STREAM (track), unescaped_uri);
 
216
 
 
217
                        /* For the moment pretend it is a video file. Since it is BraseroTrackStreamCfg, that
 
218
                         * will be set properly afterwards. */
 
219
                        if (is_video)
 
220
                                brasero_track_stream_set_format (BRASERO_TRACK_STREAM (track),
 
221
                                                                 BRASERO_VIDEO_FORMAT_UNDEFINED);
 
222
 
 
223
                        g_free (unescaped_uri);
299
224
                }
300
225
                else if (!xmlStrcmp (uris->name, (const xmlChar *) "silence")) {
301
226
                        gchar *silence;
302
227
 
303
 
                        if (!song)
304
 
                                goto error;
305
 
 
306
228
                        /* impossible to have two gaps in a row */
307
 
                        if (song->gap)
 
229
                        if (brasero_track_stream_get_gap (BRASERO_TRACK_STREAM (track)) > 0)
308
230
                                goto error;
309
231
 
310
232
                        silence = (gchar *) xmlNodeListGetString (project,
313
235
                        if (!silence)
314
236
                                goto error;
315
237
 
316
 
                        song->gap = (gint64) g_ascii_strtoull (silence, NULL, 10);
 
238
                        brasero_track_stream_set_boundaries (BRASERO_TRACK_STREAM (track),
 
239
                                                                                     -1,
 
240
                                                                                     -1,
 
241
                                                                                     g_ascii_strtoull (silence, NULL, 10));
317
242
                        g_free (silence);
318
243
                }
319
244
                else if (!xmlStrcmp (uris->name, (const xmlChar *) "start")) {
320
245
                        gchar *start;
321
246
 
322
 
                        if (!song)
323
 
                                goto error;
324
 
 
325
247
                        start = (gchar *) xmlNodeListGetString (project,
326
248
                                                                uris->xmlChildrenNode,
327
249
                                                                1);
328
250
                        if (!start)
329
251
                                goto error;
330
252
 
331
 
                        song->start = (gint64) g_ascii_strtoull (start, NULL, 10);
 
253
                        brasero_track_stream_set_boundaries (BRASERO_TRACK_STREAM (track),
 
254
                                                                                     -1,
 
255
                                                                                     g_ascii_strtoull (start, NULL, 10),
 
256
                                                                                     -1);
332
257
                        g_free (start);
333
258
                }
334
259
                else if (!xmlStrcmp (uris->name, (const xmlChar *) "end")) {
335
260
                        gchar *end;
336
261
 
337
 
                        if (!song)
338
 
                                goto error;
339
 
 
340
262
                        end = (gchar *) xmlNodeListGetString (project,
341
263
                                                              uris->xmlChildrenNode,
342
264
                                                              1);
343
265
                        if (!end)
344
266
                                goto error;
345
267
 
346
 
                        song->end = (gint64) g_ascii_strtoull (end, NULL, 10);
 
268
                        brasero_track_stream_set_boundaries (BRASERO_TRACK_STREAM (track),
 
269
                                                                                      g_ascii_strtoull (end, NULL, 10),
 
270
                                                                                      -1,
 
271
                                                                                      -1);
347
272
                        g_free (end);
348
273
                }
349
274
                else if (!xmlStrcmp (uris->name, (const xmlChar *) "title")) {
350
275
                        xmlChar *title;
 
276
                        gchar *unescaped_title;
351
277
 
352
278
                        title = xmlNodeListGetString (project,
353
279
                                                      uris->xmlChildrenNode,
355
281
                        if (!title)
356
282
                                goto error;
357
283
 
358
 
                        if (!song->info)
359
 
                                song->info = g_new0 (BraseroStreamInfo, 1);
360
 
 
361
 
                        if (song->info->title)
362
 
                                g_free (song->info->title);
363
 
 
364
 
                        song->info->title = g_uri_unescape_string ((char *) title, NULL);
365
 
                        g_free (title);
 
284
                        unescaped_title = g_uri_unescape_string ((char *) title, NULL);
 
285
                        g_free (title);
 
286
 
 
287
                        brasero_track_tag_add_string (BRASERO_TRACK (track),
 
288
                                                      BRASERO_TRACK_STREAM_TITLE_TAG,
 
289
                                                      unescaped_title);
 
290
                        g_free (unescaped_title);
366
291
                }
367
292
                else if (!xmlStrcmp (uris->name, (const xmlChar *) "artist")) {
368
293
                        xmlChar *artist;
 
294
                        gchar *unescaped_artist;
369
295
 
370
296
                        artist = xmlNodeListGetString (project,
371
297
                                                      uris->xmlChildrenNode,
373
299
                        if (!artist)
374
300
                                goto error;
375
301
 
376
 
                        if (!song->info)
377
 
                                song->info = g_new0 (BraseroStreamInfo, 1);
378
 
 
379
 
                        if (song->info->artist)
380
 
                                g_free (song->info->artist);
381
 
 
382
 
                        song->info->artist = g_uri_unescape_string ((char *) artist, NULL);
 
302
                        unescaped_artist = g_uri_unescape_string ((char *) artist, NULL);
383
303
                        g_free (artist);
 
304
 
 
305
                        brasero_track_tag_add_string (BRASERO_TRACK (track),
 
306
                                                      BRASERO_TRACK_STREAM_ARTIST_TAG,
 
307
                                                      unescaped_artist);
 
308
                        g_free (unescaped_artist);
384
309
                }
385
310
                else if (!xmlStrcmp (uris->name, (const xmlChar *) "composer")) {
386
311
                        xmlChar *composer;
 
312
                        gchar *unescaped_composer;
387
313
 
388
314
                        composer = xmlNodeListGetString (project,
389
315
                                                         uris->xmlChildrenNode,
391
317
                        if (!composer)
392
318
                                goto error;
393
319
 
394
 
                        if (!song->info)
395
 
                                song->info = g_new0 (BraseroStreamInfo, 1);
396
 
 
397
 
                        if (song->info->composer)
398
 
                                g_free (song->info->composer);
399
 
 
400
 
                        song->info->composer = g_uri_unescape_string ((char *) composer, NULL);
 
320
                        unescaped_composer = g_uri_unescape_string ((char *) composer, NULL);
401
321
                        g_free (composer);
 
322
 
 
323
                        brasero_track_tag_add_string (BRASERO_TRACK (track),
 
324
                                                      BRASERO_TRACK_STREAM_COMPOSER_TAG,
 
325
                                                      unescaped_composer);
 
326
                        g_free (unescaped_composer);
402
327
                }
403
328
                else if (!xmlStrcmp (uris->name, (const xmlChar *) "isrc")) {
404
329
                        gchar *isrc;
409
334
                        if (!isrc)
410
335
                                goto error;
411
336
 
412
 
                        if (!song->info)
413
 
                                song->info = g_new0 (BraseroStreamInfo, 1);
414
 
 
415
 
                        song->info->isrc = (gint) g_ascii_strtod (isrc, NULL);
 
337
                        brasero_track_tag_add_int (BRASERO_TRACK (track),
 
338
                                                   BRASERO_TRACK_STREAM_ISRC_TAG,
 
339
                                                   (gint) g_ascii_strtod (isrc, NULL));
416
340
                        g_free (isrc);
417
341
                }
418
342
                else if (uris->type == XML_ELEMENT_NODE)
421
345
                uris = uris->next;
422
346
        }
423
347
 
424
 
        track->contents.tracks = g_slist_reverse (track->contents.tracks);
425
 
        return (BraseroDiscTrack*) track;
 
348
        return BRASERO_TRACK (track);
426
349
 
427
350
error:
428
 
        brasero_track_free ((BraseroDiscTrack *) track);
 
351
 
 
352
        g_object_unref (track);
 
353
 
429
354
        return NULL;
430
355
}
431
356
 
432
357
static gboolean
433
358
_get_tracks (xmlDocPtr project,
434
359
             xmlNodePtr track_node,
435
 
             BraseroDiscTrack **track)
 
360
             BraseroBurnSession *session)
436
361
{
437
 
        BraseroDiscTrack *newtrack;
 
362
        GSList *tracks = NULL;
 
363
        GSList *iter;
438
364
 
439
365
        track_node = track_node->xmlChildrenNode;
440
366
 
441
 
        newtrack = NULL;
442
367
        while (track_node) {
 
368
                BraseroTrack *newtrack;
 
369
 
443
370
                if (!xmlStrcmp (track_node->name, (const xmlChar *) "audio")) {
444
 
                        if (newtrack)
445
 
                                goto error;
446
 
 
447
 
                        newtrack = _read_audio_track (project,
448
 
                                                      track_node->xmlChildrenNode);
 
371
                        newtrack = _read_audio_track (project, track_node->xmlChildrenNode, FALSE);
449
372
                        if (!newtrack)
450
373
                                goto error;
451
374
 
452
 
                        newtrack->type = BRASERO_PROJECT_TYPE_AUDIO;
 
375
                        tracks = g_slist_append (tracks, newtrack);
453
376
                }
454
377
                else if (!xmlStrcmp (track_node->name, (const xmlChar *) "data")) {
455
 
                        if (newtrack)
456
 
                                goto error;
457
 
 
458
 
                        newtrack = _read_data_track (project,
459
 
                                                     track_node->xmlChildrenNode);
 
378
                        newtrack = _read_data_track (project, track_node->xmlChildrenNode);
460
379
 
461
380
                        if (!newtrack)
462
381
                                goto error;
 
382
 
 
383
                        tracks = g_slist_append (tracks, newtrack);
463
384
                }
464
385
                else if (!xmlStrcmp (track_node->name, (const xmlChar *) "video")) {
465
 
                        if (newtrack)
466
 
                                goto error;
467
 
 
468
 
                        newtrack = _read_audio_track (project,
469
 
                                                      track_node->xmlChildrenNode);
 
386
                        newtrack = _read_audio_track (project, track_node->xmlChildrenNode, TRUE);
470
387
 
471
388
                        if (!newtrack)
472
389
                                goto error;
473
390
 
474
 
                        newtrack->type = BRASERO_PROJECT_TYPE_VIDEO;
 
391
                        tracks = g_slist_append (tracks, newtrack);
475
392
                }
476
393
                else if (track_node->type == XML_ELEMENT_NODE)
477
394
                        goto error;
479
396
                track_node = track_node->next;
480
397
        }
481
398
 
482
 
        if (!newtrack)
 
399
        if (!tracks)
483
400
                goto error;
484
401
 
485
 
        *track = newtrack;
 
402
        for (iter = tracks; iter; iter = iter->next) {
 
403
                BraseroTrack *newtrack;
 
404
 
 
405
                newtrack = tracks->data;
 
406
                brasero_burn_session_add_track (session, newtrack, NULL);
 
407
        }
 
408
 
 
409
        g_slist_free (tracks);
 
410
 
486
411
        return TRUE;
487
412
 
488
413
error :
489
 
        if (newtrack)
490
 
                brasero_track_free (newtrack);
491
 
 
492
 
        brasero_track_free (newtrack);
 
414
 
 
415
        if (tracks) {
 
416
                g_slist_foreach (tracks, (GFunc) g_object_unref, NULL);
 
417
                g_slist_free (tracks);
 
418
        }
 
419
 
493
420
        return FALSE;
494
421
}
495
422
 
496
423
gboolean
497
424
brasero_project_open_project_xml (const gchar *uri,
498
 
                                  BraseroDiscTrack **track,
 
425
                                  BraseroBurnSession *session,
499
426
                                  gboolean warn_user)
500
427
{
501
428
        xmlNodePtr track_node = NULL;
516
443
 
517
444
        if (!project) {
518
445
                if (warn_user)
519
 
                        brasero_project_invalid_project_dialog (_("The project could not be opened."));
 
446
                        brasero_project_invalid_project_dialog (_("The project could not be opened"));
520
447
 
521
448
                return FALSE;
522
449
        }
525
452
        item = xmlDocGetRootElement (project);
526
453
        if (!item) {
527
454
                if (warn_user)
528
 
                        brasero_project_invalid_project_dialog (_("The file is empty."));
 
455
                        brasero_project_invalid_project_dialog (_("The file is empty"));
529
456
 
530
457
                xmlFreeDoc (project);
531
458
                return FALSE;
571
498
                item = item->next;
572
499
        }
573
500
 
574
 
        retval = _get_tracks (project, track_node, track);
 
501
        retval = _get_tracks (project, track_node, session);
575
502
        if (!retval)
576
503
                goto error;
577
504
 
578
505
        xmlFreeDoc (project);
579
506
 
580
 
        if (track && *track) {
581
 
                (*track)->label = label;
582
 
                (*track)->cover = cover;
583
 
        }
584
 
 
585
 
        return retval;
 
507
        brasero_burn_session_set_label (session, label);
 
508
        g_free (label);
 
509
 
 
510
        if (cover) {
 
511
                GValue *value;
 
512
 
 
513
                value = g_new0 (GValue, 1);
 
514
                g_value_init (value, G_TYPE_STRING);
 
515
                g_value_set_string (value, cover);
 
516
                brasero_burn_session_tag_add (session,
 
517
                                               BRASERO_COVER_URI,
 
518
                                               value);
 
519
 
 
520
                g_free (cover);
 
521
        }
 
522
 
 
523
        return retval;
586
524
 
587
525
error:
588
526
 
593
531
 
594
532
        xmlFreeDoc (project);
595
533
        if (warn_user)
596
 
                brasero_project_invalid_project_dialog (_("It does not seem to be a valid Brasero project."));
 
534
                brasero_project_invalid_project_dialog (_("It does not seem to be a valid Brasero project"));
597
535
 
598
536
        return FALSE;
599
537
}
606
544
                                           GHashTable *metadata,
607
545
                                           gpointer user_data)
608
546
{
609
 
        gchar *string;
610
 
        gchar **retval = user_data;
 
547
        BraseroBurnSession *session = user_data;
611
548
 
612
 
        string = g_hash_table_lookup (metadata, TOTEM_PL_PARSER_FIELD_TITLE);
613
 
        if (string)
614
 
                *retval = g_strdup (string);
 
549
        brasero_burn_session_set_label (session, g_hash_table_lookup (metadata, TOTEM_PL_PARSER_FIELD_TITLE));
615
550
}
616
551
 
617
552
static void
620
555
                                       GHashTable *metadata,
621
556
                                       gpointer user_data)
622
557
{
623
 
        BraseroDiscTrack *track = user_data;
624
 
        BraseroDiscSong *song;
625
 
 
626
 
        song = g_new0 (BraseroDiscSong, 1);
627
 
        song->uri = g_strdup (uri);
628
 
 
629
 
        /* to know if this info was set or not */
630
 
        song->start = -1;
631
 
        song->end = -1;
632
 
        track->contents.tracks = g_slist_prepend (track->contents.tracks, song);
 
558
        BraseroBurnSession *session = user_data;
 
559
        BraseroTrackStreamCfg *track;
 
560
 
 
561
        track = brasero_track_stream_cfg_new ();
 
562
        brasero_track_stream_set_source (BRASERO_TRACK_STREAM (track), uri);
 
563
        brasero_burn_session_add_track (session, BRASERO_TRACK (track), NULL);
633
564
}
634
565
 
635
566
gboolean
636
567
brasero_project_open_audio_playlist_project (const gchar *uri,
637
 
                                             BraseroDiscTrack **track,
 
568
                                             BraseroBurnSession *session,
638
569
                                             gboolean warn_user)
639
570
{
640
 
        gchar *label = NULL;
641
571
        TotemPlParser *parser;
642
572
        TotemPlParserResult result;
643
 
        BraseroDiscTrack *new_track;
644
 
 
645
 
        new_track = g_new0 (BraseroDiscTrack, 1);
646
 
        new_track->type = BRASERO_PROJECT_TYPE_AUDIO;
647
573
 
648
574
        parser = totem_pl_parser_new ();
649
575
        g_object_set (parser,
654
580
        g_signal_connect (parser,
655
581
                          "playlist-started",
656
582
                          G_CALLBACK (brasero_project_playlist_playlist_started),
657
 
                          &label);
 
583
                          session);
658
584
 
659
585
        g_signal_connect (parser,
660
586
                          "entry-parsed",
661
587
                          G_CALLBACK (brasero_project_playlist_entry_parsed),
662
 
                          new_track);
 
588
                          session);
663
589
 
664
590
        result = totem_pl_parser_parse (parser, uri, FALSE);
665
591
        if (result != TOTEM_PL_PARSER_RESULT_SUCCESS) {
666
592
                if (warn_user)
667
 
                        brasero_project_invalid_project_dialog (_("It does not seem to be a valid Brasero project."));
668
 
 
669
 
                brasero_track_free (new_track);
670
 
        }
671
 
        else {
672
 
                if (new_track && label)
673
 
                        new_track->label = label;
674
 
 
675
 
                *track = new_track;
 
593
                        brasero_project_invalid_project_dialog (_("It does not seem to be a valid Brasero project"));
676
594
        }
677
595
 
678
596
        g_object_unref (parser);
681
599
}
682
600
 
683
601
#endif
 
602
 
 
603
/**
 
604
 * Project saving
 
605
 */
 
606
 
 
607
static gboolean
 
608
_save_audio_track_xml (xmlTextWriter *project,
 
609
                       BraseroTrackStream *track)
 
610
{
 
611
        xmlChar *escaped;
 
612
        gchar *start;
 
613
        gint success;
 
614
        gchar *isrc;
 
615
        gchar *uri;
 
616
        gchar *end;
 
617
 
 
618
        uri = brasero_track_stream_get_source (track, TRUE);
 
619
        escaped = (unsigned char *) g_uri_escape_string (uri, NULL, FALSE);
 
620
        g_free (uri);
 
621
 
 
622
        success = xmlTextWriterWriteElement (project,
 
623
                                            (xmlChar *) "uri",
 
624
                                             escaped);
 
625
        g_free (escaped);
 
626
 
 
627
        if (success == -1)
 
628
                return FALSE;
 
629
 
 
630
        if (brasero_track_stream_get_gap (track) > 0) {
 
631
                gchar *silence;
 
632
 
 
633
                silence = g_strdup_printf ("%"G_GINT64_FORMAT, brasero_track_stream_get_gap (track));
 
634
                success = xmlTextWriterWriteElement (project,
 
635
                                                     (xmlChar *) "silence",
 
636
                                                     (xmlChar *) silence);
 
637
 
 
638
                g_free (silence);
 
639
                if (success == -1)
 
640
                        return FALSE;
 
641
        }
 
642
 
 
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,
 
647
                                                     (xmlChar *) "start",
 
648
                                                     (xmlChar *) start);
 
649
 
 
650
                g_free (start);
 
651
                if (success == -1)
 
652
                        return FALSE;
 
653
 
 
654
                /* end of the song */
 
655
                end = g_strdup_printf ("%"G_GINT64_FORMAT, brasero_track_stream_get_end (track));
 
656
                success = xmlTextWriterWriteElement (project,
 
657
                                                     (xmlChar *) "end",
 
658
                                                     (xmlChar *) end);
 
659
 
 
660
                g_free (end);
 
661
                if (success == -1)
 
662
                        return FALSE;
 
663
        }
 
664
 
 
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,
 
668
                                                    (xmlChar *) "title",
 
669
                                                     escaped);
 
670
                g_free (escaped);
 
671
 
 
672
                if (success == -1)
 
673
                        return FALSE;
 
674
        }
 
675
 
 
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",
 
680
                                                     escaped);
 
681
                g_free (escaped);
 
682
 
 
683
                if (success == -1)
 
684
                        return FALSE;
 
685
        }
 
686
 
 
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",
 
691
                                                     escaped);
 
692
                g_free (escaped);
 
693
                if (success == -1)
 
694
                        return FALSE;
 
695
        }
 
696
 
 
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,
 
700
                                                     (xmlChar *) "isrc",
 
701
                                                     (xmlChar *) isrc);
 
702
 
 
703
                g_free (isrc);
 
704
                if (success == -1)
 
705
                        return FALSE;
 
706
        }
 
707
 
 
708
        return TRUE;
 
709
}
 
710
 
 
711
static gboolean
 
712
_save_data_track_xml (xmlTextWriter *project,
 
713
                      BraseroBurnSession *session)
 
714
{
 
715
        gchar *uri;
 
716
        gint success;
 
717
        GSList *iter;
 
718
        GSList *tracks;
 
719
        GSList *grafts;
 
720
        BraseroTrackDataCfg *track;
 
721
 
 
722
        tracks = brasero_burn_session_get_tracks (session);
 
723
        track = BRASERO_TRACK_DATA_CFG (tracks->data);
 
724
 
 
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));
 
728
                if (success < 0)
 
729
                        return FALSE;
 
730
        }
 
731
 
 
732
        grafts = brasero_track_data_get_grafts (BRASERO_TRACK_DATA (track));
 
733
        for (; grafts; grafts = grafts->next) {
 
734
                BraseroGraftPt *graft;
 
735
 
 
736
                graft = grafts->data;
 
737
 
 
738
                success = xmlTextWriterStartElement (project, (xmlChar *) "graft");
 
739
                if (success < 0)
 
740
                        return FALSE;
 
741
 
 
742
                success = xmlTextWriterWriteElement (project, (xmlChar *) "path", (xmlChar *) graft->path);
 
743
                if (success < 0)
 
744
                        return FALSE;
 
745
 
 
746
                if (graft->uri) {
 
747
                        xmlChar *escaped;
 
748
 
 
749
                        escaped = (unsigned char *) g_uri_escape_string (graft->uri, NULL, FALSE);
 
750
                        success = xmlTextWriterWriteElement (project, (xmlChar *) "uri", escaped);
 
751
                        g_free (escaped);
 
752
                        if (success < 0)
 
753
                                return FALSE;
 
754
                }
 
755
 
 
756
                success = xmlTextWriterEndElement (project); /* graft */
 
757
                if (success < 0)
 
758
                        return FALSE;
 
759
        }
 
760
 
 
761
        /* save excluded uris */
 
762
        iter = brasero_track_data_get_excluded (BRASERO_TRACK_DATA (track), FALSE);
 
763
        for (; iter; iter = iter->next) {
 
764
                xmlChar *escaped;
 
765
 
 
766
                escaped = xmlURIEscapeStr ((xmlChar *) iter->data, NULL);
 
767
                success = xmlTextWriterWriteElement (project, (xmlChar *) "excluded", (xmlChar *) escaped);
 
768
                g_free (escaped);
 
769
                if (success < 0)
 
770
                        return FALSE;
 
771
        }
 
772
 
 
773
        /* save restored uris */
 
774
        iter = brasero_track_data_cfg_get_restored_list (track);
 
775
        for (; iter; iter = iter->next) {
 
776
                uri = iter->data;
 
777
                success = xmlTextWriterWriteElement (project, (xmlChar *) "restored", (xmlChar *) uri);
 
778
                if (success < 0)
 
779
                        return FALSE;
 
780
        }
 
781
 
 
782
        /* NOTE: we don't write symlinks and unreadable they are useless */
 
783
        return TRUE;
 
784
}
 
785
 
 
786
gboolean 
 
787
brasero_project_save_project_xml (BraseroBurnSession *session,
 
788
                                  const gchar *uri)
 
789
{
 
790
        BraseroTrackType *track_type = NULL;
 
791
        xmlTextWriter *project;
 
792
        gboolean retval;
 
793
        GSList *tracks;
 
794
        GValue *value;
 
795
        gint success;
 
796
        gchar *path;
 
797
 
 
798
        path = g_filename_from_uri (uri, NULL, NULL);
 
799
        if (!path)
 
800
                return FALSE;
 
801
 
 
802
        project = xmlNewTextWriterFilename (path, 0);
 
803
        if (!project) {
 
804
                g_free (path);
 
805
                return FALSE;
 
806
        }
 
807
 
 
808
        xmlTextWriterSetIndent (project, 1);
 
809
        xmlTextWriterSetIndentString (project, (xmlChar *) "\t");
 
810
 
 
811
        success = xmlTextWriterStartDocument (project,
 
812
                                              NULL,
 
813
                                              "UTF8",
 
814
                                              NULL);
 
815
        if (success < 0)
 
816
                goto error;
 
817
 
 
818
        success = xmlTextWriterStartElement (project, (xmlChar *) "braseroproject");
 
819
        if (success < 0)
 
820
                goto error;
 
821
 
 
822
        /* write the name of the version */
 
823
        success = xmlTextWriterWriteElement (project,
 
824
                                             (xmlChar *) "version",
 
825
                                             (xmlChar *) BRASERO_PROJECT_VERSION);
 
826
        if (success < 0)
 
827
                goto error;
 
828
 
 
829
        if (brasero_burn_session_get_label (session)) {
 
830
                success = xmlTextWriterWriteElement (project,
 
831
                                                     (xmlChar *) "label",
 
832
                                                     (xmlChar *) brasero_burn_session_get_label (session));
 
833
 
 
834
                if (success < 0)
 
835
                        goto error;
 
836
        }
 
837
 
 
838
        value = NULL;
 
839
        brasero_burn_session_tag_lookup (session,
 
840
                                         BRASERO_COVER_URI,
 
841
                                         &value);
 
842
        if (value) {
 
843
                gchar *escaped;
 
844
 
 
845
                escaped = g_uri_escape_string (g_value_get_string (value), NULL, FALSE);
 
846
                success = xmlTextWriterWriteElement (project,
 
847
                                                     (xmlChar *) "cover",
 
848
                                                     (xmlChar *) escaped);
 
849
                g_free (escaped);
 
850
 
 
851
                if (success < 0)
 
852
                        goto error;
 
853
        }
 
854
 
 
855
        success = xmlTextWriterStartElement (project, (xmlChar *) "track");
 
856
        if (success < 0)
 
857
                goto error;
 
858
 
 
859
        track_type = brasero_track_type_new ();
 
860
        tracks = brasero_burn_session_get_tracks (session);
 
861
 
 
862
        for (; tracks; tracks = tracks->next) {
 
863
                BraseroTrack *track;
 
864
 
 
865
                track = tracks->data;
 
866
 
 
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");
 
871
                        else
 
872
                                success = xmlTextWriterStartElement (project, (xmlChar *) "audio");
 
873
 
 
874
                        if (success < 0)
 
875
                                goto error;
 
876
 
 
877
                        retval = _save_audio_track_xml (project, BRASERO_TRACK_STREAM (track));
 
878
                        if (!retval)
 
879
                                goto error;
 
880
 
 
881
                        success = xmlTextWriterEndElement (project); /* audio/video */
 
882
                        if (success < 0)
 
883
                                goto error;
 
884
                }
 
885
                else if (brasero_track_type_get_has_data (track_type)) {
 
886
                        success = xmlTextWriterStartElement (project, (xmlChar *) "data");
 
887
                        if (success < 0)
 
888
                                goto error;
 
889
 
 
890
                        retval = _save_data_track_xml (project, session);
 
891
                        if (!retval)
 
892
                                goto error;
 
893
 
 
894
                        success = xmlTextWriterEndElement (project); /* data */
 
895
                        if (success < 0)
 
896
                                goto error;
 
897
                }
 
898
                else
 
899
                        retval = FALSE;
 
900
        }
 
901
 
 
902
        success = xmlTextWriterEndElement (project); /* track */
 
903
        if (success < 0)
 
904
                goto error;
 
905
 
 
906
        brasero_track_type_free (track_type);
 
907
 
 
908
        success = xmlTextWriterEndElement (project); /* braseroproject */
 
909
        if (success < 0)
 
910
                goto error;
 
911
 
 
912
        xmlTextWriterEndDocument (project);
 
913
        xmlFreeTextWriter (project);
 
914
        g_free (path);
 
915
        return TRUE;
 
916
 
 
917
error:
 
918
 
 
919
        if (track_type)
 
920
                brasero_track_type_free (track_type);
 
921
 
 
922
        xmlTextWriterEndDocument (project);
 
923
        xmlFreeTextWriter (project);
 
924
 
 
925
        g_remove (path);
 
926
        g_free (path);
 
927
 
 
928
        return FALSE;
 
929
}
 
930
 
 
931
gboolean
 
932
brasero_project_save_audio_project_plain_text (BraseroBurnSession *session,
 
933
                                               const gchar *uri)
 
934
{
 
935
        const gchar *title;
 
936
        guint written;
 
937
        GSList *iter;
 
938
        gchar *path;
 
939
        FILE *file;
 
940
 
 
941
        path = g_filename_from_uri (uri, NULL, NULL);
 
942
        if (!path)
 
943
                return FALSE;
 
944
 
 
945
        file = fopen (path, "w+");
 
946
        g_free (path);
 
947
        if (!file)
 
948
                return FALSE;
 
949
 
 
950
        /* write title */
 
951
        title = brasero_burn_session_get_label (session);
 
952
        written = fwrite (title, strlen (title), 1, file);
 
953
        if (written != 1)
 
954
                goto error;
 
955
 
 
956
        written = fwrite ("\n", 1, 1, file);
 
957
        if (written != 1)
 
958
                goto error;
 
959
 
 
960
        iter = brasero_burn_session_get_tracks (session);
 
961
        for (; iter; iter = iter->next) {
 
962
                BraseroTrackStream *track;
 
963
                const gchar *text;
 
964
                gchar *time;
 
965
                guint64 len;
 
966
                gchar *uri;
 
967
 
 
968
                track = iter->data;
 
969
 
 
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))
 
973
                        goto error;
 
974
 
 
975
                len = 0;
 
976
                brasero_track_stream_get_length (track, &len);
 
977
                time = brasero_units_get_time_string (len, TRUE, FALSE);
 
978
                if (time) {
 
979
                        written = fwrite ("\t", 1, 1, file);
 
980
                        if (written != 1)
 
981
                                goto error;
 
982
 
 
983
                        written = fwrite (time, 1, strlen (time), file);
 
984
                        if (written != strlen (time)) {
 
985
                                g_free (time);
 
986
                                goto error;
 
987
                        }
 
988
                        g_free (time);
 
989
                }
 
990
 
 
991
                text = brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_ARTIST_TAG);
 
992
                if (text) {
 
993
                        gchar *string;
 
994
 
 
995
                        written = fwrite ("\t", 1, 1, file);
 
996
                        if (written != 1)
 
997
                                goto error;
 
998
 
 
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)) {
 
1003
                                g_free (string);
 
1004
                                goto error;
 
1005
                        }
 
1006
                        g_free (string);
 
1007
                }
 
1008
 
 
1009
                written = fwrite ("\n(", 1, 2, file);
 
1010
                if (written != 2)
 
1011
                        goto error;
 
1012
 
 
1013
                uri = brasero_track_stream_get_source (track, TRUE);
 
1014
                written = fwrite (uri, 1, strlen (uri), file);
 
1015
                if (written != strlen (uri)) {
 
1016
                        g_free (uri);
 
1017
                        goto error;
 
1018
                }
 
1019
 
 
1020
                g_free (uri);
 
1021
 
 
1022
                written = fwrite (")", 1, 1, file);
 
1023
                if (written != 1)
 
1024
                        goto error;
 
1025
 
 
1026
                written = fwrite ("\n\n", 1, 2, file);
 
1027
                if (written != 2)
 
1028
                        goto error;
 
1029
        }
 
1030
 
 
1031
        fclose (file);
 
1032
        return TRUE;
 
1033
        
 
1034
error:
 
1035
 
 
1036
        fclose (file);
 
1037
 
 
1038
        return FALSE;
 
1039
}
 
1040
 
 
1041
#ifdef BUILD_PLAYLIST
 
1042
 
 
1043
static void
 
1044
brasero_project_save_audio_playlist_entry (GtkTreeModel *model,
 
1045
                                           GtkTreeIter *iter,
 
1046
                                           gchar **uri,
 
1047
                                           gchar **title,
 
1048
                                           gboolean *custom_title,
 
1049
                                           gpointer user_data)
 
1050
{
 
1051
        gtk_tree_model_get (model, iter,
 
1052
                            0, uri,
 
1053
                            1, title,
 
1054
                            2, custom_title,
 
1055
                            -1);
 
1056
}
 
1057
 
 
1058
gboolean
 
1059
brasero_project_save_audio_project_playlist (BraseroBurnSession *session,
 
1060
                                             const gchar *uri,
 
1061
                                             BraseroProjectSave type)
 
1062
{
 
1063
        TotemPlParserType pl_type;
 
1064
        TotemPlParser *parser;
 
1065
        GtkListStore *model;
 
1066
        GtkTreeIter t_iter;
 
1067
        gboolean result;
 
1068
        GSList *iter;
 
1069
        gchar *path;
 
1070
 
 
1071
        path = g_filename_from_uri (uri, NULL, NULL);
 
1072
        if (!path)
 
1073
                return FALSE;
 
1074
 
 
1075
        parser = totem_pl_parser_new ();
 
1076
 
 
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;
 
1082
                gchar *uri;
 
1083
 
 
1084
                track = iter->data;
 
1085
 
 
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,
 
1089
                                    0, uri,
 
1090
                                    1, brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_TITLE_TAG),
 
1091
                                    2, TRUE,
 
1092
                                    -1);
 
1093
                g_free (uri);
 
1094
        }
 
1095
 
 
1096
        switch (type) {
 
1097
                case BRASERO_PROJECT_SAVE_PLAYLIST_M3U:
 
1098
                        pl_type = TOTEM_PL_PARSER_M3U;
 
1099
                        break;
 
1100
                case BRASERO_PROJECT_SAVE_PLAYLIST_XSPF:
 
1101
                        pl_type = TOTEM_PL_PARSER_XSPF;
 
1102
                        break;
 
1103
                case BRASERO_PROJECT_SAVE_PLAYLIST_IRIVER_PLA:
 
1104
                        pl_type = TOTEM_PL_PARSER_IRIVER_PLA;
 
1105
                        break;
 
1106
 
 
1107
                case BRASERO_PROJECT_SAVE_PLAYLIST_PLS:
 
1108
                default:
 
1109
                        pl_type = TOTEM_PL_PARSER_PLS;
 
1110
                        break;
 
1111
        }
 
1112
 
 
1113
        result = totem_pl_parser_write_with_title (parser,
 
1114
                                                   GTK_TREE_MODEL (model),
 
1115
                                                   brasero_project_save_audio_playlist_entry,
 
1116
                                                   path,
 
1117
                                                   brasero_burn_session_get_label (session),
 
1118
                                                   pl_type,
 
1119
                                                   NULL,
 
1120
                                                   NULL);
 
1121
 
 
1122
        g_object_unref (model);
 
1123
        g_object_unref (parser);
 
1124
        g_free (path);
 
1125
 
 
1126
        return result;
 
1127
}
 
1128
 
 
1129
#endif