From 017da028276837f0e8e37e625aad39911dedce9d Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 18 May 2016 07:57:07 -0400 Subject: [PATCH] gui/playlist: Add Queued Tracks playlist Signed-off-by: Anna Schumaker --- gui/playlist.c | 9 ++++++++- tests/gui/playlist.c | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gui/playlist.c b/gui/playlist.c index b9870827..87608261 100644 --- a/gui/playlist.c +++ b/gui/playlist.c @@ -181,6 +181,8 @@ static void *__playlist_init(struct queue *queue, void *data) if (string_match(playlist->pl_name, "Collection")) flags = GQ_CAN_RANDOM; + if (string_match(playlist->pl_name, "Queued Tracks")) + flags = GQ_CAN_RANDOM | GQ_CAN_REPEAT; if (p_init_done && playlist->pl_type == PL_ARTIST) gui_playlist_add_artist(artist_find(playlist->pl_name)); return gui_queue_alloc(playlist, queue, playlist->pl_name, flags); @@ -203,7 +205,8 @@ static bool __playlist_erase(struct queue *queue, struct track *track) if (string_match(gui_playlist_cur(), "Collection")) playlist_add(PL_SYSTEM, "Hidden", track); else if (string_match(gui_playlist_cur(), "Favorites") || - string_match(gui_playlist_cur(), "Hidden")) + string_match(gui_playlist_cur(), "Hidden") || + string_match(gui_playlist_cur(), "Queued Tracks")) playlist_remove(PL_SYSTEM, gui_playlist_cur(), track); return false; } @@ -231,6 +234,10 @@ void gui_playlist_init() treeview = GTK_TREE_VIEW(gui_builder_widget("o_playlist_view")); selection = gtk_tree_view_get_selection(treeview); + gtk_tree_store_insert(p_store, &parent, NULL, -1); + __playlist_set(&parent, "Queued Tracks", "audio-x-generic", PL_SYSTEM); + __playlist_set_size(&parent, "Queued Tracks"); + gtk_tree_store_insert(p_store, &parent, NULL, -1); __playlist_set(&parent, "Collection", "media-optical", PL_SYSTEM); __playlist_set_size(&parent, "Collection"); diff --git a/tests/gui/playlist.c b/tests/gui/playlist.c index 96bbdc78..ee09d709 100644 --- a/tests/gui/playlist.c +++ b/tests/gui/playlist.c @@ -29,6 +29,12 @@ static void test_playlist_sidebar() path = gtk_tree_model_get_path(model, &iter); gtk_tree_selection_select_path(selection, path); g_assert_cmpuint(gtk_tree_selection_count_selected_rows(selection), ==, 1); + g_assert_cmpstr(gui_playlist_cur(), ==, "Queued Tracks"); + + gtk_tree_path_next(path); + gtk_tree_selection_select_path(selection, path); + g_assert_cmpuint(gtk_tree_selection_count_selected_rows(selection), ==, 1); + gtk_tree_selection_unselect_all(selection); g_assert_cmpstr(gui_playlist_cur(), ==, "Collection"); gtk_tree_path_next(path);