Readded the tab

This commit is contained in:
Pietro Gagliardi 2015-06-29 22:49:12 -04:00
parent 1860f6a731
commit c8a53277c3
2 changed files with 24 additions and 43 deletions

View File

@ -7,6 +7,15 @@ struct tab {
GtkWidget *widget;
GtkContainer *container;
GtkNotebook *notebook;
GArray *pages;
};
struct tabPage {
uiControl *holder;
GtkWidget *holderWidget;
uiControl *c;
int margined;
};
uiDefineControlType(uiTab, uiTypeTab, struct tab)
@ -22,14 +31,24 @@ static void tabAppend(uiTab *tt, const char *name, uiControl *child)
{
struct tab *t = (struct tab *) tt;
uiTabInsertAt(tt, name, PUT_CODE_HERE, child);
uiTabInsertAt(tt, name, t->pages->len, child);
}
static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
{
struct tab *t = (struct tab *) tt;
struct tabPage page;
PUT_CODE_HERE;
page.holder = newHolder();
page.c = child;
holderSetChild(page.holder, page.c);
page.holderWidget = GTK_WIDGET(uiControlHandle(page.holder));
gtk_container_add(t->container, page.holderWidget);
gtk_notebook_set_tab_label(t->container, page.holderWidget, name);
gtk_notebook_reorder_child(t->container, page.holderWidget, n);
g_array_insert_val(t->pages, n, page);
}
static void tabDelete(uiTab *tt, uintmax_t n)
@ -43,7 +62,7 @@ static uintmax_t tabNumPages(uiTab *tt)
{
struct tab *t = (struct tab *) tt;
return PUT_CODE_HERE;
return t->pages->len;
}
static int tabMargined(uiTab *tt, uintmax_t n)
@ -73,6 +92,8 @@ uiTab *uiNewTab(void)
gtk_notebook_set_scrollable(t->notebook, TRUE);
t->pages = g_array_new(FALSE, TRUE, sizeof (struct tabPage));
uiControl(t)->Handle = tabHandle;
uiTab(t)->Append = tabAppend;

View File

@ -44,38 +44,7 @@ static void tabShow(uiControl *c)
gtk_widget_show(t->widget);
}
#define tabCapGrow 32
static void tabAppendPage(uiTab *tt, const char *name, uiControl *child)
{
struct tab *t = (struct tab *) tt;
struct tabPage page;
page.bin = newBin();
uiBinSetMainControl(page.bin, child);
// and add it as a tab page
uiBinSetOSParent(page.bin, (uintptr_t) (t->container));
page.binWidget = GTK_WIDGET(uiControlHandle(uiControl(page.bin)));
gtk_notebook_set_tab_label_text(t->notebook, page.binWidget, name);
g_array_append_val(t->pages, page);
}
static void tabInsertPageBefore(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
{
struct tab *t = (struct tab *) tt;
struct tabPage page;
page.bin = newBin();
uiBinSetMainControl(page.bin, child);
// and add it as a tab page
uiBinSetOSParent(page.bin, (uintptr_t) (t->container));
page.binWidget = GTK_WIDGET(uiControlHandle(uiControl(page.bin)));
gtk_notebook_set_tab_label_text(t->notebook, page.binWidget, name);
gtk_notebook_reorder_child(t->notebook, page.binWidget, n);
g_array_insert_val(t->pages, n, page);
}
static void tabDeletePage(uiTab *tt, uintmax_t n)
{
@ -99,13 +68,6 @@ static void tabDeletePage(uiTab *tt, uintmax_t n)
g_array_remove_index(t->pages, n);
}
static uintmax_t tabNumPages(uiTab *tt)
{
struct tab *t = (struct tab *) tt;
return t->pages->len;
}
static int tabMargined(uiTab *tt, uintmax_t n)
{
struct tab *t = (struct tab *) tt;
@ -135,8 +97,6 @@ uiTab *uiNewTab(void)
t = uiNew(struct tab);
t->pages = g_array_new(FALSE, TRUE, sizeof (struct tabPage));
uiControl(t)->Show = tabShow;
uiTab(t)->AppendPage = tabAppendPage;