core/playlist: playlist_select() takes a playlist pointer
And stores it for future reference, so we don't have to keep looking up current and previous playlists. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
73825dd916
commit
5c215df0bf
|
@ -10,6 +10,9 @@ static const gchar *SETTINGS_CUR_ID = "core.playlist.cur.id";
|
|||
static const gchar *SETTINGS_PREV_TYPE = "core.playlist.prev.type";
|
||||
static const gchar *SETTINGS_PREV_ID = "core.playlist.prev.id";
|
||||
|
||||
static struct playlist *current = NULL;
|
||||
static struct playlist *previous = NULL;
|
||||
|
||||
struct playlist_type *playlist_types[] = {
|
||||
[PL_SYSTEM] = &pl_system,
|
||||
[PL_ARTIST] = &pl_artist,
|
||||
|
@ -18,6 +21,18 @@ struct playlist_type *playlist_types[] = {
|
|||
};
|
||||
|
||||
|
||||
static struct playlist *__playlist_saved(const gchar *s_type, const gchar *s_id)
|
||||
{
|
||||
unsigned int type, id;
|
||||
|
||||
if (!settings_has(s_type) || !settings_has(s_id))
|
||||
return NULL;
|
||||
|
||||
type = settings_get(s_type);
|
||||
id = settings_get(s_id);
|
||||
return playlist_types[type]->pl_get(id);
|
||||
}
|
||||
|
||||
void playlist_init(struct queue_ops *ops)
|
||||
{
|
||||
pl_system_init(ops);
|
||||
|
@ -25,12 +40,10 @@ void playlist_init(struct queue_ops *ops)
|
|||
pl_user_init(ops);
|
||||
pl_library_init(ops);
|
||||
|
||||
if (!settings_has(SETTINGS_CUR_TYPE) ||
|
||||
!settings_has(SETTINGS_CUR_ID)) {
|
||||
playlist_select(PL_SYSTEM, "Collection");
|
||||
if (playlist_size(playlist_lookup(PL_SYSTEM, "Queued Tracks")) > 0)
|
||||
playlist_select(PL_SYSTEM, "Queued Tracks");
|
||||
}
|
||||
current = __playlist_saved(SETTINGS_CUR_TYPE, SETTINGS_CUR_ID);
|
||||
previous = __playlist_saved(SETTINGS_PREV_TYPE, SETTINGS_PREV_ID);
|
||||
if (!current)
|
||||
current = playlist_lookup(PL_SYSTEM, "Collection");
|
||||
}
|
||||
|
||||
void playlist_deinit()
|
||||
|
@ -48,21 +61,6 @@ void playlist_save()
|
|||
playlist_types[i]->pl_save();
|
||||
}
|
||||
|
||||
bool playlist_select(enum playlist_type_t type, const gchar *name)
|
||||
{
|
||||
if (!playlist_types[type]->pl_can_select(name))
|
||||
return false;
|
||||
if ((settings_get(SETTINGS_CUR_TYPE) == type) &&
|
||||
settings_get(SETTINGS_CUR_ID) == playlist_get_id(type, name))
|
||||
return true;
|
||||
|
||||
settings_set(SETTINGS_PREV_TYPE, settings_get(SETTINGS_CUR_TYPE));
|
||||
settings_set(SETTINGS_PREV_ID, settings_get(SETTINGS_CUR_ID));
|
||||
settings_set(SETTINGS_CUR_TYPE, type);
|
||||
settings_set(SETTINGS_CUR_ID, playlist_get_id(type, name));
|
||||
return true;
|
||||
}
|
||||
|
||||
struct playlist *playlist_new(enum playlist_type_t type, const gchar *name)
|
||||
{
|
||||
if (type < PL_MAX_TYPE && playlist_types[type]->pl_new)
|
||||
|
@ -99,6 +97,30 @@ struct playlist *playlist_get(enum playlist_type_t type, unsigned int id)
|
|||
return playlist_types[type]->pl_get(id);
|
||||
}
|
||||
|
||||
bool playlist_select(struct playlist *playlist)
|
||||
{
|
||||
if (!playlist || (playlist == current))
|
||||
return false;
|
||||
if (!playlist->pl_ops->pl_can_select)
|
||||
return false;
|
||||
if (!playlist->pl_ops->pl_can_select(playlist))
|
||||
return false;
|
||||
|
||||
previous = current;
|
||||
current = playlist;
|
||||
|
||||
settings_set(SETTINGS_CUR_TYPE, current->pl_type);
|
||||
settings_set(SETTINGS_CUR_ID, playlist_get_id(current->pl_type,
|
||||
current->pl_name));
|
||||
|
||||
if (previous) {
|
||||
settings_set(SETTINGS_PREV_TYPE, previous->pl_type);
|
||||
settings_set(SETTINGS_PREV_ID,
|
||||
playlist_get_id(previous->pl_type, previous->pl_name));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool playlist_add(struct playlist *playlist, struct track *track)
|
||||
{
|
||||
bool ret;
|
||||
|
@ -110,7 +132,7 @@ bool playlist_add(struct playlist *playlist, struct track *track)
|
|||
if (ret)
|
||||
playlist_types[playlist->pl_type]->pl_save();
|
||||
if (playlist == playlist_lookup(PL_SYSTEM, "Queued Tracks"))
|
||||
playlist_select(PL_SYSTEM, "Queued Tracks");
|
||||
playlist_select(playlist);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -169,16 +191,14 @@ bool playlist_sort(struct playlist *playlist, enum compare_t sort, bool reset)
|
|||
|
||||
struct track *playlist_next(void)
|
||||
{
|
||||
enum playlist_type_t type = settings_get(SETTINGS_CUR_TYPE);
|
||||
unsigned int id = settings_get(SETTINGS_CUR_ID);
|
||||
struct playlist *playlist = playlist_get(type, id);
|
||||
struct track *track = playlist_types[type]->pl_next(playlist->pl_name);
|
||||
struct track *track;
|
||||
|
||||
if (playlist_size(playlist) == 0) {
|
||||
settings_set(SETTINGS_CUR_ID, settings_get(SETTINGS_PREV_ID));
|
||||
settings_set(SETTINGS_CUR_TYPE, settings_get(SETTINGS_PREV_TYPE));
|
||||
}
|
||||
if (!current)
|
||||
return NULL;
|
||||
|
||||
track = playlist_types[current->pl_type]->pl_next(current->pl_name);
|
||||
if (playlist_size(current) == 0)
|
||||
playlist_select(previous);
|
||||
return track;
|
||||
}
|
||||
|
||||
|
@ -189,9 +209,7 @@ struct track *playlist_prev(void)
|
|||
|
||||
struct playlist *playlist_cur(void)
|
||||
{
|
||||
enum playlist_type_t type = settings_get(SETTINGS_CUR_TYPE);
|
||||
unsigned int id = settings_get(SETTINGS_CUR_ID);
|
||||
return playlist_get(type, id);
|
||||
return current;
|
||||
}
|
||||
|
||||
struct queue *playlist_get_queue(enum playlist_type_t type, const gchar *name)
|
||||
|
|
|
@ -9,8 +9,9 @@ static struct queue_ops *artist_ops = NULL;
|
|||
static struct file artist_file = FILE_INIT("playlist.artist", 0);
|
||||
|
||||
static struct playlist_ops pl_artist_ops = {
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
.pl_can_select = playlist_generic_can_select,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
};
|
||||
|
||||
|
||||
|
@ -117,12 +118,6 @@ static unsigned int pl_artist_get_id(const gchar *name)
|
|||
return artist ? artist->ar_dbe.dbe_index : -1;
|
||||
}
|
||||
|
||||
static bool pl_artist_can_select(const gchar *name)
|
||||
{
|
||||
struct playlist *playlist = __artist_pl_lookup(name);
|
||||
return playlist ? playlist_generic_can_select(playlist) : false;
|
||||
}
|
||||
|
||||
static void pl_artist_update(const gchar *name)
|
||||
{
|
||||
}
|
||||
|
@ -137,13 +132,12 @@ static struct track *pl_artist_next(const gchar *name)
|
|||
|
||||
|
||||
struct playlist_type pl_artist = {
|
||||
.pl_save = pl_artist_save,
|
||||
.pl_lookup = pl_artist_lookup,
|
||||
.pl_get = pl_artist_get,
|
||||
.pl_get_id = pl_artist_get_id,
|
||||
.pl_can_select = pl_artist_can_select,
|
||||
.pl_update = pl_artist_update,
|
||||
.pl_next = pl_artist_next,
|
||||
.pl_save = pl_artist_save,
|
||||
.pl_lookup = pl_artist_lookup,
|
||||
.pl_get = pl_artist_get,
|
||||
.pl_get_id = pl_artist_get_id,
|
||||
.pl_update = pl_artist_update,
|
||||
.pl_next = pl_artist_next,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -5,15 +5,6 @@
|
|||
#include <core/playlists/type.h>
|
||||
|
||||
|
||||
/*
|
||||
* Noop playlist operations.
|
||||
*/
|
||||
bool playlist_noop_can_select(struct playlist *playlist)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Generic playlist operations.
|
||||
*/
|
||||
|
|
|
@ -193,9 +193,10 @@ static bool pl_library_delete(struct playlist *playlist)
|
|||
|
||||
|
||||
static struct playlist_ops pl_library_ops = {
|
||||
.pl_delete = pl_library_delete,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
.pl_can_select = playlist_generic_can_select,
|
||||
.pl_delete = pl_library_delete,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
};
|
||||
|
||||
|
||||
|
@ -234,12 +235,6 @@ static unsigned int pl_library_get_id(const gchar *name)
|
|||
return library ? library->li_dbe.dbe_index : -1;
|
||||
}
|
||||
|
||||
static bool pl_library_can_select(const gchar *name)
|
||||
{
|
||||
struct playlist *playlist = __lib_pl_lookup(name);
|
||||
return playlist ? playlist_generic_can_select(playlist) : false;
|
||||
}
|
||||
|
||||
static struct playlist *pl_library_new(const gchar *name)
|
||||
{
|
||||
struct library *library;
|
||||
|
@ -271,14 +266,13 @@ static struct track *pl_library_next(const gchar *name)
|
|||
|
||||
|
||||
struct playlist_type pl_library = {
|
||||
.pl_save = pl_library_save,
|
||||
.pl_lookup = pl_library_lookup,
|
||||
.pl_get = pl_library_get,
|
||||
.pl_get_id = pl_library_get_id,
|
||||
.pl_can_select = pl_library_can_select,
|
||||
.pl_new = pl_library_new,
|
||||
.pl_update = pl_library_update,
|
||||
.pl_next = pl_library_next,
|
||||
.pl_save = pl_library_save,
|
||||
.pl_lookup = pl_library_lookup,
|
||||
.pl_get = pl_library_get,
|
||||
.pl_get_id = pl_library_get_id,
|
||||
.pl_new = pl_library_new,
|
||||
.pl_update = pl_library_update,
|
||||
.pl_next = pl_library_next,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -77,11 +77,12 @@ static bool sys_pl_generic_add_front(struct playlist *playlist,
|
|||
* Favorite tracks playlist operations.
|
||||
*/
|
||||
static struct playlist_ops favorites_ops = {
|
||||
.pl_add = playlist_generic_add_track,
|
||||
.pl_delete = sys_pl_delete_clear,
|
||||
.pl_remove = playlist_generic_remove_track,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
.pl_add = playlist_generic_add_track,
|
||||
.pl_can_select = playlist_generic_can_select,
|
||||
.pl_delete = sys_pl_delete_clear,
|
||||
.pl_remove = playlist_generic_remove_track,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
};
|
||||
|
||||
static struct sys_playlist sys_favorites = {
|
||||
|
@ -89,7 +90,6 @@ static struct sys_playlist sys_favorites = {
|
|||
.spl_init = playlist_generic_init,
|
||||
.spl_save = sys_pl_save_full,
|
||||
.spl_load = sys_pl_load_full,
|
||||
.spl_can_select = playlist_generic_can_select,
|
||||
.spl_next = playlist_generic_next,
|
||||
};
|
||||
|
||||
|
@ -135,11 +135,12 @@ static bool sys_pl_hidden_clear(struct playlist *playlist)
|
|||
}
|
||||
|
||||
static struct playlist_ops hidden_ops = {
|
||||
.pl_add = sys_pl_hidden_add,
|
||||
.pl_delete = sys_pl_hidden_clear,
|
||||
.pl_remove = sys_pl_hidden_remove,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
.pl_add = sys_pl_hidden_add,
|
||||
.pl_can_select = playlist_generic_can_select,
|
||||
.pl_delete = sys_pl_hidden_clear,
|
||||
.pl_remove = sys_pl_hidden_remove,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
};
|
||||
|
||||
static struct sys_playlist sys_hidden = {
|
||||
|
@ -147,7 +148,6 @@ static struct sys_playlist sys_hidden = {
|
|||
.spl_init = playlist_generic_init,
|
||||
.spl_save = sys_pl_save_full,
|
||||
.spl_load = sys_pl_load_full,
|
||||
.spl_can_select = playlist_generic_can_select,
|
||||
.spl_next = playlist_generic_next,
|
||||
};
|
||||
|
||||
|
@ -184,20 +184,20 @@ static void sys_pl_queued_init(struct playlist *playlist,
|
|||
}
|
||||
|
||||
static struct playlist_ops queued_ops = {
|
||||
.pl_add = playlist_generic_add_track,
|
||||
.pl_delete = sys_pl_delete_clear,
|
||||
.pl_remove = playlist_generic_remove_track,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
.pl_add = playlist_generic_add_track,
|
||||
.pl_can_select = playlist_generic_can_select,
|
||||
.pl_delete = sys_pl_delete_clear,
|
||||
.pl_remove = playlist_generic_remove_track,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
};
|
||||
|
||||
static struct sys_playlist sys_queued = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Queued Tracks", &queued_ops),
|
||||
.spl_init = sys_pl_queued_init,
|
||||
.spl_save = sys_pl_save_full,
|
||||
.spl_load = sys_pl_load_full,
|
||||
.spl_can_select = playlist_generic_can_select,
|
||||
.spl_next = playlist_generic_next,
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Queued Tracks", &queued_ops),
|
||||
.spl_init = sys_pl_queued_init,
|
||||
.spl_save = sys_pl_save_full,
|
||||
.spl_load = sys_pl_load_full,
|
||||
.spl_next = playlist_generic_next,
|
||||
};
|
||||
|
||||
|
||||
|
@ -217,11 +217,6 @@ static bool sys_pl_collection_load()
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool sys_pl_collection_can_select(struct playlist *playlist)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool sys_pl_collection_update(struct playlist *playlist,
|
||||
struct track *track)
|
||||
{
|
||||
|
@ -229,20 +224,20 @@ static bool sys_pl_collection_update(struct playlist *playlist,
|
|||
}
|
||||
|
||||
static struct playlist_ops collection_ops = {
|
||||
.pl_remove = sys_pl_hidden_add,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
.pl_can_select = playlist_generic_can_select,
|
||||
.pl_remove = sys_pl_hidden_add,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
};
|
||||
|
||||
static struct sys_playlist sys_collection = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Collection",
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Collection",
|
||||
&collection_ops),
|
||||
.spl_init = sys_pl_update_init,
|
||||
.spl_save = sys_pl_save_partial,
|
||||
.spl_load = sys_pl_load_partial,
|
||||
.spl_can_select = sys_pl_collection_can_select,
|
||||
.spl_update = sys_pl_collection_update,
|
||||
.spl_next = playlist_generic_next,
|
||||
.spl_init = sys_pl_update_init,
|
||||
.spl_save = sys_pl_save_partial,
|
||||
.spl_load = sys_pl_load_partial,
|
||||
.spl_update = sys_pl_collection_update,
|
||||
.spl_next = playlist_generic_next,
|
||||
};
|
||||
|
||||
|
||||
|
@ -267,12 +262,11 @@ static struct playlist_ops history_ops = {
|
|||
};
|
||||
|
||||
static struct sys_playlist sys_history = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "History", &history_ops),
|
||||
.spl_init = sys_pl_history_init,
|
||||
.spl_save = sys_pl_save_partial,
|
||||
.spl_load = sys_pl_load_partial,
|
||||
.spl_can_select = playlist_noop_can_select,
|
||||
.spl_next = playlist_generic_next,
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "History", &history_ops),
|
||||
.spl_init = sys_pl_history_init,
|
||||
.spl_save = sys_pl_save_partial,
|
||||
.spl_load = sys_pl_load_partial,
|
||||
.spl_next = playlist_generic_next,
|
||||
};
|
||||
|
||||
|
||||
|
@ -288,18 +282,18 @@ static bool sys_pl_unplayed_update(struct playlist *playlist,
|
|||
}
|
||||
|
||||
static struct playlist_ops unplayed_ops = {
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
.pl_can_select = playlist_generic_can_select,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
};
|
||||
|
||||
static struct sys_playlist sys_unplayed = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Unplayed", &unplayed_ops),
|
||||
.spl_init = sys_pl_update_init,
|
||||
.spl_save = sys_pl_save_partial,
|
||||
.spl_load = sys_pl_load_partial,
|
||||
.spl_can_select = playlist_generic_can_select,
|
||||
.spl_update = sys_pl_unplayed_update,
|
||||
.spl_next = playlist_generic_next,
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Unplayed", &unplayed_ops),
|
||||
.spl_init = sys_pl_update_init,
|
||||
.spl_save = sys_pl_save_partial,
|
||||
.spl_load = sys_pl_load_partial,
|
||||
.spl_update = sys_pl_unplayed_update,
|
||||
.spl_next = playlist_generic_next,
|
||||
};
|
||||
|
||||
|
||||
|
@ -316,19 +310,19 @@ static bool sys_pl_most_played_update(struct playlist *playlist,
|
|||
}
|
||||
|
||||
static struct playlist_ops most_played_ops = {
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
.pl_can_select = playlist_generic_can_select,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
};
|
||||
|
||||
static struct sys_playlist sys_most_played = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Most Played",
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Most Played",
|
||||
&most_played_ops),
|
||||
.spl_init = sys_pl_update_init,
|
||||
.spl_save = sys_pl_save_partial,
|
||||
.spl_load = sys_pl_load_partial,
|
||||
.spl_can_select = playlist_generic_can_select,
|
||||
.spl_update = sys_pl_most_played_update,
|
||||
.spl_next = playlist_generic_next,
|
||||
.spl_init = sys_pl_update_init,
|
||||
.spl_save = sys_pl_save_partial,
|
||||
.spl_load = sys_pl_load_partial,
|
||||
.spl_update = sys_pl_most_played_update,
|
||||
.spl_next = playlist_generic_next,
|
||||
};
|
||||
|
||||
|
||||
|
@ -345,19 +339,19 @@ static bool sys_pl_least_played_update(struct playlist *playlist,
|
|||
}
|
||||
|
||||
static struct playlist_ops least_played_ops = {
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
.pl_can_select = playlist_generic_can_select,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
};
|
||||
|
||||
static struct sys_playlist sys_least_played = {
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Least Played",
|
||||
.spl_playlist = DEFINE_PLAYLIST(PL_SYSTEM, "Least Played",
|
||||
&least_played_ops),
|
||||
.spl_init = sys_pl_update_init,
|
||||
.spl_save = sys_pl_save_partial,
|
||||
.spl_load = sys_pl_load_partial,
|
||||
.spl_can_select = playlist_generic_can_select,
|
||||
.spl_update = sys_pl_least_played_update,
|
||||
.spl_next = playlist_generic_next,
|
||||
.spl_init = sys_pl_update_init,
|
||||
.spl_save = sys_pl_save_partial,
|
||||
.spl_load = sys_pl_load_partial,
|
||||
.spl_update = sys_pl_least_played_update,
|
||||
.spl_next = playlist_generic_next,
|
||||
};
|
||||
|
||||
|
||||
|
@ -490,12 +484,6 @@ static unsigned int pl_system_get_id(const gchar *name)
|
|||
return SYS_PL_NUM_PLAYLISTS;
|
||||
}
|
||||
|
||||
static bool pl_system_can_select(const gchar *name)
|
||||
{
|
||||
struct sys_playlist *sys_pl = __sys_pl_lookup(name);
|
||||
return sys_pl ? sys_pl->spl_can_select(&sys_pl->spl_playlist) : false;
|
||||
}
|
||||
|
||||
static void pl_system_update(const gchar *name)
|
||||
{
|
||||
struct sys_playlist *sys_pl = __sys_pl_lookup(name);
|
||||
|
@ -516,13 +504,12 @@ static struct track *pl_system_next(const gchar *name)
|
|||
|
||||
|
||||
struct playlist_type pl_system = {
|
||||
.pl_save = pl_system_save,
|
||||
.pl_lookup = pl_system_lookup,
|
||||
.pl_get = pl_system_get,
|
||||
.pl_get_id = pl_system_get_id,
|
||||
.pl_can_select = pl_system_can_select,
|
||||
.pl_update = pl_system_update,
|
||||
.pl_next = pl_system_next,
|
||||
.pl_save = pl_system_save,
|
||||
.pl_lookup = pl_system_lookup,
|
||||
.pl_get = pl_system_get,
|
||||
.pl_get_id = pl_system_get_id,
|
||||
.pl_update = pl_system_update,
|
||||
.pl_next = pl_system_next,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -82,11 +82,12 @@ static bool pl_user_delete(struct playlist *playlist)
|
|||
|
||||
|
||||
static struct playlist_ops user_ops = {
|
||||
.pl_add = playlist_generic_add_track,
|
||||
.pl_delete = pl_user_delete,
|
||||
.pl_remove = playlist_generic_remove_track,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
.pl_add = playlist_generic_add_track,
|
||||
.pl_can_select = playlist_generic_can_select,
|
||||
.pl_delete = pl_user_delete,
|
||||
.pl_remove = playlist_generic_remove_track,
|
||||
.pl_set_flag = playlist_generic_set_flag,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
};
|
||||
|
||||
|
||||
|
@ -113,11 +114,6 @@ static unsigned int pl_user_get_id(const gchar *name)
|
|||
return dbe ? dbe->dbe_index : -1;
|
||||
}
|
||||
|
||||
static bool pl_user_can_select(const gchar *name)
|
||||
{
|
||||
return db_get(&user_db, name) != NULL;
|
||||
}
|
||||
|
||||
static struct playlist *pl_user_new(const gchar *name)
|
||||
{
|
||||
struct db_entry *dbe;
|
||||
|
@ -142,14 +138,13 @@ static struct track *pl_user_next(const gchar *name)
|
|||
|
||||
|
||||
struct playlist_type pl_user = {
|
||||
.pl_save = pl_user_save,
|
||||
.pl_lookup = pl_user_lookup,
|
||||
.pl_get = pl_user_get,
|
||||
.pl_get_id = pl_user_get_id,
|
||||
.pl_can_select = pl_user_can_select,
|
||||
.pl_new = pl_user_new,
|
||||
.pl_update = pl_user_update,
|
||||
.pl_next = pl_user_next,
|
||||
.pl_save = pl_user_save,
|
||||
.pl_lookup = pl_user_lookup,
|
||||
.pl_get = pl_user_get,
|
||||
.pl_get_id = pl_user_get_id,
|
||||
.pl_new = pl_user_new,
|
||||
.pl_update = pl_user_update,
|
||||
.pl_next = pl_user_next,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -309,21 +309,13 @@ void gui_sidebar_iter_select(GtkTreeIter *iter)
|
|||
void gui_sidebar_filter_path_select(GtkTreePath *path)
|
||||
{
|
||||
GtkTreeModel *model = GTK_TREE_MODEL(gui_sidebar_filter());
|
||||
enum playlist_type_t type;
|
||||
GtkTreeIter iter, child;
|
||||
gchar *name;
|
||||
|
||||
gtk_tree_model_get_iter(model, &iter, path);
|
||||
__gui_sidebar_filter_iter_convert(&iter, &child);
|
||||
|
||||
type = gui_sidebar_iter_type(&child);
|
||||
if (type >= PL_MAX_TYPE)
|
||||
return;
|
||||
|
||||
name = gui_sidebar_iter_name(&child);
|
||||
if (playlist_select(type, name))
|
||||
if (playlist_select(gui_sidebar_iter_playlist(&child)))
|
||||
gui_sidebar_iter_update(&child);
|
||||
g_free(name);
|
||||
}
|
||||
|
||||
void gui_sidebar_filter_set_expand(GtkTreeIter *iter)
|
||||
|
|
|
@ -24,9 +24,6 @@ void playlist_deinit();
|
|||
/* Called to force-save all playlists. */
|
||||
void playlist_save();
|
||||
|
||||
/* Called to select the current playlist. */
|
||||
bool playlist_select(enum playlist_type_t, const gchar *);
|
||||
|
||||
|
||||
/* Called to create a new playlist. */
|
||||
struct playlist *playlist_new(enum playlist_type_t, const gchar *);
|
||||
|
@ -40,6 +37,10 @@ struct playlist *playlist_lookup(enum playlist_type_t, const gchar *);
|
|||
struct playlist *playlist_get(enum playlist_type_t, unsigned int);
|
||||
|
||||
|
||||
/* Called to select the current playlist. */
|
||||
bool playlist_select(struct playlist *);
|
||||
|
||||
|
||||
/* Called to add a track to a playlist. */
|
||||
bool playlist_add(struct playlist *, struct track *);
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ struct sys_playlist {
|
|||
void (*spl_init)(struct playlist *, unsigned int, struct queue_ops *);
|
||||
void (*spl_save)(struct playlist *, struct file *);
|
||||
void (*spl_load)(struct playlist *, struct file *);
|
||||
bool (*spl_can_select)(struct playlist *);
|
||||
bool (*spl_update)(struct playlist *, struct track *);
|
||||
struct track *(*spl_next)(struct playlist *);
|
||||
};
|
||||
|
|
|
@ -24,6 +24,9 @@ struct playlist_ops {
|
|||
/* Called to add a track to a playlist. */
|
||||
bool (*pl_add)(struct playlist *, struct track *);
|
||||
|
||||
/* Called to check if a playlist can be selected. */
|
||||
bool (*pl_can_select)(struct playlist *);
|
||||
|
||||
/* Called to delete a playlist. */
|
||||
bool (*pl_delete)(struct playlist *);
|
||||
|
||||
|
@ -66,9 +69,6 @@ struct playlist_type {
|
|||
/* Called to convert a playlist name to an integer id. */
|
||||
unsigned int (*pl_get_id)(const gchar *);
|
||||
|
||||
/* Called to check if a playlist can be selected. */
|
||||
bool (*pl_can_select)(const gchar *);
|
||||
|
||||
/* Called to create a new playlist. */
|
||||
struct playlist *(*pl_new)(const gchar *);
|
||||
|
||||
|
@ -80,10 +80,6 @@ struct playlist_type {
|
|||
};
|
||||
|
||||
|
||||
/* Noop playlist can-select operation. */
|
||||
bool playlist_noop_can_select(struct playlist *);
|
||||
|
||||
|
||||
/* Generic playlist init function. */
|
||||
void playlist_generic_init(struct playlist *, unsigned int, struct queue_ops *);
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ static void test_next()
|
|||
g_assert_cmpuint(playlist_size(playlist_lookup(PL_SYSTEM, "Queued Tracks")), ==, 0);
|
||||
|
||||
/* Tracks should now be picked from the collection. */
|
||||
playlist_select(PL_SYSTEM, "Collection");
|
||||
playlist_select(playlist_lookup(PL_SYSTEM, "Collection"));
|
||||
for (i = 1; i <= 3; i++) {
|
||||
if (i < 3)
|
||||
g_assert_cmpuint(audio_next()->tr_track, ==, i);
|
||||
|
|
|
@ -16,6 +16,10 @@ static void test_null()
|
|||
g_assert_null(playlist_lookup(PL_MAX_TYPE, NULL));
|
||||
g_assert_null(playlist_get(PL_MAX_TYPE, 0));
|
||||
|
||||
g_assert(playlist_cur() == playlist_lookup(PL_SYSTEM, "Collection"));
|
||||
g_assert_false(playlist_select(NULL));
|
||||
g_assert(playlist_cur() == playlist_lookup(PL_SYSTEM, "Collection"));
|
||||
|
||||
g_assert_false(playlist_add(NULL, NULL));
|
||||
g_assert_false(playlist_add(NULL, track_get(0)));
|
||||
g_assert_false(playlist_has(NULL, NULL));
|
||||
|
|
|
@ -18,11 +18,10 @@ void test_artist()
|
|||
g_assert_null(playlist_new(PL_ARTIST, "Koji Kondo"));
|
||||
g_assert_null(playlist_get_queue(PL_ARTIST, "Koji Kondo"));
|
||||
|
||||
artist = artist_find("Koji Kondo");
|
||||
artist = artist_find("Koji Kondo");
|
||||
g_assert_null(artist->ar_playlist);
|
||||
g_assert_false(playlist_add(NULL, track_get(0)));
|
||||
g_assert_false(playlist_select(PL_ARTIST, "Koji Kondo"));
|
||||
g_assert_false(playlist_select(PL_ARTIST, "Hajime Wakai"));
|
||||
g_assert_false(playlist_select(NULL));
|
||||
|
||||
pl_artist_deinit();
|
||||
pl_artist_init(NULL);
|
||||
|
@ -38,11 +37,12 @@ void test_artist()
|
|||
g_assert_false(playlist_remove(playlist, track_get(0)));
|
||||
g_assert_cmpuint(playlist_size(playlist), ==, 2);
|
||||
|
||||
g_assert(playlist_cur() != playlist_lookup(PL_ARTIST, "Koji Kondo"));
|
||||
g_assert_true(playlist_select(PL_ARTIST, "Koji Kondo"));
|
||||
g_assert(playlist_cur() != playlist);
|
||||
g_assert_true(playlist_select(playlist));
|
||||
g_assert_cmpuint(settings_get("core.playlist.cur.type"), ==, PL_ARTIST);
|
||||
g_assert_cmpuint(settings_get("core.playlist.cur.id"), ==, 0);
|
||||
g_assert(playlist_cur() == playlist_lookup(PL_ARTIST, "Koji Kondo"));
|
||||
g_assert(playlist_cur() == playlist);
|
||||
g_assert_false(playlist_select(playlist));
|
||||
|
||||
g_assert_false(playlist_delete(playlist));
|
||||
pl_artist_deinit();
|
||||
|
|
|
@ -16,7 +16,7 @@ void test_library()
|
|||
g_assert_null(playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony/01 - Title Theme.ogg"));
|
||||
|
||||
g_assert_null(playlist_get_queue(PL_LIBRARY, "tests/Music"));
|
||||
g_assert_false(playlist_select(PL_LIBRARY, "tests/Music"));
|
||||
g_assert_false(playlist_select(NULL));
|
||||
|
||||
playlist = playlist_new(PL_LIBRARY, "tests/Music");
|
||||
g_assert_nonnull(playlist);
|
||||
|
@ -24,7 +24,6 @@ void test_library()
|
|||
g_assert_nonnull(playlist_get_queue(PL_LIBRARY, "tests/Music"));
|
||||
|
||||
g_assert_cmpuint(playlist_get_id(PL_LIBRARY, "tests/Music"), ==, 0);
|
||||
g_assert_false(playlist_select(PL_LIBRARY, "tests/Music"));
|
||||
|
||||
library = library_get(0);
|
||||
playlist = library->li_playlist;
|
||||
|
@ -39,11 +38,13 @@ void test_library()
|
|||
g_assert_cmpuint(playlist_size(playlist_lookup(PL_SYSTEM, "Collection")),
|
||||
==, 48);
|
||||
|
||||
g_assert(playlist_cur() != playlist_lookup(PL_LIBRARY, "tests/Music"));
|
||||
g_assert_true(playlist_select(PL_LIBRARY, "tests/Music"));
|
||||
playlist = playlist_lookup(PL_LIBRARY, "tests/Music");
|
||||
g_assert(playlist_cur() != playlist);
|
||||
g_assert_true(playlist_select(playlist));
|
||||
g_assert_cmpuint(settings_get("core.playlist.cur.type"), ==, PL_LIBRARY);
|
||||
g_assert_cmpuint(settings_get("core.playlist.cur.id"), ==, 0);
|
||||
g_assert(playlist_cur() == playlist_lookup(PL_LIBRARY, "tests/Music"));
|
||||
g_assert(playlist_cur() == playlist);
|
||||
g_assert_false(playlist_select(playlist));
|
||||
|
||||
g_assert_false(playlist_add(playlist, track_get(0)));
|
||||
g_assert_false(playlist_add(playlist, track_get(1)));
|
||||
|
|
|
@ -56,20 +56,6 @@
|
|||
__test_playlist_state("Hidden", 0, false, false); \
|
||||
__test_playlist_state(name, ex_size, ex_track0, ex_track1);
|
||||
|
||||
#define __test_playlist_select(name, id) \
|
||||
g_assert_true(playlist_select(PL_SYSTEM, name)); \
|
||||
g_assert_cmpuint(settings_get("core.playlist.cur.id"), ==, id); \
|
||||
g_assert(playlist_cur() == playlist_lookup(PL_SYSTEM, name))
|
||||
|
||||
#define __test_playlist_noselect(name) \
|
||||
do { \
|
||||
unsigned int id = settings_get("core.playlist.cur.id"); \
|
||||
struct playlist *cur = playlist_cur(); \
|
||||
g_assert_false(playlist_select(PL_SYSTEM, name)); \
|
||||
g_assert_cmpuint(settings_get("core.playlist.cur.id"), ==, id); \
|
||||
g_assert(playlist_cur() == cur); \
|
||||
} while (0)
|
||||
|
||||
#define __test_playlist_reinit(name, ex_size, ex_track0, ex_track1) \
|
||||
do { \
|
||||
struct queue *queue; \
|
||||
|
@ -106,6 +92,15 @@ static void test_init()
|
|||
struct playlist *playlist;
|
||||
unsigned int i;
|
||||
|
||||
g_assert(playlist_cur() == __test_pl_collection());
|
||||
|
||||
for (i = 0; i < SYS_PL_NUM_PLAYLISTS; i++) {
|
||||
playlist = playlist_get(PL_SYSTEM, i);
|
||||
g_assert_nonnull(playlist);
|
||||
g_assert(playlist_lookup(PL_SYSTEM, playlist->pl_name) == playlist);
|
||||
g_assert_false(playlist_select(playlist));
|
||||
}
|
||||
|
||||
/* Add tracks to the collection. */
|
||||
track_add(library, "tests/Music/Hyrule Symphony/01 - Title Theme.ogg");
|
||||
track_add(library, "tests/Music/Hyrule Symphony/02 - Kokiri Forest.ogg");
|
||||
|
@ -115,9 +110,6 @@ static void test_init()
|
|||
g_assert_null(playlist_new(PL_SYSTEM, "New Playlist"));
|
||||
for (i = 0; i < SYS_PL_NUM_PLAYLISTS; i++) {
|
||||
playlist = playlist_get(PL_SYSTEM, i);
|
||||
g_assert_nonnull(playlist);
|
||||
g_assert(playlist_lookup(PL_SYSTEM, playlist->pl_name) == playlist);
|
||||
|
||||
if (i == SYS_PL_COLLECTION || i == SYS_PL_UNPLAYED)
|
||||
g_assert_cmpuint(playlist_size(playlist), ==, 2);
|
||||
else
|
||||
|
@ -135,9 +127,6 @@ static void test_invalid()
|
|||
g_assert_cmpuint(playlist_get_id(PL_SYSTEM, "Invalid"), ==,
|
||||
SYS_PL_NUM_PLAYLISTS);
|
||||
|
||||
__test_playlist_noselect(NULL);
|
||||
__test_playlist_noselect("Invalid");
|
||||
|
||||
playlist_update(PL_SYSTEM, NULL);
|
||||
}
|
||||
|
||||
|
@ -149,9 +138,7 @@ static void test_favorites()
|
|||
g_assert_true(queue_has_flag(queue, Q_REPEAT));
|
||||
|
||||
__test_playlist_id("Favorites", SYS_PL_FAVORITES);
|
||||
__test_playlist_noselect("Favorites");
|
||||
__test_playlist_add("Favorites");
|
||||
__test_playlist_select("Favorites", SYS_PL_FAVORITES);
|
||||
__test_playlist_reinit("Favorites", 2, true, true);
|
||||
__test_playlist_update("Favorites", 2, true, true);
|
||||
__test_playlist_remove("Favorites");
|
||||
|
@ -166,9 +153,7 @@ static void test_hidden()
|
|||
g_assert_true(queue_has_flag(queue, Q_REPEAT));
|
||||
|
||||
__test_playlist_id("Hidden", SYS_PL_HIDDEN);
|
||||
__test_playlist_noselect("Hidden");
|
||||
__test_playlist_add("Hidden");
|
||||
__test_playlist_select("Hidden", SYS_PL_HIDDEN);
|
||||
__test_playlist_reinit("Hidden", 2, true, true);
|
||||
__test_playlist_update("Hidden", 2, true, true);
|
||||
__test_playlist_remove("Hidden");
|
||||
|
@ -183,17 +168,15 @@ static void test_queued()
|
|||
g_assert_cmpuint(g_slist_length(queue->q_sort), ==, 0);
|
||||
|
||||
__test_playlist_id("Queued Tracks", SYS_PL_QUEUED);
|
||||
__test_playlist_noselect("Queued Tracks");
|
||||
__test_playlist_add("Queued Tracks");
|
||||
__test_playlist_select("Queued Tracks", SYS_PL_QUEUED);
|
||||
__test_playlist_reinit("Queued Tracks", 2, true, true);
|
||||
|
||||
g_assert(playlist_next() == track_get(0));
|
||||
g_assert_cmpuint(playlist_size(__test_pl_queued()), ==, 1);
|
||||
playlist_select(PL_SYSTEM, "Collection");
|
||||
playlist_select(__test_pl_collection());
|
||||
g_assert(playlist_next() == track_get(0));
|
||||
g_assert_cmpuint(playlist_size(__test_pl_queued()), ==, 1);
|
||||
playlist_select(PL_SYSTEM, "Queued Tracks");
|
||||
playlist_select(__test_pl_queued());
|
||||
g_assert(playlist_next() == track_get(1));
|
||||
g_assert_cmpuint(playlist_size(__test_pl_queued()), ==, 0);
|
||||
g_assert(playlist_next() == track_get(1));
|
||||
|
@ -214,7 +197,6 @@ static void test_collection()
|
|||
g_assert_true(queue_has_flag(queue, Q_REPEAT));
|
||||
|
||||
__test_playlist_id("Collection", SYS_PL_COLLECTION);
|
||||
__test_playlist_select("Collection", SYS_PL_COLLECTION);
|
||||
__test_playlist_update("Collection", 2, true, true);
|
||||
__test_playlist_hide_track("Collection", 1, false, true);
|
||||
__test_playlist_reinit("Collection", 1, false, true);
|
||||
|
@ -231,7 +213,6 @@ static void test_history()
|
|||
g_assert_nonnull(queue);
|
||||
g_assert_true(queue_has_flag(queue, Q_REPEAT));
|
||||
__test_playlist_id("History", SYS_PL_HISTORY);
|
||||
__test_playlist_noselect("History");
|
||||
|
||||
__test_playlist_state("History", 0, false, false);
|
||||
g_assert_true(playlist_add(__test_pl_history(), track_get(0)));
|
||||
|
@ -239,7 +220,6 @@ static void test_history()
|
|||
g_assert_true(playlist_add(__test_pl_history(), track_get(1)));
|
||||
g_assert_true(playlist_add(__test_pl_history(), track_get(1)));
|
||||
__test_playlist_state("History", 4, true, true);
|
||||
__test_playlist_noselect("History");
|
||||
|
||||
g_assert(playlist_prev() == track_get(1));
|
||||
g_assert(playlist_prev() == track_get(0));
|
||||
|
@ -262,12 +242,10 @@ static void test_unplayed()
|
|||
g_assert_true(queue_has_flag(queue, Q_REPEAT));
|
||||
|
||||
__test_playlist_id("Unplayed", SYS_PL_UNPLAYED);
|
||||
__test_playlist_noselect("Unplayed");
|
||||
__test_playlist_reinit("Unplayed", 2, true, true);
|
||||
|
||||
track_get(1)->tr_count = 1;
|
||||
__test_playlist_update("Unplayed", 1, true, false);
|
||||
__test_playlist_select("Unplayed", SYS_PL_UNPLAYED);
|
||||
|
||||
track_get(0)->tr_count = 1;
|
||||
track_get(1)->tr_count = 0;
|
||||
|
@ -301,9 +279,7 @@ static void test_most_played()
|
|||
g_assert_true(queue_has_flag(most, Q_REPEAT));
|
||||
|
||||
__test_playlist_id("Most Played", SYS_PL_MOST_PLAYED);
|
||||
__test_playlist_noselect("Most Played");
|
||||
__test_playlist_reinit("Most Played", 1, false, true);
|
||||
__test_playlist_select("Most Played", SYS_PL_MOST_PLAYED);
|
||||
|
||||
track_get(0)->tr_count = 3;
|
||||
track_get(1)->tr_count = 1;
|
||||
|
@ -332,9 +308,7 @@ static void test_least_played()
|
|||
g_assert_true(queue_has_flag(least, Q_REPEAT));
|
||||
|
||||
__test_playlist_id("Least Played", SYS_PL_LEAST_PLAYED);
|
||||
__test_playlist_noselect("Least Played");
|
||||
__test_playlist_reinit("Least Played", 1, false, true);
|
||||
__test_playlist_select("Least Played", SYS_PL_LEAST_PLAYED);
|
||||
|
||||
track_get(0)->tr_count = 1;
|
||||
track_get(1)->tr_count = 3;
|
||||
|
@ -398,6 +372,9 @@ static void test_sort()
|
|||
static void test_add()
|
||||
{
|
||||
struct library *library = library_find("tests/Music");
|
||||
struct playlist *playlist;
|
||||
unsigned int i;
|
||||
|
||||
track_add(library, "tests/Music/Hyrule Symphony/03 - Hyrule Field.ogg");
|
||||
pl_system_new_track(track_get(2));
|
||||
|
||||
|
@ -441,10 +418,30 @@ static void test_add()
|
|||
g_assert_false(playlist_has(__test_pl_most_played(), track_get(0)));
|
||||
g_assert_false(playlist_has(__test_pl_least_played(), track_get(1)));
|
||||
g_assert_false(playlist_has(__test_pl_unplayed(), track_get(2)));
|
||||
|
||||
for (i = 0; i < SYS_PL_NUM_PLAYLISTS; i++) {
|
||||
playlist = playlist_get(PL_SYSTEM, i);
|
||||
|
||||
switch (i) {
|
||||
case SYS_PL_FAVORITES:
|
||||
case SYS_PL_HIDDEN:
|
||||
case SYS_PL_QUEUED:
|
||||
g_assert_true( playlist_select(playlist));
|
||||
g_assert_false(playlist_select(playlist));
|
||||
g_assert(playlist_cur() == playlist);
|
||||
break;
|
||||
default:
|
||||
g_assert_false(playlist_select(playlist));
|
||||
g_assert(playlist_cur() != playlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test_remove()
|
||||
{
|
||||
struct playlist *playlist;
|
||||
unsigned int i;
|
||||
|
||||
g_assert_true( playlist_remove(__test_pl_favorites(), track_get(0)));
|
||||
g_assert_false(playlist_remove(__test_pl_favorites(), track_get(0)));
|
||||
g_assert_true( playlist_remove(__test_pl_queued(), track_get(0)));
|
||||
|
@ -487,6 +484,26 @@ static void test_remove()
|
|||
g_assert_cmpuint(playlist_size(__test_pl_collection()), ==, 2);
|
||||
g_assert_true (playlist_has(__test_pl_hidden(), track_get(0)));
|
||||
g_assert_false(playlist_has(__test_pl_collection(), track_get(0)));
|
||||
g_assert_true(playlist_remove(__test_pl_hidden(), track_get(0)));
|
||||
|
||||
g_assert_true(playlist_select(__test_pl_least_played()));
|
||||
for (i = 0; i < SYS_PL_NUM_PLAYLISTS; i++) {
|
||||
playlist = playlist_get(PL_SYSTEM, i);
|
||||
|
||||
switch (i) {
|
||||
case SYS_PL_FAVORITES:
|
||||
case SYS_PL_HIDDEN:
|
||||
case SYS_PL_QUEUED:
|
||||
case SYS_PL_HISTORY:
|
||||
g_assert_false(playlist_select(playlist));
|
||||
g_assert(playlist_cur() != playlist);
|
||||
break;
|
||||
default:
|
||||
g_assert_true( playlist_select(playlist));
|
||||
g_assert_false(playlist_select(playlist));
|
||||
g_assert(playlist_cur() == playlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test_delete()
|
||||
|
|
|
@ -30,10 +30,9 @@ void test_user()
|
|||
g_assert_cmpuint(playlist_get_id(PL_USER, "No Playlist"), ==,
|
||||
(unsigned int)-1);
|
||||
|
||||
g_assert(playlist_cur() != playlist_lookup(PL_USER, "Test Playlist"));
|
||||
g_assert_true( playlist_select(PL_USER, "Test Playlist"));
|
||||
g_assert(playlist_cur() == playlist_lookup(PL_USER, "Test Playlist"));
|
||||
g_assert_false(playlist_select(PL_USER, "No Playlist"));
|
||||
g_assert(playlist_cur() != playlist);
|
||||
g_assert_false(playlist_select(playlist));
|
||||
g_assert(playlist_cur() != playlist);
|
||||
|
||||
g_assert_cmpuint(playlist_size(playlist), ==, 0);
|
||||
g_assert_false(playlist_has(playlist, track_get(0)));
|
||||
|
@ -42,6 +41,11 @@ void test_user()
|
|||
g_assert_true( playlist_has(playlist, track_get(0)));
|
||||
g_assert_cmpuint(playlist_size(playlist), ==, 1);
|
||||
|
||||
g_assert_true(playlist_select(playlist));
|
||||
g_assert(playlist_cur() == playlist);
|
||||
g_assert_false(playlist_select(playlist));
|
||||
g_assert_false(playlist_select(NULL));
|
||||
|
||||
playlist_update(PL_USER, "Test Playlist");
|
||||
pl_user_deinit();
|
||||
g_assert_cmpuint(db->db_size, ==, 0);
|
||||
|
|
|
@ -124,7 +124,7 @@ static void test_sidebar_selection()
|
|||
g_assert_cmpuint(gtk_tree_model_iter_n_children(filter, NULL), ==, 8);
|
||||
|
||||
playlist_set_random(collection, true);
|
||||
g_assert_true(playlist_select(PL_SYSTEM, "Favorites"));
|
||||
g_assert_true(playlist_select(playlist_lookup(PL_SYSTEM, "Favorites")));
|
||||
g_assert(playlist_cur() == playlist_lookup(PL_SYSTEM, "Favorites"));
|
||||
|
||||
g_assert_true(gui_sidebar_iter_first(&iter));
|
||||
|
|
Loading…
Reference in New Issue