Sort of implemented uiTabDeletePage() on GTK+. It's segfaulting on close; that isn't good...

This commit is contained in:
Pietro Gagliardi 2015-04-17 22:26:05 -04:00
parent e74aeeab44
commit 5bd6140d46
4 changed files with 23 additions and 2 deletions

View File

@ -18,6 +18,7 @@
- verify retainment for uiParents in GTK+ - verify retainment for uiParents in GTK+
- add an example of events to each of the new controls guides - add an example of events to each of the new controls guides
- verify that uiParentSetMainControl() does indeed not update - verify that uiParentSetMainControl() does indeed not update
- settle differences between intmax_t and uintmax_t
ultimately: ultimately:
- make everything vtable-based - make everything vtable-based

2
test.c
View File

@ -173,7 +173,7 @@ uiTab *tab;
void movePage1Out(uiButton *b, void *data) void movePage1Out(uiButton *b, void *data)
{ {
uiTabDeletePage(tab, 0) uiTabDeletePage(tab, 0);
uiStackAppend(mainStack, uiControl(page1stack), 1); uiStackAppend(mainStack, uiControl(page1stack), 1);
} }

2
ui.idl
View File

@ -124,7 +124,7 @@ func NewLabel(text *const char) *Label;
interface Tab from Control { interface Tab from Control {
// TODO rename to AppendPage() // TODO rename to AppendPage()
func AddPage(name *const char, c *Control); func AddPage(name *const char, c *Control);
func DeletePage(index intmax_t); func DeletePage(index uintmax_t);
}; };
func NewTab(void) *Tab; func NewTab(void) *Tab;

View File

@ -40,6 +40,25 @@ static void tabAddPage(uiTab *tt, const char *name, uiControl *child)
t->len++; t->len++;
} }
static void tabDeletePage(uiTab *tt, uintmax_t n)
{
struct tab *t = (struct tab *) tt;
uiParent *p;
uintmax_t i;
p = t->pages[n];
for (i = n; i < t->len - 1; i++)
t->pages[i] = t->pages[i + 1];
t->pages[i] = NULL;
t->len--;
// make sure the page's control isn't destroyed
uiParentSetMainControl(p, NULL);
// TODO don't call uiParentDestroy() here as the following line will do so; figure out how to prevent
gtk_notebook_remove_page(t->notebook, n);
}
uiTab *uiNewTab(void) uiTab *uiNewTab(void)
{ {
struct tab *t; struct tab *t;
@ -57,6 +76,7 @@ uiTab *uiNewTab(void)
g_signal_connect(t->widget, "destroy", G_CALLBACK(onDestroy), t); g_signal_connect(t->widget, "destroy", G_CALLBACK(onDestroy), t);
uiTab(t)->AddPage = tabAddPage; uiTab(t)->AddPage = tabAddPage;
uiTab(t)->DeletePage = tabDeletePage;
return uiTab(t); return uiTab(t);
} }