# HG changeset patch # User Kieran Clancy # Date 1189401127 -34200 # Node ID 3f4ad59a5c02c05003cb04b1f82a8fce4a9b78fd # Parent 26910525cec8d9a19a68bab416d1a07e1baab1a1 Load extra playlists on startup diff -r 26910525cec8 -r 3f4ad59a5c02 src/audacious/main.c --- a/src/audacious/main.c Mon Sep 10 14:18:18 2007 +0930 +++ b/src/audacious/main.c Mon Sep 10 14:42:07 2007 +0930 @@ -1108,6 +1108,35 @@ return TRUE; } +static gboolean +load_extra_playlist(const gchar * path, const gchar * basename, + gpointer def) +{ + const gchar *title; + Playlist *playlist; + Playlist *deflist; + + deflist = (Playlist *)def; + playlist = playlist_new(); + if (!playlist) { + g_warning("Couldn't create new playlist\n"); + return FALSE; + } + + playlist_add_playlist(playlist); + playlist_load(playlist, path); + + title = playlist_get_current_name(playlist); + + if (playlist_playlists_equal(playlist, deflist)) { + /* same as default playlist */ + playlist_remove_playlist(playlist); + playlist_filename_set(deflist, path); + } + + return FALSE; /* keep loading other playlists */ +} + gint main(gint argc, gchar ** argv) { @@ -1231,6 +1260,12 @@ playlist_load(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); playlist_set_position(playlist, cfg.playlist_position); + /* Load extra playlists */ + if(!dir_foreach(bmp_paths[BMP_PATH_PLAYLISTS_DIR], load_extra_playlist, + playlist, NULL)) { + g_warning("Could not load extra playlists\n"); + } + /* this needs to be called after all 3 windows are created and * input plugins are setup'ed * but not if we're running headless --nenolod