gui: Add initial extra notebook tab

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-01-18 14:43:24 -05:00 committed by Anna Schumaker
parent f80203c5fe
commit 2724b90281
4 changed files with 71 additions and 0 deletions

61
gui/tabs.cpp Normal file
View File

@ -0,0 +1,61 @@
/*
* 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;
}

View File

@ -203,6 +203,7 @@ Gtk::Window *connect_wires()
builder->add_from_file("gui/ocarina6.glade");
builder->get_widget("o_window", window);
/* Collection manager */
cb->on_library_add = on_library_add;
cb->on_library_update = on_library_update;
@ -219,5 +220,9 @@ Gtk::Window *connect_wires()
connect_button("o_collection_update", on_collection_update);
connect_button("o_collection_import", on_collection_import);
/* Set up other tabs */
setup_library_tab();
return window;
}

View File

@ -6,6 +6,10 @@
#include <gtkmm.h>
/* tabs.cpp */
void setup_library_tab();
void cleanup_tabs();
/* wires.cpp */
Gtk::Window *connect_wires();
Gtk::Button *get_button(const std::string &);

View File

@ -121,5 +121,6 @@ int main(int argc, char **argv)
schedule_test(test_0);
Gtk::Main::run(*window);
cleanup_tabs();
return 0;
}