ocarina/gui/tabs.cpp

62 lines
1.0 KiB
C++
Raw Normal View History

/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <deck.h>
#include <ocarina.h>
#include <playqueue.h>
#include <map>
#include <string>
/*
* Tab class definition
*/
class OcarinaTab {
private:
Playqueue *queue;
Gtk::Label tab_label;
Gtk::VBox tab_box;
public:
OcarinaTab(const std::string &, Playqueue *);
~OcarinaTab();
};
static std::map<Playqueue *, OcarinaTab *> tab_map;
OcarinaTab::OcarinaTab(const std::string &text, Playqueue *pq)
: queue(pq), tab_label(text)
{
Gtk::Notebook *notebook;
tab_label.set_visible();
tab_box.set_visible();
get_builder()->get_widget("o_notebook", notebook);
notebook->prepend_page(tab_box, tab_label);
tab_map[pq] = this;
};
OcarinaTab::~OcarinaTab()
{
tab_map.erase(queue);
}
/*
* Do stuff with tabs
*/
void setup_library_tab()
{
/*OcarinaTab *ot =*/ new OcarinaTab("Library", deck::get_library_pq());
}
void cleanup_tabs()
{
std::map<Playqueue *, OcarinaTab *>::iterator it;
for (it = tab_map.begin(); it != tab_map.end(); it++)
delete it->second;
}