static gboolean save_playlist_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, SavePlaylistData *data) { RBGenericPlayerPlaylistSourcePrivate *priv = GET_PRIVATE (data->source); RhythmDBEntry *entry; TotemPlPlaylistIter pl_iter; const char *host_uri; char *uri; entry = rhythmdb_query_model_iter_to_entry (RHYTHMDB_QUERY_MODEL (model), iter); if (entry == NULL) { return FALSE; } host_uri = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION); uri = rb_generic_player_source_uri_to_playlist_uri (priv->player_source, host_uri, data->playlist_type); totem_pl_playlist_append (data->playlist, &pl_iter); totem_pl_playlist_set (data->playlist, &pl_iter, TOTEM_PL_PARSER_FIELD_URI, uri, NULL); set_field_from_property (data->playlist, &pl_iter, entry, RHYTHMDB_PROP_ARTIST, TOTEM_PL_PARSER_FIELD_AUTHOR); set_field_from_property (data->playlist, &pl_iter, entry, RHYTHMDB_PROP_GENRE, TOTEM_PL_PARSER_FIELD_GENRE); set_field_from_property (data->playlist, &pl_iter, entry, RHYTHMDB_PROP_ALBUM, TOTEM_PL_PARSER_FIELD_ALBUM); set_field_from_property (data->playlist, &pl_iter, entry, RHYTHMDB_PROP_TITLE, TOTEM_PL_PARSER_FIELD_TITLE); rhythmdb_entry_unref (entry); g_free (uri); return FALSE; }
static void set_field_from_property (TotemPlPlaylist *playlist, TotemPlPlaylistIter *iter, RhythmDBEntry *entry, RhythmDBPropType property, const char *field) { const char *value; value = rhythmdb_entry_get_string (entry, property); if (value != NULL) { totem_pl_playlist_set (playlist, iter, field, value, NULL); } }
gboolean brasero_project_save_audio_project_playlist (BraseroBurnSession *session, const gchar *uri, BraseroProjectSave type) { TotemPlParserType pl_type; TotemPlParser *parser; TotemPlPlaylist *playlist; TotemPlPlaylistIter pl_iter; gboolean result; GFile *file; GSList *iter; file = g_file_new_for_uri (uri); parser = totem_pl_parser_new (); playlist = totem_pl_playlist_new (); /* populate playlist */ iter = brasero_burn_session_get_tracks (session); for (; iter; iter = iter->next) { BraseroTrackStream *track; const gchar *title; gchar *uri; track = iter->data; uri = brasero_track_stream_get_source (track, TRUE); title = brasero_track_tag_lookup_string (BRASERO_TRACK (track), BRASERO_TRACK_STREAM_TITLE_TAG); totem_pl_playlist_append (playlist, &pl_iter); totem_pl_playlist_set (playlist, &pl_iter, TOTEM_PL_PARSER_FIELD_URI, uri, TOTEM_PL_PARSER_FIELD_TITLE, title, NULL); g_free (uri); } switch (type) { case BRASERO_PROJECT_SAVE_PLAYLIST_M3U: pl_type = TOTEM_PL_PARSER_M3U; break; case BRASERO_PROJECT_SAVE_PLAYLIST_XSPF: pl_type = TOTEM_PL_PARSER_XSPF; break; case BRASERO_PROJECT_SAVE_PLAYLIST_IRIVER_PLA: pl_type = TOTEM_PL_PARSER_IRIVER_PLA; break; case BRASERO_PROJECT_SAVE_PLAYLIST_PLS: default: pl_type = TOTEM_PL_PARSER_PLS; break; } result = totem_pl_parser_save (parser, playlist, file, brasero_burn_session_get_label (session), pl_type, NULL); g_object_unref (playlist); g_object_unref (parser); g_object_unref (file); return result; }