diff --git a/gui/playlist.c b/gui/playlist.c index a9443a51..da3ef6aa 100644 --- a/gui/playlist.c +++ b/gui/playlist.c @@ -1,6 +1,7 @@ /* * Copyright 2016 (c) Anna Schumaker. */ +#include #include #include #include @@ -49,6 +50,21 @@ void __playlist_selection_changed(GtkTreeSelection *selection, gpointer data) } } +static void *__playlist_init(struct queue *queue) +{ + return gui_queue_alloc(queue, "Playlist", 0); +} + +static bool __playlist_erase(struct queue *queue, struct track *track) +{ + /* collection_unban() and playlist_remove() handle queue changes */ + if (gui_playlist_cur() == PL_HIDDEN) + collection_unban(track); + else + playlist_remove(gui_playlist_cur(), track); + return false; +} + void gui_playlist_init() { GtkTreeView *treeview; @@ -82,3 +98,13 @@ enum playlist_t gui_playlist_cur() { return p_cur; } + +struct queue_ops playlist_ops = { + .qop_init = __playlist_init, + .qop_deinit = gui_queue_free, + .qop_added = gui_queue_added, + .qop_erase = __playlist_erase, + .qop_removed = gui_queue_removed, + .qop_cleared = gui_queue_cleared, + .qop_updated = gui_queue_updated, +}; diff --git a/gui/playlist_tab.cpp b/gui/playlist_tab.cpp index c0ddd97e..6612c2a3 100644 --- a/gui/playlist_tab.cpp +++ b/gui/playlist_tab.cpp @@ -39,46 +39,6 @@ public: } *p_tab; - -static void *playlist_init(struct queue *queue) -{ - return gui_queue_alloc(queue, "Playlist", 0); -} - -static void playlist_added(struct queue *queue, unsigned int pos) -{ - if (p_tab) - p_tab->on_track_added(pos); - gui_queue_added(queue, pos); -} - -static bool playlist_erase(struct queue *queue, struct track *track) -{ - /* collection_unban() and playlist_remove() handle queue changes */ - if (gui_playlist_cur() == PL_HIDDEN) - collection_unban(track); - else - playlist_remove(gui_playlist_cur(), track); - return false; -} - -static void playlist_removed(struct queue *queue, unsigned int pos) -{ - p_tab->on_track_removed(pos); - gui_queue_removed(queue, pos); -} - -struct queue_ops playlist_ops = { - playlist_init, - gui_queue_free, - playlist_added, - playlist_erase, - playlist_removed, - gui_queue_cleared, - NULL, - gui_queue_updated, -}; - void plist :: init() { p_tab = new PlaylistTab; diff --git a/include/gui/ocarina.h b/include/gui/ocarina.h index 2b50565c..77619c72 100644 --- a/include/gui/ocarina.h +++ b/include/gui/ocarina.h @@ -16,7 +16,6 @@ namespace gui extern struct queue_ops collection_ops; extern struct queue_ops history_ops; -extern struct queue_ops playlist_ops; extern struct queue_ops tempq_ops; void on_pq_created(queue *, unsigned int); diff --git a/include/gui/playlist.h b/include/gui/playlist.h index 9f2ef994..e6693b2d 100644 --- a/include/gui/playlist.h +++ b/include/gui/playlist.h @@ -12,4 +12,7 @@ void gui_playlist_init(); /* Called to get the currently selected playlist. */ enum playlist_t gui_playlist_cur(); +/* Playlist operations passed to core_init() */ +extern struct queue_ops playlist_ops; + #endif /* OCARINA_GUI_PLAYLIST_H */