84 lines
1.3 KiB
C++
84 lines
1.3 KiB
C++
/*
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
#include <audio.h>
|
|
#include <ocarina.h>
|
|
|
|
static Glib::RefPtr<PlayqueueModel> model;
|
|
|
|
|
|
/*
|
|
* Basic helper functions
|
|
*/
|
|
static inline Playqueue *history_pq()
|
|
{
|
|
return audio::get_recent_pq();
|
|
}
|
|
|
|
static void set_queue_size()
|
|
{
|
|
Gtk::Label *label = get_widget<Gtk::Label>("o_history_size");
|
|
label->set_text(itoa(history_pq()->size()));
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
* Gtk signal functions
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
* Functions exposed through a TabFuncs structure
|
|
*/
|
|
|
|
static void history_init_late()
|
|
{
|
|
set_queue_size();
|
|
}
|
|
|
|
static void history_cleanup() {}
|
|
|
|
static bool history_has_queue(Playqueue *pq)
|
|
{
|
|
return pq == history_pq();
|
|
}
|
|
|
|
static void history_track_added(Playqueue *pq, unsigned int row)
|
|
{
|
|
model->on_row_inserted(row);
|
|
set_queue_size();
|
|
}
|
|
|
|
static void history_track_deleted(Playqueue *pq, unsigned int row)
|
|
{
|
|
model->on_row_deleted(row);
|
|
set_queue_size();
|
|
}
|
|
|
|
|
|
static struct TabFuncs history_funcs = {
|
|
.init_late = history_init_late,
|
|
.cleanup = history_cleanup,
|
|
|
|
.has_queue = history_has_queue,
|
|
.track_added = history_track_added,
|
|
.track_deleted = history_track_deleted,
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
* Basic tab setup
|
|
*/
|
|
|
|
struct TabFuncs *init_history_tab()
|
|
{
|
|
model = Glib::RefPtr<PlayqueueModel>(new PlayqueueModel(history_pq()));
|
|
get_widget<Gtk::TreeView>("o_history_treeview")->set_model(model);
|
|
|
|
return &history_funcs;
|
|
}
|