88 lines
1.4 KiB
C++
88 lines
1.4 KiB
C++
/*
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
#include <deck.h>
|
|
#include <ocarina.h>
|
|
#include <playqueue.h>
|
|
|
|
#include <map>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
class OcarinaTab;
|
|
static std::map<Playqueue *, OcarinaTab *> tab_map;
|
|
|
|
/*
|
|
* Tab class definition
|
|
*/
|
|
class OcarinaTab {
|
|
private:
|
|
Playqueue *queue;
|
|
|
|
/* Tab widgets */
|
|
Gtk::VBox tab_box;
|
|
Gtk::Label tab_name;
|
|
Gtk::Label tab_size;
|
|
|
|
Gtk::VBox tab_page;
|
|
|
|
void set_tab_size();
|
|
|
|
public:
|
|
OcarinaTab(const std::string &, Playqueue *);
|
|
~OcarinaTab();
|
|
};
|
|
|
|
|
|
OcarinaTab::OcarinaTab(const std::string &text, Playqueue *pq)
|
|
: queue(pq),
|
|
tab_name("<big>" + text + "</big>", 1, 0.5),
|
|
tab_size("0", 1, 0.5)
|
|
{
|
|
Gtk::Notebook *notebook;
|
|
get_builder()->get_widget("o_notebook", notebook);
|
|
|
|
/* Make tab label */
|
|
tab_name.set_use_markup();
|
|
tab_box.pack_start(tab_name);
|
|
tab_box.pack_start(tab_size);
|
|
tab_box.show_all();
|
|
set_tab_size();
|
|
|
|
|
|
|
|
tab_page.set_visible();
|
|
notebook->prepend_page(tab_page, tab_box);
|
|
|
|
tab_map[pq] = this;
|
|
};
|
|
|
|
OcarinaTab::~OcarinaTab()
|
|
{
|
|
tab_map.erase(queue);
|
|
}
|
|
|
|
void OcarinaTab::set_tab_size()
|
|
{
|
|
std::stringstream ss;
|
|
ss << queue->size();
|
|
tab_size.set_text(ss.str());
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
* Do stuff with tabs
|
|
*/
|
|
void init_tabs()
|
|
{
|
|
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;
|
|
}
|