59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
|
|
#include <ocarina/gtk.h>
|
|
#include <ocarina/page.h>
|
|
#include <ocarina/footer.h>
|
|
#include <libsaria/print.h>
|
|
|
|
#include <vector>
|
|
using namespace std;
|
|
|
|
static GtkWidget *tabs = NULL;
|
|
static vector<Page> pages;
|
|
|
|
static int cur_page()
|
|
{
|
|
return gtk_notebook_get_current_page(GTK_NOTEBOOK(tabs));
|
|
}
|
|
|
|
static void switch_page(GtkWidget *notebook, GtkWidget *page, int pagenum)
|
|
{
|
|
GtkWidget *footer = get_footer();
|
|
int cur = cur_page();
|
|
if (cur != -1)
|
|
pages[cur].remove_footer(footer);
|
|
if (pagenum != -1)
|
|
pages[pagenum].add_footer(footer);
|
|
if (footer != NULL)
|
|
put_footer();
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
GtkWidget *get_tabs()
|
|
{
|
|
if (tabs == NULL)
|
|
make_tabs();
|
|
return tabs;
|
|
}
|
|
|
|
void add_page(GtkWidget *label, GtkWidget *content, bool fill)
|
|
{
|
|
Page page(content);
|
|
pages.push_back(page);
|
|
|
|
gtk_notebook_append_page(GTK_NOTEBOOK(tabs), page.get_page(), label);
|
|
if (fill == true) {
|
|
gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(tabs),
|
|
page.get_page(),
|
|
TRUE,
|
|
TRUE,
|
|
GTK_PACK_START);
|
|
}
|
|
};
|