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); } }
static void add_list (Index * filenames, int at, bool_t to_temp, bool_t play) { if (to_temp) playlist_set_active (playlist_get_temporary ()); int playlist = playlist_get_active (); if (play) { if (get_bool (NULL, "clear_playlist")) playlist_entry_delete (playlist, 0, playlist_entry_count (playlist)); else playlist_queue_delete (playlist, 0, playlist_queue_count (playlist)); } playlist_entry_insert_batch (playlist, at, filenames, NULL, play); }
static void add_list (Index * filenames, int at, bool_t to_temp, bool_t play) { if (to_temp) playlist_set_active (playlist_get_temporary ()); int playlist = playlist_get_active (); /* queue the new entries before deleting the old ones */ /* this is to avoid triggering the --quit-after-play condition */ playlist_entry_insert_batch (playlist, at, filenames, NULL, play); if (play) { if (get_bool (NULL, "clear_playlist")) playlist_entry_delete (playlist, 0, playlist_entry_count (playlist)); else playlist_queue_delete (playlist, 0, playlist_queue_count (playlist)); } }
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); }