2014-02-17 15:47:19 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#include <audio.h>
|
2014-02-17 17:40:18 -05:00
|
|
|
#include <filter.h>
|
2014-02-17 15:47:19 -05:00
|
|
|
#include <ocarina.h>
|
2014-02-17 19:15:02 -05:00
|
|
|
#include <tabs.h>
|
2014-02-17 15:47:19 -05:00
|
|
|
|
2014-02-17 17:40:18 -05:00
|
|
|
#include <set>
|
|
|
|
|
|
|
|
static std::set<unsigned int> visible_ids;
|
|
|
|
static Glib::RefPtr<Gtk::TreeModelFilter> history_filter;
|
2014-02-17 15:47:19 -05:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-17 19:15:02 -05:00
|
|
|
static struct TabType history_funcs = {
|
2014-02-17 15:47:19 -05:00
|
|
|
.init_late = history_init_late,
|
|
|
|
.cleanup = history_cleanup,
|
|
|
|
|
|
|
|
.has_queue = history_has_queue,
|
|
|
|
.track_added = history_track_added,
|
|
|
|
.track_deleted = history_track_deleted,
|
|
|
|
};
|
|
|
|
|
2014-02-17 19:15:02 -05:00
|
|
|
static struct FilterDesc filter_desc;
|
|
|
|
|
2014-02-17 15:47:19 -05:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Basic tab setup
|
|
|
|
*/
|
|
|
|
|
2014-02-17 19:15:02 -05:00
|
|
|
struct TabType *init_history_tab()
|
2014-02-17 15:47:19 -05:00
|
|
|
{
|
|
|
|
model = Glib::RefPtr<PlayqueueModel>(new PlayqueueModel(history_pq()));
|
2014-02-17 17:40:18 -05:00
|
|
|
|
2014-02-17 19:15:02 -05:00
|
|
|
filter_desc.model = model;
|
|
|
|
filter_desc.entry = get_widget<Gtk::SearchEntry>("o_history_entry");
|
|
|
|
init_filter(&filter_desc);
|
2014-02-17 17:40:18 -05:00
|
|
|
|
2014-02-17 19:15:02 -05:00
|
|
|
get_widget<Gtk::TreeView>("o_history_treeview")->set_model(filter_desc.filter);
|
2014-02-17 15:47:19 -05:00
|
|
|
|
|
|
|
return &history_funcs;
|
|
|
|
}
|