ocarina/gui/history.cpp

79 lines
1.4 KiB
C++

/*
* Copyright 2014 (c) Anna Schumaker.
*/
extern "C" {
#include <core/history.h>
#include <gui/builder.h>
#include <gui/queue.h>
}
#include <gui/tabs.h>
#include <gui/queue/label.h>
class HistoryTab : public Tab {
private:
HistoryLabel *history_label;
public:
HistoryTab() : Tab(history_get_queue())
{
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
tab_builder->get_widget_derived("HistoryLabel", history_label);
history_label->init(tab_pq);
tab_label = history_label;
tab_vbox.pack_start(*tab_window, true, true);
Glib :: wrap(GTK_NOTEBOOK(gui_builder_widget("o_notebook")),
false)->insert_page(tab_vbox, *history_label, 0);
}
~HistoryTab()
{
tab_unmap();
}
};
static HistoryTab *history_tab;
static void *history_init(struct queue *queue)
{
return gui_queue_alloc(queue, "History", 0);
}
static void history_added(struct queue *queue, unsigned int pos)
{
if (history_tab)
history_tab->on_track_added(pos);
gui_queue_added(queue, pos);
}
static bool history_erase(struct queue *queue, struct track *track)
{
return false;
}
static void history_removed(struct queue *queue, unsigned int pos)
{
history_tab->on_track_removed(pos);
gui_queue_removed(queue, pos);
}
struct queue_ops history_ops = {
history_init,
gui_queue_free,
history_added,
history_erase,
history_removed,
gui_queue_cleared,
NULL,
gui_queue_updated,
};
void init_history_tab()
{
history_tab = new HistoryTab;
}