2015-06-11 18:07:06 -05:00
|
|
|
// 11 june 2015
|
|
|
|
#include "uipriv_unix.h"
|
|
|
|
|
2015-08-28 08:56:41 -05:00
|
|
|
struct uiTab {
|
|
|
|
uiUnixControl c;
|
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
|
|
|
|
2015-08-28 15:50:55 -05:00
|
|
|
GArray *pages; // []*struct child
|
2015-06-11 18:07:06 -05:00
|
|
|
};
|
|
|
|
|
2015-08-28 08:56:41 -05:00
|
|
|
static void onDestroy(uiTab *);
|
|
|
|
|
|
|
|
uiUnixDefineControlWithOnDestroy(
|
|
|
|
uiTab, // type name
|
|
|
|
onDestroy(this); // on destroy
|
|
|
|
)
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-08-28 08:56:41 -05:00
|
|
|
static void onDestroy(uiTab *t)
|
2015-07-01 00:02:34 -05:00
|
|
|
{
|
|
|
|
guint i;
|
2015-08-28 15:50:55 -05:00
|
|
|
struct child *page;
|
2015-07-01 00:02:34 -05:00
|
|
|
|
|
|
|
for (i = 0; i < t->pages->len; i++) {
|
2015-08-28 15:50:55 -05:00
|
|
|
page = g_array_index(t->pages, struct child *, i);
|
|
|
|
childDestroy(page);
|
2015-07-01 00:02:34 -05:00
|
|
|
}
|
|
|
|
g_array_free(t->pages, TRUE);
|
|
|
|
}
|
|
|
|
|
2015-08-28 08:56:41 -05:00
|
|
|
// TODO tabContainerUpdateState()
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-08-28 08:56:41 -05:00
|
|
|
void uiTabAppend(uiTab *t, const char *name, uiControl *child)
|
2015-06-11 18:07:06 -05:00
|
|
|
{
|
2015-08-28 08:56:41 -05:00
|
|
|
uiTabInsertAt(t, name, t->pages->len, child);
|
2015-06-11 18:07:06 -05:00
|
|
|
}
|
|
|
|
|
2015-08-28 08:56:41 -05:00
|
|
|
void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
|
2015-06-11 18:07:06 -05:00
|
|
|
{
|
2015-08-28 15:50:55 -05:00
|
|
|
struct child *page;
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-08-28 15:50:55 -05:00
|
|
|
// this will create a tab, because of gtk_container_add()
|
|
|
|
page = newChildWithBox(child, uiControl(t), t->container, 0);
|
2015-06-29 21:49:12 -05:00
|
|
|
|
2015-08-28 15:50:55 -05:00
|
|
|
gtk_notebook_set_tab_label_text(t->notebook, childBox(page), name);
|
|
|
|
gtk_notebook_reorder_child(t->notebook, childBox(page), 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
|
|
|
}
|
|
|
|
|
2015-08-28 08:56:41 -05:00
|
|
|
void uiTabDelete(uiTab *t, uintmax_t n)
|
2015-06-11 18:07:06 -05:00
|
|
|
{
|
2015-08-28 15:50:55 -05:00
|
|
|
struct child *page;
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-08-28 15:50:55 -05:00
|
|
|
page = g_array_index(t->pages, struct child *, n);
|
|
|
|
// this will remove the tab, because gtk_widget_destroy() calls gtk_container_remove()
|
|
|
|
childRemove(page);
|
2015-07-01 00:02:34 -05:00
|
|
|
g_array_remove_index(t->pages, n);
|
2015-06-11 18:07:06 -05:00
|
|
|
}
|
|
|
|
|
2015-08-28 08:56:41 -05:00
|
|
|
uintmax_t uiTabNumPages(uiTab *t)
|
2015-06-11 18:07:06 -05:00
|
|
|
{
|
2015-06-29 21:49:12 -05:00
|
|
|
return t->pages->len;
|
2015-06-11 18:07:06 -05:00
|
|
|
}
|
|
|
|
|
2015-08-28 08:56:41 -05:00
|
|
|
int uiTabMargined(uiTab *t, uintmax_t n)
|
2015-06-11 18:07:06 -05:00
|
|
|
{
|
2015-08-28 15:50:55 -05:00
|
|
|
struct child *page;
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-08-28 15:50:55 -05:00
|
|
|
page = g_array_index(t->pages, struct child *, n);
|
|
|
|
return childFlag(page);
|
2015-06-11 18:07:06 -05:00
|
|
|
}
|
|
|
|
|
2015-08-28 08:56:41 -05:00
|
|
|
void uiTabSetMargined(uiTab *t, uintmax_t n, int margined)
|
2015-06-11 18:07:06 -05:00
|
|
|
{
|
2015-08-28 15:50:55 -05:00
|
|
|
struct child *page;
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-08-28 15:50:55 -05:00
|
|
|
page = g_array_index(t->pages, struct child *, n);
|
|
|
|
childSetFlag(page, margined);
|
|
|
|
childSetMargined(page, childFlag(page));
|
2015-06-11 18:07:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uiTab *uiNewTab(void)
|
|
|
|
{
|
2015-08-28 08:56:41 -05:00
|
|
|
uiTab *t;
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2016-04-24 15:59:46 -05:00
|
|
|
t = (uiTab *) uiNewControl(uiTab);
|
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);
|
|
|
|
|
|
|
|
gtk_notebook_set_scrollable(t->notebook, TRUE);
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-08-28 15:50:55 -05:00
|
|
|
t->pages = g_array_new(FALSE, TRUE, sizeof (struct child *));
|
2015-06-29 21:49:12 -05:00
|
|
|
|
2015-08-28 08:56:41 -05:00
|
|
|
uiUnixFinishNewControl(t, uiTab);
|
|
|
|
//TODO uiControl(t)->ContainerUpdateState = tabContainerUpdateState;
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-08-28 08:56:41 -05:00
|
|
|
return t;
|
2015-06-11 18:07:06 -05:00
|
|
|
}
|