diff --git a/include/ocarina/page.h b/include/ocarina/page.h index fc2621bf..d3886b6b 100644 --- a/include/ocarina/page.h +++ b/include/ocarina/page.h @@ -8,10 +8,15 @@ class Page private: GtkWidget *table; void add_content(GtkWidget *); + void add_footer(GtkWidget *); public: Page(GtkWidget *); ~Page(); + + GtkWidget *get_page(); + void hide(); + void show(); }; #endif /* OCARINA_PAGE_H */ diff --git a/ocarina/body/page.cpp b/ocarina/body/page.cpp index aa83466a..add984f1 100644 --- a/ocarina/body/page.cpp +++ b/ocarina/body/page.cpp @@ -1,10 +1,17 @@ #include +#include + +#include + +GtkAttachOptions GROW; +GtkAttachOptions SHRINK; Page::Page(GtkWidget *content) { table = gtk_table_new(3, 1, FALSE); add_content(content); + gtk_widget_show(table); } Page::~Page() @@ -13,5 +20,23 @@ Page::~Page() void Page::add_content(GtkWidget *content) { - gtk_table_attach_defaults(GTK_TABLE(table), content, 0, 1, 1, 2); + gtk_table_attach_defaults(GTK_TABLE(table), content, 0, 1, 0, 1); +} + +void Page::add_footer(GtkWidget *footer) +{ + gtk_table_attach(GTK_TABLE(table), footer, 0, 1, 2, 3, GROW, SHRINK, 0, 0); +} + +GtkWidget *Page::get_page() +{ + return table; +} + +void Page::hide() +{ +} + +void Page::show() +{ } diff --git a/ocarina/body/tabs.cpp b/ocarina/body/tabs.cpp index 45124c11..6afefc74 100644 --- a/ocarina/body/tabs.cpp +++ b/ocarina/body/tabs.cpp @@ -1,11 +1,32 @@ #include +#include +#include + +#include +using namespace std; static GtkWidget *tabs = NULL; +static vector pages; + +static int cur_page() +{ + return gtk_notebook_get_current_page(GTK_NOTEBOOK(tabs)); +} + +static void switch_page(GtkWidget *notebook, GtkWidget *page, int pagenum) +{ + int cur = cur_page(); + if (cur != -1) + pages[cur].hide(); + if (pagenum != -1) + pages[pagenum].show(); +} static void make_tabs() { tabs = gtk_notebook_new(); + GTK_CONNECT(tabs, "switch-page", switch_page, NULL); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tabs), GTK_POS_LEFT); gtk_widget_show(tabs); } @@ -19,12 +40,14 @@ GtkWidget *get_tabs() void add_page(GtkWidget *label, GtkWidget *content, bool fill) { - gtk_notebook_append_page(GTK_NOTEBOOK(tabs), content, label); + Page page(content); + gtk_notebook_append_page(GTK_NOTEBOOK(tabs), page.get_page(), label); if (fill == true) { gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(tabs), - content, + page.get_page(), TRUE, TRUE, GTK_PACK_START); } + pages.push_back(page); };