From 2724b9028111ceff15626b1b4a99b5b864df8f0a Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sat, 18 Jan 2014 14:43:24 -0500 Subject: [PATCH] gui: Add initial extra notebook tab Signed-off-by: Anna Schumaker --- gui/tabs.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++ gui/wires.cpp | 5 ++++ include/ocarina.h | 4 ++++ tests/gui/gui.cpp | 1 + 4 files changed, 71 insertions(+) create mode 100644 gui/tabs.cpp diff --git a/gui/tabs.cpp b/gui/tabs.cpp new file mode 100644 index 00000000..ca209a75 --- /dev/null +++ b/gui/tabs.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2014 (c) Anna Schumaker. + */ +#include +#include +#include + +#include +#include + + +/* + * 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 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::iterator it; + for (it = tab_map.begin(); it != tab_map.end(); it++) + delete it->second; +} diff --git a/gui/wires.cpp b/gui/wires.cpp index 51f34c18..e684a205 100644 --- a/gui/wires.cpp +++ b/gui/wires.cpp @@ -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; } diff --git a/include/ocarina.h b/include/ocarina.h index a291fb5c..50e59bca 100644 --- a/include/ocarina.h +++ b/include/ocarina.h @@ -6,6 +6,10 @@ #include +/* tabs.cpp */ +void setup_library_tab(); +void cleanup_tabs(); + /* wires.cpp */ Gtk::Window *connect_wires(); Gtk::Button *get_button(const std::string &); diff --git a/tests/gui/gui.cpp b/tests/gui/gui.cpp index 9ca73862..89b971d4 100644 --- a/tests/gui/gui.cpp +++ b/tests/gui/gui.cpp @@ -121,5 +121,6 @@ int main(int argc, char **argv) schedule_test(test_0); Gtk::Main::run(*window); + cleanup_tabs(); return 0; }