Made all variables that refer to a tab page be called 'page'.
This commit is contained in:
parent
721acd44a4
commit
c0c6b4fed6
1
TODO.md
1
TODO.md
|
@ -1,5 +1,4 @@
|
|||
- consider calling setAppleMenu: for the application menu; it doesn't seem to make much of a difference but
|
||||
- make the name of the variable to refer to a single tab page consistent (already decided to make them all `page`)
|
||||
- make it so Windows API calls that do logLastError(), etc. abort whatever they're doing and not try to continue, just like wintable
|
||||
- 32-bit Mac OS X support (requires lots of code changes)
|
||||
- change the build system to be more receptive to arch changes
|
||||
|
|
38
darwin/tab.m
38
darwin/tab.m
|
@ -54,10 +54,10 @@ static void tabEnable(uiControl *c)
|
|||
(*(t->baseEnable))(uiControl(t));
|
||||
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
||||
NSValue *v = (NSValue *) obj;
|
||||
uiBin *p;
|
||||
uiBin *page;
|
||||
|
||||
p = (uiBin *) [v pointerValue];
|
||||
uiControlEnable(uiControl(p));
|
||||
page = (uiBin *) [v pointerValue];
|
||||
uiControlEnable(uiControl(page));
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -68,10 +68,10 @@ static void tabDisable(uiControl *c)
|
|||
(*(t->baseDisable))(uiControl(t));
|
||||
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
||||
NSValue *v = (NSValue *) obj;
|
||||
uiBin *p;
|
||||
uiBin *page;
|
||||
|
||||
p = (uiBin *) [v pointerValue];
|
||||
uiControlDisable(uiControl(p));
|
||||
page = (uiBin *) [v pointerValue];
|
||||
uiControlDisable(uiControl(page));
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -82,10 +82,10 @@ static void tabSysFunc(uiControl *c, uiControlSysFuncParams *p)
|
|||
(*(t->baseSysFunc))(uiControl(t), p);
|
||||
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
||||
NSValue *v = (NSValue *) obj;
|
||||
uiBin *pp;
|
||||
uiBin *page;
|
||||
|
||||
pp = (uiBin *) [v pointerValue];
|
||||
uiControlSysFunc(uiControl(pp), p);
|
||||
page = (uiBin *) [v pointerValue];
|
||||
uiControlSysFunc(uiControl(page), p);
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -127,16 +127,16 @@ static void tabDeletePage(uiTab *tt, uintmax_t n)
|
|||
{
|
||||
struct tab *t = (struct tab *) tt;
|
||||
NSValue *v;
|
||||
uiBin *p;
|
||||
uiBin *page;
|
||||
NSTabViewItem *i;
|
||||
|
||||
v = (NSValue *) [t->pages objectAtIndex:n];
|
||||
p = (uiBin *) [v pointerValue];
|
||||
page = (uiBin *) [v pointerValue];
|
||||
[t->pages removeObjectAtIndex:n];
|
||||
[t->margined removeObjectAtIndex:n];
|
||||
|
||||
// make sure the children of the tab aren't destroyed
|
||||
uiBinSetMainControl(p, NULL);
|
||||
uiBinSetMainControl(page, NULL);
|
||||
|
||||
// remove the bin from the tab view
|
||||
// this serves the purpose of uiBinRemoveOSParent()
|
||||
|
@ -144,7 +144,7 @@ static void tabDeletePage(uiTab *tt, uintmax_t n)
|
|||
[t->tabview removeTabViewItem:i];
|
||||
|
||||
// then destroy the bin
|
||||
uiControlDestroy(uiControl(p));
|
||||
uiControlDestroy(uiControl(page));
|
||||
}
|
||||
|
||||
static uintmax_t tabNumPages(uiTab *tt)
|
||||
|
@ -178,17 +178,17 @@ static void tabSetMargined(uiTab *tt, uintmax_t n, int margined)
|
|||
{
|
||||
struct tab *t = (struct tab *) tt;
|
||||
NSNumber *v;
|
||||
NSValue *binv;
|
||||
uiBin *bin;
|
||||
NSValue *pagev;
|
||||
uiBin *page;
|
||||
|
||||
v = [NSNumber numberWithInt:margined];
|
||||
[t->margined replaceObjectAtIndex:n withObject:v];
|
||||
binv = (NSValue *) [t->pages objectAtIndex:n];
|
||||
bin = (uiBin *) [binv pointerValue];
|
||||
pagev = (NSValue *) [t->pages objectAtIndex:n];
|
||||
page = (uiBin *) [pagev pointerValue];
|
||||
if ([v intValue])
|
||||
uiBinSetMargins(bin, tabLeftMargin, tabTopMargin, tabRightMargin, tabBottomMargin);
|
||||
uiBinSetMargins(page, tabLeftMargin, tabTopMargin, tabRightMargin, tabBottomMargin);
|
||||
else
|
||||
uiBinSetMargins(bin, 0, 0, 0, 0);
|
||||
uiBinSetMargins(page, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
uiTab *uiNewTab(void)
|
||||
|
|
66
unix/tab.c
66
unix/tab.c
|
@ -20,16 +20,16 @@ static void onDestroy(void *data)
|
|||
{
|
||||
struct tab *t = (struct tab *) data;
|
||||
guint i;
|
||||
struct tabPage *p;
|
||||
struct tabPage *page;
|
||||
|
||||
// first hide ourselves to avoid flicker
|
||||
gtk_widget_hide(t->widget);
|
||||
// the pages do not have a libui parent, so we can simply destroy them
|
||||
// we need to remove them from the tab first; see below
|
||||
for (i = 0; i < t->pages->len; i++) {
|
||||
p = &g_array_index(t->pages, struct tabPage, i);
|
||||
uiBinRemoveOSParent(p->bin);
|
||||
uiControlDestroy(uiControl(p->bin));
|
||||
page = &g_array_index(t->pages, struct tabPage, i);
|
||||
uiBinRemoveOSParent(page->bin);
|
||||
uiControlDestroy(uiControl(page->bin));
|
||||
}
|
||||
// then free ourselves
|
||||
g_array_free(t->pages, TRUE);
|
||||
|
@ -49,43 +49,43 @@ static void tabShow(uiControl *c)
|
|||
static void tabAppendPage(uiTab *tt, const char *name, uiControl *child)
|
||||
{
|
||||
struct tab *t = (struct tab *) tt;
|
||||
struct tabPage p;
|
||||
struct tabPage page;
|
||||
|
||||
p.bin = newBin();
|
||||
uiBinSetMainControl(p.bin, child);
|
||||
page.bin = newBin();
|
||||
uiBinSetMainControl(page.bin, child);
|
||||
// and add it as a tab page
|
||||
uiBinSetOSParent(p.bin, (uintptr_t) (t->container));
|
||||
p.binWidget = GTK_WIDGET(uiControlHandle(uiControl(p.bin)));
|
||||
gtk_notebook_set_tab_label_text(t->notebook, p.binWidget, name);
|
||||
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, p);
|
||||
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 p;
|
||||
struct tabPage page;
|
||||
|
||||
p.bin = newBin();
|
||||
uiBinSetMainControl(p.bin, child);
|
||||
page.bin = newBin();
|
||||
uiBinSetMainControl(page.bin, child);
|
||||
// and add it as a tab page
|
||||
uiBinSetOSParent(p.bin, (uintptr_t) (t->container));
|
||||
p.binWidget = GTK_WIDGET(uiControlHandle(uiControl(p.bin)));
|
||||
gtk_notebook_set_tab_label_text(t->notebook, p.binWidget, name);
|
||||
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, p.binWidget, n);
|
||||
g_array_insert_val(t->pages, n, p);
|
||||
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)
|
||||
{
|
||||
struct tab *t = (struct tab *) tt;
|
||||
struct tabPage *p;
|
||||
struct tabPage *page;
|
||||
|
||||
p = &g_array_index(t->pages, struct tabPage, n);
|
||||
page = &g_array_index(t->pages, struct tabPage, n);
|
||||
|
||||
// make sure the page's control isn't destroyed
|
||||
uiBinSetMainControl(p->bin, NULL);
|
||||
uiBinSetMainControl(page->bin, NULL);
|
||||
|
||||
// now destroy the page
|
||||
// this will also remove the tab
|
||||
|
@ -93,8 +93,8 @@ static void tabDeletePage(uiTab *tt, uintmax_t n)
|
|||
// we need to remove them from the tab first, though, otherwise they won't really be destroyed properly
|
||||
// (the GtkNotebook will still have the tab in it because its reference ISN'T destroyed, and we crash resizing a bin that no longer exists
|
||||
// TODO redo this comment
|
||||
uiBinRemoveOSParent(p->bin);
|
||||
uiControlDestroy(uiControl(p->bin));
|
||||
uiBinRemoveOSParent(page->bin);
|
||||
uiControlDestroy(uiControl(page->bin));
|
||||
|
||||
g_array_remove_index(t->pages, n);
|
||||
}
|
||||
|
@ -109,23 +109,23 @@ static uintmax_t tabNumPages(uiTab *tt)
|
|||
static int tabMargined(uiTab *tt, uintmax_t n)
|
||||
{
|
||||
struct tab *t = (struct tab *) tt;
|
||||
struct tabPage *p;
|
||||
struct tabPage *page;
|
||||
|
||||
p = &g_array_index(t->pages, struct tabPage, n);
|
||||
return p->margined;
|
||||
page = &g_array_index(t->pages, struct tabPage, n);
|
||||
return page->margined;
|
||||
}
|
||||
|
||||
static void tabSetMargined(uiTab *tt, uintmax_t n, int margined)
|
||||
{
|
||||
struct tab *t = (struct tab *) tt;
|
||||
struct tabPage *p;
|
||||
struct tabPage *page;
|
||||
|
||||
p = &g_array_index(t->pages, struct tabPage, n);
|
||||
p->margined = margined;
|
||||
if (p->margined)
|
||||
uiBinSetMargins(p->bin, gtkXMargin, gtkYMargin, gtkXMargin, gtkYMargin);
|
||||
page = &g_array_index(t->pages, struct tabPage, n);
|
||||
page->margined = margined;
|
||||
if (page->margined)
|
||||
uiBinSetMargins(page->bin, gtkXMargin, gtkYMargin, gtkXMargin, gtkYMargin);
|
||||
else
|
||||
uiBinSetMargins(p->bin, 0, 0, 0, 0);
|
||||
uiBinSetMargins(page->bin, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
uiTab *uiNewTab(void)
|
||||
|
|
|
@ -53,19 +53,19 @@ static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult)
|
|||
static void onDestroy(void *data)
|
||||
{
|
||||
struct tab *t = (struct tab *) data;
|
||||
struct tabPage *p;
|
||||
struct tabPage *page;
|
||||
|
||||
// first, hide the widget to avoid flicker
|
||||
ShowWindow(t->hwnd, SW_HIDE);
|
||||
// because the pages don't have by a libui paent, we can simply destroy them
|
||||
// we don't have to worry about the Windows tab control holding a reference to our bin; there is no reference holding anyway
|
||||
while (t->pages->len != 0) {
|
||||
p = ptrArrayIndex(t->pages, struct tabPage *, 0);
|
||||
page = ptrArrayIndex(t->pages, struct tabPage *, 0);
|
||||
// we do have to remove the page from the tab control, though
|
||||
uiBinRemoveOSParent(p->bin);
|
||||
uiControlDestroy(uiControl(p->bin));
|
||||
uiBinRemoveOSParent(page->bin);
|
||||
uiControlDestroy(uiControl(page->bin));
|
||||
ptrArrayDelete(t->pages, 0);
|
||||
uiFree(p);
|
||||
uiFree(page);
|
||||
}
|
||||
// and finally destroy ourselves
|
||||
ptrArrayDestroy(t->pages);
|
||||
|
@ -135,26 +135,26 @@ static void tabResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intm
|
|||
static void tabEnable(uiControl *c)
|
||||
{
|
||||
struct tab *t = (struct tab *) c;
|
||||
struct tabPage *p;
|
||||
struct tabPage *page;
|
||||
uintmax_t i;
|
||||
|
||||
(*(t->baseEnable))(uiControl(t));
|
||||
for (i = 0; i < t->pages->len; i++) {
|
||||
p = ptrArrayIndex(t->pages, struct tabPage *, i);
|
||||
uiControlEnable(uiControl(p->bin));
|
||||
page = ptrArrayIndex(t->pages, struct tabPage *, i);
|
||||
uiControlEnable(uiControl(page->bin));
|
||||
}
|
||||
}
|
||||
|
||||
static void tabDisable(uiControl *c)
|
||||
{
|
||||
struct tab *t = (struct tab *) c;
|
||||
struct tabPage *p;
|
||||
struct tabPage *page;
|
||||
uintmax_t i;
|
||||
|
||||
(*(t->baseDisable))(uiControl(t));
|
||||
for (i = 0; i < t->pages->len; i++) {
|
||||
p = ptrArrayIndex(t->pages, struct tabPage *, i);
|
||||
uiControlDisable(uiControl(p->bin));
|
||||
page = ptrArrayIndex(t->pages, struct tabPage *, i);
|
||||
uiControlDisable(uiControl(page->bin));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue