86 lines
1.7 KiB
C++
86 lines
1.7 KiB
C++
/*
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
extern "C" {
|
|
#include <core/audio.h>
|
|
#include <core/collection.h>
|
|
#include <core/playlist.h>
|
|
#include <gui/builder.h>
|
|
#include <gui/playlist.h>
|
|
#include <gui/queue.h>
|
|
}
|
|
#include <gui/tabs.h>
|
|
#include <gui/queue/label.h>
|
|
|
|
|
|
static class PlaylistTab : public Tab {
|
|
private:
|
|
PlaylistLabel *playlist_label;
|
|
|
|
public:
|
|
PlaylistTab() : Tab(playlist_get_queue())
|
|
{
|
|
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
|
|
tab_builder->get_widget_derived("PlaylistLabel", playlist_label);
|
|
|
|
playlist_label->init(tab_pq);
|
|
tab_label = playlist_label;
|
|
|
|
tab_vbox.pack_start(*tab_window, true, true);
|
|
|
|
Glib :: wrap(GTK_NOTEBOOK(gui_builder_widget("o_notebook")),
|
|
false)->insert_page(tab_vbox, *playlist_label, 0);
|
|
}
|
|
|
|
~PlaylistTab()
|
|
{
|
|
tab_unmap();
|
|
}
|
|
} *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;
|
|
}
|