2015-06-11 18:07:06 -05:00
|
|
|
// 11 june 2015
|
|
|
|
#include "uipriv_unix.h"
|
|
|
|
|
|
|
|
struct tab {
|
|
|
|
uiTab t;
|
2015-06-26 20:52:42 -05:00
|
|
|
|
2015-06-11 18:07:06 -05:00
|
|
|
GtkWidget *widget;
|
2015-06-26 20:52:42 -05:00
|
|
|
GtkContainer *container;
|
|
|
|
GtkNotebook *notebook;
|
2015-06-29 21:49:12 -05:00
|
|
|
|
|
|
|
GArray *pages;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tabPage {
|
|
|
|
uiControl *c;
|
2015-06-30 00:16:35 -05:00
|
|
|
GtkWidget *widget;
|
2015-06-29 21:49:12 -05:00
|
|
|
int margined;
|
2015-06-11 18:07:06 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
uiDefineControlType(uiTab, uiTypeTab, struct tab)
|
|
|
|
|
|
|
|
static uintptr_t tabHandle(uiControl *c)
|
|
|
|
{
|
|
|
|
struct tab *t = (struct tab *) c;
|
|
|
|
|
|
|
|
return (uintptr_t) (t->widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tabAppend(uiTab *tt, const char *name, uiControl *child)
|
|
|
|
{
|
|
|
|
struct tab *t = (struct tab *) tt;
|
|
|
|
|
2015-06-29 21:49:12 -05:00
|
|
|
uiTabInsertAt(tt, name, t->pages->len, child);
|
2015-06-11 18:07:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
|
|
|
|
{
|
|
|
|
struct tab *t = (struct tab *) tt;
|
2015-06-29 21:49:12 -05:00
|
|
|
struct tabPage page;
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-06-29 21:49:12 -05:00
|
|
|
page.c = child;
|
2015-06-30 00:16:35 -05:00
|
|
|
page.widget = GTK_WIDGET(uiControlHandle(page.c));
|
2015-06-29 21:49:12 -05:00
|
|
|
|
2015-06-30 00:16:35 -05:00
|
|
|
uiControlSetParent(page.c, uiControl(t));
|
|
|
|
gtk_notebook_set_tab_label_text(t->notebook, page.widget, name);
|
|
|
|
gtk_notebook_reorder_child(t->notebook, page.widget, n);
|
2015-06-29 21:49:12 -05:00
|
|
|
|
|
|
|
g_array_insert_val(t->pages, n, page);
|
2015-06-11 18:07:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void tabDelete(uiTab *tt, uintmax_t n)
|
|
|
|
{
|
|
|
|
struct tab *t = (struct tab *) tt;
|
|
|
|
|
|
|
|
PUT_CODE_HERE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uintmax_t tabNumPages(uiTab *tt)
|
|
|
|
{
|
|
|
|
struct tab *t = (struct tab *) tt;
|
|
|
|
|
2015-06-29 21:49:12 -05:00
|
|
|
return t->pages->len;
|
2015-06-11 18:07:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static int tabMargined(uiTab *tt, uintmax_t n)
|
|
|
|
{
|
|
|
|
struct tab *t = (struct tab *) tt;
|
|
|
|
|
|
|
|
return PUT_CODE_HERE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tabSetMargined(uiTab *tt, uintmax_t n, int margined)
|
|
|
|
{
|
|
|
|
struct tab *t = (struct tab *) tt;
|
|
|
|
|
|
|
|
PUT_CODE_HERE;
|
|
|
|
}
|
|
|
|
|
|
|
|
uiTab *uiNewTab(void)
|
|
|
|
{
|
|
|
|
struct tab *t;
|
|
|
|
|
2015-06-14 19:02:38 -05:00
|
|
|
t = (struct tab *) uiNewControl(uiTypeTab());
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-06-26 20:52:42 -05:00
|
|
|
t->widget = gtk_notebook_new();
|
|
|
|
t->container = GTK_CONTAINER(t->widget);
|
|
|
|
t->notebook = GTK_NOTEBOOK(t->widget);
|
|
|
|
uiUnixMakeSingleWidgetControl(uiControl(t), t->widget);
|
|
|
|
|
|
|
|
gtk_notebook_set_scrollable(t->notebook, TRUE);
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-06-29 21:49:12 -05:00
|
|
|
t->pages = g_array_new(FALSE, TRUE, sizeof (struct tabPage));
|
|
|
|
|
2015-06-11 18:07:06 -05:00
|
|
|
uiControl(t)->Handle = tabHandle;
|
|
|
|
|
|
|
|
uiTab(t)->Append = tabAppend;
|
|
|
|
uiTab(t)->InsertAt = tabInsertAt;
|
|
|
|
uiTab(t)->Delete = tabDelete;
|
|
|
|
uiTab(t)->NumPages = tabNumPages;
|
|
|
|
uiTab(t)->Margined = tabMargined;
|
|
|
|
uiTab(t)->SetMargined = tabSetMargined;
|
|
|
|
|
|
|
|
return uiTab(t);
|
|
|
|
}
|