2014-02-17 15:32:47 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
2015-12-07 09:35:58 -05:00
|
|
|
extern "C" {
|
|
|
|
#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-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-11 16:24:01 -04:00
|
|
|
#include <gui/queue/label.h>
|
2014-02-17 15:32:47 -05:00
|
|
|
|
|
|
|
|
2014-02-21 22:06:42 -05:00
|
|
|
class CollectionTab : public Tab {
|
2015-04-11 16:24:01 -04:00
|
|
|
private:
|
|
|
|
CollectionLabel *collection_label;
|
|
|
|
|
2014-02-21 22:06:42 -05:00
|
|
|
public:
|
2015-12-05 12:12:01 -05:00
|
|
|
CollectionTab() : Tab(collection_get_queue())
|
2015-04-12 10:03:54 -04:00
|
|
|
{
|
2015-04-19 09:24:25 -04:00
|
|
|
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
|
|
|
|
tab_builder->get_widget_derived("CollectionLabel", collection_label);
|
2015-04-19 09:52:27 -04:00
|
|
|
tab_toolbar->init(tab_pq, collection_label, tab_window, T_RANDOM);
|
2015-04-11 16:24:01 -04:00
|
|
|
|
2015-04-19 12:13:32 -04:00
|
|
|
collection_label->init(tab_pq);
|
|
|
|
tab_label = collection_label;
|
2015-04-11 16:24:01 -04:00
|
|
|
|
2015-04-19 12:13:32 -04:00
|
|
|
tab_vbox.pack_start(*tab_window, true, true);
|
2015-12-24 09:35:36 -05:00
|
|
|
|
|
|
|
Glib::wrap(GTK_NOTEBOOK(gui_builder_widget("o_notebook")),
|
|
|
|
false)->insert_page(tab_vbox, *collection_label, 0);
|
2015-04-12 10:03:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
~CollectionTab()
|
|
|
|
{
|
|
|
|
tab_unmap();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool on_key_press_event(const std::string &key)
|
|
|
|
{
|
|
|
|
std::vector<unsigned int> ids;
|
|
|
|
|
|
|
|
if (key != "Delete")
|
|
|
|
return Tab :: on_key_press_event(key);
|
|
|
|
|
|
|
|
tab_selected_ids(ids);
|
|
|
|
for (unsigned int i = 0; i < ids.size(); i++)
|
2015-12-11 09:21:10 -05:00
|
|
|
collection_ban(track_get(ids[i]));
|
2015-04-12 10:03:54 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2014-02-21 22:06:42 -05:00
|
|
|
};
|
2014-02-17 15:32:47 -05:00
|
|
|
|
|
|
|
|
2014-02-21 22:06:42 -05:00
|
|
|
static CollectionTab *collection_tab;
|
2014-02-17 15:32:47 -05:00
|
|
|
|
2016-01-12 08:02:28 -05:00
|
|
|
static void *collection_init(struct queue *queue)
|
|
|
|
{
|
2016-01-13 09:37:05 -05:00
|
|
|
return gui_queue_alloc(queue, "Collection");
|
2016-01-13 08:18:03 -05:00
|
|
|
}
|
|
|
|
|
2015-11-29 19:45:39 -05:00
|
|
|
static void collection_added(struct queue *queue, unsigned int pos)
|
|
|
|
{
|
|
|
|
if (collection_tab)
|
|
|
|
collection_tab->on_track_added(pos);
|
|
|
|
}
|
|
|
|
|
2015-11-29 20:01:12 -05:00
|
|
|
static void collection_removed(struct queue *queue, unsigned int pos)
|
|
|
|
{
|
2015-12-07 10:19:12 -05:00
|
|
|
if (collection_tab)
|
|
|
|
collection_tab->on_track_removed(pos);
|
2015-11-29 20:01:12 -05:00
|
|
|
}
|
|
|
|
|
2016-01-29 10:12:09 -05:00
|
|
|
static void collection_cleared(struct queue *queue, unsigned int n)
|
|
|
|
{
|
|
|
|
if (collection_tab)
|
|
|
|
collection_tab->on_tracks_cleared(n);
|
|
|
|
}
|
|
|
|
|
2015-11-29 20:10:15 -05:00
|
|
|
static void collection_updated(struct queue *queue, unsigned int pos)
|
|
|
|
{
|
|
|
|
if (collection_tab)
|
|
|
|
collection_tab->on_track_updated(pos);
|
|
|
|
}
|
|
|
|
|
2015-11-24 08:18:31 -05:00
|
|
|
struct queue_ops collection_ops = {
|
2016-01-12 08:02:28 -05:00
|
|
|
collection_init,
|
2016-01-13 09:37:05 -05:00
|
|
|
gui_queue_free,
|
2015-11-29 19:45:39 -05:00
|
|
|
collection_added,
|
2015-11-29 20:01:12 -05:00
|
|
|
collection_removed,
|
2016-01-29 10:12:09 -05:00
|
|
|
collection_cleared,
|
2015-12-05 13:24:26 -05:00
|
|
|
collection_save,
|
2015-11-29 20:10:15 -05:00
|
|
|
collection_updated,
|
2015-11-24 08:18:31 -05:00
|
|
|
};
|
|
|
|
|
2014-02-20 19:49:33 -05:00
|
|
|
void init_collection_tab()
|
2014-02-17 15:32:47 -05:00
|
|
|
{
|
2014-02-21 22:06:42 -05:00
|
|
|
collection_tab = new CollectionTab;
|
2014-02-17 15:32:47 -05:00
|
|
|
}
|