Readded the tab
This commit is contained in:
parent
1860f6a731
commit
c8a53277c3
|
@ -7,6 +7,15 @@ struct tab {
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GtkContainer *container;
|
GtkContainer *container;
|
||||||
GtkNotebook *notebook;
|
GtkNotebook *notebook;
|
||||||
|
|
||||||
|
GArray *pages;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct tabPage {
|
||||||
|
uiControl *holder;
|
||||||
|
GtkWidget *holderWidget;
|
||||||
|
uiControl *c;
|
||||||
|
int margined;
|
||||||
};
|
};
|
||||||
|
|
||||||
uiDefineControlType(uiTab, uiTypeTab, struct tab)
|
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;
|
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)
|
static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) tt;
|
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)
|
static void tabDelete(uiTab *tt, uintmax_t n)
|
||||||
|
@ -43,7 +62,7 @@ static uintmax_t tabNumPages(uiTab *tt)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) tt;
|
struct tab *t = (struct tab *) tt;
|
||||||
|
|
||||||
return PUT_CODE_HERE;
|
return t->pages->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tabMargined(uiTab *tt, uintmax_t n)
|
static int tabMargined(uiTab *tt, uintmax_t n)
|
||||||
|
@ -73,6 +92,8 @@ uiTab *uiNewTab(void)
|
||||||
|
|
||||||
gtk_notebook_set_scrollable(t->notebook, TRUE);
|
gtk_notebook_set_scrollable(t->notebook, TRUE);
|
||||||
|
|
||||||
|
t->pages = g_array_new(FALSE, TRUE, sizeof (struct tabPage));
|
||||||
|
|
||||||
uiControl(t)->Handle = tabHandle;
|
uiControl(t)->Handle = tabHandle;
|
||||||
|
|
||||||
uiTab(t)->Append = tabAppend;
|
uiTab(t)->Append = tabAppend;
|
||||||
|
|
40
unix/tab.c
40
unix/tab.c
|
@ -44,38 +44,7 @@ static void tabShow(uiControl *c)
|
||||||
gtk_widget_show(t->widget);
|
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)
|
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);
|
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)
|
static int tabMargined(uiTab *tt, uintmax_t n)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) tt;
|
struct tab *t = (struct tab *) tt;
|
||||||
|
@ -135,8 +97,6 @@ uiTab *uiNewTab(void)
|
||||||
|
|
||||||
t = uiNew(struct tab);
|
t = uiNew(struct tab);
|
||||||
|
|
||||||
t->pages = g_array_new(FALSE, TRUE, sizeof (struct tabPage));
|
|
||||||
|
|
||||||
uiControl(t)->Show = tabShow;
|
uiControl(t)->Show = tabShow;
|
||||||
|
|
||||||
uiTab(t)->AppendPage = tabAppendPage;
|
uiTab(t)->AppendPage = tabAppendPage;
|
||||||
|
|
Loading…
Reference in New Issue