ocarina/gui/collection_tab.cpp
Anna Schumaker c9eb9d724b gui/view: Add keypress events
- Press "f" to add tracks to the Favorites playlist
- Press "q" to create a new temporary queue
- Press "r" to create a new temporary queue with Q_RANDOM set
- Press 0 .. 9 to add tracks to a temporary queue
- Delete to remove tracks from a queue

I also removed the corresponding keypress events from the C++ code to
make progress easier to track.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-05-27 12:01:43 -04:00

81 lines
1.6 KiB
C++

/*
* Copyright 2014 (c) Anna Schumaker.
*/
extern "C" {
#include <core/collection.h>
#include <core/playlist.h>
#include <gui/builder.h>
#include <gui/queue.h>
}
#include <gui/tabs.h>
#include <gui/queue/label.h>
class CollectionTab : public Tab {
private:
CollectionLabel *collection_label;
public:
CollectionTab() : Tab(collection_get_queue())
{
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
tab_builder->get_widget_derived("CollectionLabel", collection_label);
collection_label->init(tab_pq);
tab_label = collection_label;
tab_vbox.pack_start(*tab_window, true, true);
Glib::wrap(GTK_NOTEBOOK(gui_builder_widget("o_notebook")),
false)->insert_page(tab_vbox, *collection_label, 0);
}
~CollectionTab()
{
tab_unmap();
}
};
static CollectionTab *collection_tab;
static void *collection_init(struct queue *queue)
{
return gui_queue_alloc(queue, "Collection", GQ_CAN_RANDOM);
}
static void collection_added(struct queue *queue, unsigned int pos)
{
if (collection_tab)
collection_tab->on_track_added(pos);
gui_queue_added(queue, pos);
}
static bool collection_erase(struct queue *queue, struct track *track)
{
return playlist_add(PL_HIDDEN, track);
}
static void collection_removed(struct queue *queue, unsigned int pos)
{
if (collection_tab)
collection_tab->on_track_removed(pos);
gui_queue_removed(queue, pos);
}
struct queue_ops collection_ops = {
collection_init,
gui_queue_free,
collection_added,
collection_erase,
collection_removed,
gui_queue_cleared,
collection_save,
gui_queue_updated,
};
void init_collection_tab()
{
collection_tab = new CollectionTab;
}