static void activate_temp (void) { gint playlists = playlist_count (); const gchar * title = _("Temporary Playlist"); for (gint playlist = 0; playlist < playlists; playlist ++) { gchar * title2 = playlist_get_title (playlist); if (! strcmp (title2, title)) { playlist_set_active (playlist); g_free (title2); return; } g_free (title2); } if (! playlist_entry_count (playlist_get_active ())) playlist_set_title (playlist_get_active (), title); else { playlist_insert (playlists); playlist_set_title (playlists, title); playlist_set_active (playlists); } }
// Moves entry such that entry->prev = at (even if at is NULL) void playlist_move(struct playlist *pl, struct playlist_entry *entry, struct playlist_entry *at) { struct playlist_entry *save_current = pl->current; bool save_replaced = pl->current_was_replaced; playlist_unlink(pl, entry); playlist_insert(pl, at ? at->prev : pl->last, entry); pl->current = save_current; pl->current_was_replaced = save_replaced; }
// Move all entries from source_pl to pl, appending them after the current entry // of pl. source_pl will be empty, and all entries have changed ownership to pl. void playlist_transfer_entries(struct playlist *pl, struct playlist *source_pl) { struct playlist_entry *add_after = pl->current; if (pl->current && pl->current_was_replaced) add_after = pl->current->next; if (!add_after) add_after = pl->last; while (source_pl->first) { struct playlist_entry *e = source_pl->first; playlist_unlink(source_pl, e); playlist_insert(pl, add_after, e); } }
void playlist_add(struct playlist *pl, struct playlist_entry *add) { playlist_insert(pl, pl->last, add); }
static void load_playlists_real (void) { /* old (v3.1 and earlier) naming scheme */ int count; for (count = 0; ; count ++) { char * path = make_playlist_path (count); if (! g_file_test (path, G_FILE_TEST_EXISTS)) { g_free (path); break; } char * uri = filename_to_uri (path); playlist_insert (count); playlist_insert_playlist_raw (count, 0, uri); playlist_set_modified (count, TRUE); g_free (path); g_free (uri); } /* unique ID-based naming scheme */ char * order_path = g_strdup_printf ("%s/order", get_path (AUD_PATH_PLAYLISTS_DIR)); char * order_string; g_file_get_contents (order_path, & order_string, NULL, NULL); g_free (order_path); if (! order_string) goto DONE; char * * order = g_strsplit (order_string, " ", -1); g_free (order_string); for (int i = 0; order[i]; i ++) { char * path = g_strdup_printf ("%s/%s.audpl", get_path (AUD_PATH_PLAYLISTS_DIR), order[i]); if (! g_file_test (path, G_FILE_TEST_EXISTS)) { g_free (path); path = g_strdup_printf ("%s/%s.xspf", get_path (AUD_PATH_PLAYLISTS_DIR), order[i]); } char * uri = filename_to_uri (path); playlist_insert_with_id (count + i, atoi (order[i])); playlist_insert_playlist_raw (count + i, 0, uri); playlist_set_modified (count + i, FALSE); if (g_str_has_suffix (path, ".xspf")) playlist_set_modified (count + i, TRUE); g_free (path); g_free (uri); } g_strfreev (order); DONE: if (! playlist_count ()) playlist_insert (0); playlist_set_active (0); }