Fixed up unix/tab.c.
This commit is contained in:
parent
90be2feb7f
commit
f25e0fe4d7
23
unix/tab.c
23
unix/tab.c
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
struct tab {
|
struct tab {
|
||||||
uiTab t;
|
uiTab t;
|
||||||
|
GtkWidget *widget;
|
||||||
|
GtkContainer *container;
|
||||||
|
GtkNotebook *notebook;
|
||||||
uiParent **pages;
|
uiParent **pages;
|
||||||
uintmax_t len;
|
uintmax_t len;
|
||||||
uintmax_t cap;
|
uintmax_t cap;
|
||||||
|
@ -16,14 +19,11 @@ static void onDestroy(GtkWidget *widget, gpointer data)
|
||||||
uiFree(t);
|
uiFree(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TAB(t) GTK_NOTEBOOK(uiControlHandle(uiControl(t)))
|
|
||||||
|
|
||||||
#define tabCapGrow 32
|
#define tabCapGrow 32
|
||||||
|
|
||||||
static void addPage(uiTab *tt, const char *name, uiControl *child)
|
static void tabAddPage(uiTab *tt, const char *name, uiControl *child)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) tt;
|
struct tab *t = (struct tab *) tt;
|
||||||
GtkWidget *notebook;
|
|
||||||
uiParent *content;
|
uiParent *content;
|
||||||
|
|
||||||
if (t->len >= t->cap) {
|
if (t->len >= t->cap) {
|
||||||
|
@ -31,11 +31,10 @@ static void addPage(uiTab *tt, const char *name, uiControl *child)
|
||||||
t->pages = (uiParent **) uiRealloc(t->pages, t->cap * sizeof (uiParent *), "uiParent *[]");
|
t->pages = (uiParent **) uiRealloc(t->pages, t->cap * sizeof (uiParent *), "uiParent *[]");
|
||||||
}
|
}
|
||||||
|
|
||||||
notebook = GTK_WIDGET(TAB(t));
|
content = uiNewParent((uintptr_t) (t->container));
|
||||||
content = uiNewParent((uintptr_t) notebook);
|
|
||||||
uiParentSetChild(content, child);
|
uiParentSetChild(content, child);
|
||||||
uiParentUpdate(content);
|
uiParentUpdate(content);
|
||||||
gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), GTK_WIDGET(uiParentHandle(content)), name);
|
gtk_notebook_set_tab_label_text(t->notebook, GTK_WIDGET(uiParentHandle(content)), name);
|
||||||
|
|
||||||
t->pages[t->len] = content;
|
t->pages[t->len] = content;
|
||||||
t->len++;
|
t->len++;
|
||||||
|
@ -44,7 +43,6 @@ static void addPage(uiTab *tt, const char *name, uiControl *child)
|
||||||
uiTab *uiNewTab(void)
|
uiTab *uiNewTab(void)
|
||||||
{
|
{
|
||||||
struct tab *t;
|
struct tab *t;
|
||||||
GtkWidget *widget;
|
|
||||||
|
|
||||||
t = uiNew(struct tab);
|
t = uiNew(struct tab);
|
||||||
|
|
||||||
|
@ -52,10 +50,13 @@ uiTab *uiNewTab(void)
|
||||||
FALSE, FALSE,
|
FALSE, FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
widget = GTK_WIDGET(TAB(t));
|
t->widget = WIDGET(t);
|
||||||
g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), t);
|
t->container = GTK_CONTAINER(t->widget);
|
||||||
|
t->notebook = GTK_NOTEBOOK(t->widget);
|
||||||
|
|
||||||
uiTab(t)->AddPage = addPage;
|
g_signal_connect(t->widget, "destroy", G_CALLBACK(onDestroy), t);
|
||||||
|
|
||||||
|
uiTab(t)->AddPage = tabAddPage;
|
||||||
|
|
||||||
return uiTab(t);
|
return uiTab(t);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue