ocarina/gui/collection.cpp

66 lines
1.5 KiB
C++
Raw Normal View History

/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/library.h>
#include <core/playlist.h>
#include <gui/tabs.h>
#include <gui/queue/label.h>
#include <gui/queue/window.h>
class CollectionTab : public Tab {
private:
CollectionLabel *collection_label;
QueueWindow *collection_window;
public:
CollectionTab() : Tab(library::get_queue())
{
tab_builder->add_from_file(gui :: share_file("QueueWindow.ui"));
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
tab_builder->get_widget_derived("CollectionLabel", collection_label);
tab_builder->get_widget_derived("QueueWindow", collection_window);
tab_toolbar->init(tab_pq, collection_label, collection_window, T_RANDOM);
collection_window->init(tab_pq);
tab_vbox.pack_start(*collection_window, true, true);
tab_model = collection_window->q_model;
tab_filter = collection_window->q_filter;
tab_size = collection_label->collection_size;
tab_treeview = collection_window->q_treeview;
tab_finish_init();
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(tab_vbox, *collection_label, 0);
}
~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++)
playlist :: add(tags :: get_track(ids[i]), "Banned");
return true;
}
};
static CollectionTab *collection_tab;
void init_collection_tab()
{
collection_tab = new CollectionTab;
}