2014-02-17 16:08:14 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
2015-12-10 13:59:21 -05:00
|
|
|
extern "C" {
|
2015-12-17 10:32:01 -05:00
|
|
|
#include <core/audio.h>
|
2015-12-11 09:21:10 -05:00
|
|
|
#include <core/collection.h>
|
2014-06-05 10:19:22 -04:00
|
|
|
#include <core/playlist.h>
|
2015-12-24 09:35:36 -05:00
|
|
|
#include <gui/builder.h>
|
2016-01-04 09:56:37 -05:00
|
|
|
#include <gui/playlist.h>
|
2016-01-13 09:37:05 -05:00
|
|
|
#include <gui/queue.h>
|
2015-12-10 13:59:21 -05:00
|
|
|
}
|
2014-06-04 13:59:15 -04:00
|
|
|
#include <gui/tabs.h>
|
2015-04-14 08:45:32 -04:00
|
|
|
#include <gui/queue/label.h>
|
2014-02-17 16:08:14 -05:00
|
|
|
|
|
|
|
|
2015-01-17 11:14:46 -05:00
|
|
|
static class PlaylistTab : public Tab {
|
2015-04-14 08:45:32 -04:00
|
|
|
private:
|
|
|
|
PlaylistLabel *playlist_label;
|
|
|
|
|
2014-02-21 22:06:42 -05:00
|
|
|
public:
|
2015-12-09 10:38:57 -05:00
|
|
|
PlaylistTab() : Tab(playlist_get_queue())
|
2015-01-15 08:32:44 -05:00
|
|
|
{
|
2015-04-19 09:24:25 -04:00
|
|
|
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
|
|
|
|
tab_builder->get_widget_derived("PlaylistLabel", playlist_label);
|
2015-04-17 20:17:24 -04:00
|
|
|
|
2015-04-19 12:13:32 -04:00
|
|
|
playlist_label->init(tab_pq);
|
|
|
|
tab_label = playlist_label;
|
2015-04-14 08:45:32 -04:00
|
|
|
|
2016-01-04 09:56:37 -05:00
|
|
|
tab_vbox.pack_start(*tab_window, true, true);
|
2015-04-14 08:45:32 -04:00
|
|
|
|
2015-12-24 09:35:36 -05:00
|
|
|
Glib :: wrap(GTK_NOTEBOOK(gui_builder_widget("o_notebook")),
|
|
|
|
false)->insert_page(tab_vbox, *playlist_label, 0);
|
2015-01-15 08:32:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
~PlaylistTab()
|
|
|
|
{
|
|
|
|
tab_unmap();
|
|
|
|
}
|
2015-01-17 11:14:46 -05:00
|
|
|
} *p_tab;
|
2015-01-15 09:06:59 -05:00
|
|
|
|
2014-02-28 20:07:59 -05:00
|
|
|
|
2014-02-17 16:08:14 -05:00
|
|
|
|
2016-01-12 08:02:28 -05:00
|
|
|
static void *playlist_init(struct queue *queue)
|
|
|
|
{
|
2016-01-14 08:00:04 -05:00
|
|
|
return gui_queue_alloc(queue, "Playlist", 0);
|
2016-01-13 08:18:03 -05:00
|
|
|
}
|
|
|
|
|
2015-11-29 19:45:39 -05:00
|
|
|
static void playlist_added(struct queue *queue, unsigned int pos)
|
|
|
|
{
|
|
|
|
if (p_tab)
|
|
|
|
p_tab->on_track_added(pos);
|
2016-01-18 09:11:30 -05:00
|
|
|
gui_queue_added(queue, pos);
|
2015-11-29 19:45:39 -05:00
|
|
|
}
|
2015-01-17 11:14:46 -05:00
|
|
|
|
2016-01-22 08:11:09 -05:00
|
|
|
static bool playlist_erase(struct queue *queue, struct track *track)
|
|
|
|
{
|
2016-01-21 08:13:14 -05:00
|
|
|
/* collection_unban() and playlist_remove() handle queue changes */
|
|
|
|
if (gui_playlist_cur() == PL_HIDDEN)
|
|
|
|
collection_unban(track);
|
|
|
|
else
|
|
|
|
playlist_remove(gui_playlist_cur(), track);
|
2016-01-22 08:11:09 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-11-29 20:01:12 -05:00
|
|
|
static void playlist_removed(struct queue *queue, unsigned int pos)
|
|
|
|
{
|
|
|
|
p_tab->on_track_removed(pos);
|
2016-01-18 09:11:30 -05:00
|
|
|
gui_queue_removed(queue, pos);
|
2015-11-29 20:01:12 -05:00
|
|
|
}
|
|
|
|
|
2015-11-29 19:45:39 -05:00
|
|
|
struct queue_ops playlist_ops = {
|
2016-01-12 08:02:28 -05:00
|
|
|
playlist_init,
|
2016-01-13 09:37:05 -05:00
|
|
|
gui_queue_free,
|
2015-11-29 19:45:39 -05:00
|
|
|
playlist_added,
|
2016-01-22 08:11:09 -05:00
|
|
|
playlist_erase,
|
2015-11-29 20:01:12 -05:00
|
|
|
playlist_removed,
|
2016-01-20 16:49:37 -05:00
|
|
|
gui_queue_cleared,
|
2015-11-29 19:45:39 -05:00
|
|
|
NULL,
|
2016-01-20 16:49:37 -05:00
|
|
|
gui_queue_updated,
|
2015-11-29 19:45:39 -05:00
|
|
|
};
|
2015-01-17 11:14:46 -05:00
|
|
|
|
|
|
|
void plist :: init()
|
2014-07-27 11:52:28 -04:00
|
|
|
{
|
|
|
|
p_tab = new PlaylistTab;
|
|
|
|
}
|