gui/playlist: Move playlist_ops into playlist.c

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-01-21 09:42:37 -05:00
parent a1c6502226
commit 7995e381c0
4 changed files with 29 additions and 41 deletions

View File

@ -1,6 +1,7 @@
/*
* Copyright 2016 (c) Anna Schumaker.
*/
#include <core/collection.h>
#include <core/tempq.h>
#include <gui/builder.h>
#include <gui/playlist.h>
@ -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,
};

View File

@ -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;

View File

@ -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);

View File

@ -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 */