Made all variables that refer to a tab page be called 'page'.

This commit is contained in:
Pietro Gagliardi 2015-05-10 21:22:22 -04:00
parent 721acd44a4
commit c0c6b4fed6
4 changed files with 63 additions and 64 deletions

View File

@ -1,5 +1,4 @@
- consider calling setAppleMenu: for the application menu; it doesn't seem to make much of a difference but - 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 - 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) - 32-bit Mac OS X support (requires lots of code changes)
- change the build system to be more receptive to arch changes - change the build system to be more receptive to arch changes

View File

@ -54,10 +54,10 @@ static void tabEnable(uiControl *c)
(*(t->baseEnable))(uiControl(t)); (*(t->baseEnable))(uiControl(t));
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { [t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
NSValue *v = (NSValue *) obj; NSValue *v = (NSValue *) obj;
uiBin *p; uiBin *page;
p = (uiBin *) [v pointerValue]; page = (uiBin *) [v pointerValue];
uiControlEnable(uiControl(p)); uiControlEnable(uiControl(page));
}]; }];
} }
@ -68,10 +68,10 @@ static void tabDisable(uiControl *c)
(*(t->baseDisable))(uiControl(t)); (*(t->baseDisable))(uiControl(t));
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { [t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
NSValue *v = (NSValue *) obj; NSValue *v = (NSValue *) obj;
uiBin *p; uiBin *page;
p = (uiBin *) [v pointerValue]; page = (uiBin *) [v pointerValue];
uiControlDisable(uiControl(p)); uiControlDisable(uiControl(page));
}]; }];
} }
@ -82,10 +82,10 @@ static void tabSysFunc(uiControl *c, uiControlSysFuncParams *p)
(*(t->baseSysFunc))(uiControl(t), p); (*(t->baseSysFunc))(uiControl(t), p);
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { [t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
NSValue *v = (NSValue *) obj; NSValue *v = (NSValue *) obj;
uiBin *pp; uiBin *page;
pp = (uiBin *) [v pointerValue]; page = (uiBin *) [v pointerValue];
uiControlSysFunc(uiControl(pp), p); uiControlSysFunc(uiControl(page), p);
}]; }];
} }
@ -127,16 +127,16 @@ static void tabDeletePage(uiTab *tt, uintmax_t n)
{ {
struct tab *t = (struct tab *) tt; struct tab *t = (struct tab *) tt;
NSValue *v; NSValue *v;
uiBin *p; uiBin *page;
NSTabViewItem *i; NSTabViewItem *i;
v = (NSValue *) [t->pages objectAtIndex:n]; v = (NSValue *) [t->pages objectAtIndex:n];
p = (uiBin *) [v pointerValue]; page = (uiBin *) [v pointerValue];
[t->pages removeObjectAtIndex:n]; [t->pages removeObjectAtIndex:n];
[t->margined removeObjectAtIndex:n]; [t->margined removeObjectAtIndex:n];
// make sure the children of the tab aren't destroyed // make sure the children of the tab aren't destroyed
uiBinSetMainControl(p, NULL); uiBinSetMainControl(page, NULL);
// remove the bin from the tab view // remove the bin from the tab view
// this serves the purpose of uiBinRemoveOSParent() // this serves the purpose of uiBinRemoveOSParent()
@ -144,7 +144,7 @@ static void tabDeletePage(uiTab *tt, uintmax_t n)
[t->tabview removeTabViewItem:i]; [t->tabview removeTabViewItem:i];
// then destroy the bin // then destroy the bin
uiControlDestroy(uiControl(p)); uiControlDestroy(uiControl(page));
} }
static uintmax_t tabNumPages(uiTab *tt) 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; struct tab *t = (struct tab *) tt;
NSNumber *v; NSNumber *v;
NSValue *binv; NSValue *pagev;
uiBin *bin; uiBin *page;
v = [NSNumber numberWithInt:margined]; v = [NSNumber numberWithInt:margined];
[t->margined replaceObjectAtIndex:n withObject:v]; [t->margined replaceObjectAtIndex:n withObject:v];
binv = (NSValue *) [t->pages objectAtIndex:n]; pagev = (NSValue *) [t->pages objectAtIndex:n];
bin = (uiBin *) [binv pointerValue]; page = (uiBin *) [pagev pointerValue];
if ([v intValue]) if ([v intValue])
uiBinSetMargins(bin, tabLeftMargin, tabTopMargin, tabRightMargin, tabBottomMargin); uiBinSetMargins(page, tabLeftMargin, tabTopMargin, tabRightMargin, tabBottomMargin);
else else
uiBinSetMargins(bin, 0, 0, 0, 0); uiBinSetMargins(page, 0, 0, 0, 0);
} }
uiTab *uiNewTab(void) uiTab *uiNewTab(void)

View File

@ -20,16 +20,16 @@ static void onDestroy(void *data)
{ {
struct tab *t = (struct tab *) data; struct tab *t = (struct tab *) data;
guint i; guint i;
struct tabPage *p; struct tabPage *page;
// first hide ourselves to avoid flicker // first hide ourselves to avoid flicker
gtk_widget_hide(t->widget); gtk_widget_hide(t->widget);
// the pages do not have a libui parent, so we can simply destroy them // 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 // we need to remove them from the tab first; see below
for (i = 0; i < t->pages->len; i++) { for (i = 0; i < t->pages->len; i++) {
p = &g_array_index(t->pages, struct tabPage, i); page = &g_array_index(t->pages, struct tabPage, i);
uiBinRemoveOSParent(p->bin); uiBinRemoveOSParent(page->bin);
uiControlDestroy(uiControl(p->bin)); uiControlDestroy(uiControl(page->bin));
} }
// then free ourselves // then free ourselves
g_array_free(t->pages, TRUE); 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) static void tabAppendPage(uiTab *tt, const char *name, uiControl *child)
{ {
struct tab *t = (struct tab *) tt; struct tab *t = (struct tab *) tt;
struct tabPage p; struct tabPage page;
p.bin = newBin(); page.bin = newBin();
uiBinSetMainControl(p.bin, child); uiBinSetMainControl(page.bin, child);
// and add it as a tab page // and add it as a tab page
uiBinSetOSParent(p.bin, (uintptr_t) (t->container)); uiBinSetOSParent(page.bin, (uintptr_t) (t->container));
p.binWidget = GTK_WIDGET(uiControlHandle(uiControl(p.bin))); page.binWidget = GTK_WIDGET(uiControlHandle(uiControl(page.bin)));
gtk_notebook_set_tab_label_text(t->notebook, p.binWidget, name); 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) static void tabInsertPageBefore(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
{ {
struct tab *t = (struct tab *) tt; struct tab *t = (struct tab *) tt;
struct tabPage p; struct tabPage page;
p.bin = newBin(); page.bin = newBin();
uiBinSetMainControl(p.bin, child); uiBinSetMainControl(page.bin, child);
// and add it as a tab page // and add it as a tab page
uiBinSetOSParent(p.bin, (uintptr_t) (t->container)); uiBinSetOSParent(page.bin, (uintptr_t) (t->container));
p.binWidget = GTK_WIDGET(uiControlHandle(uiControl(p.bin))); page.binWidget = GTK_WIDGET(uiControlHandle(uiControl(page.bin)));
gtk_notebook_set_tab_label_text(t->notebook, p.binWidget, name); gtk_notebook_set_tab_label_text(t->notebook, page.binWidget, name);
gtk_notebook_reorder_child(t->notebook, p.binWidget, n); gtk_notebook_reorder_child(t->notebook, page.binWidget, n);
g_array_insert_val(t->pages, n, p); g_array_insert_val(t->pages, n, page);
} }
static void tabDeletePage(uiTab *tt, uintmax_t n) static void tabDeletePage(uiTab *tt, uintmax_t n)
{ {
struct tab *t = (struct tab *) tt; 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 // make sure the page's control isn't destroyed
uiBinSetMainControl(p->bin, NULL); uiBinSetMainControl(page->bin, NULL);
// now destroy the page // now destroy the page
// this will also remove the tab // 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 // 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 // (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 // TODO redo this comment
uiBinRemoveOSParent(p->bin); uiBinRemoveOSParent(page->bin);
uiControlDestroy(uiControl(p->bin)); uiControlDestroy(uiControl(page->bin));
g_array_remove_index(t->pages, n); 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) static int tabMargined(uiTab *tt, uintmax_t n)
{ {
struct tab *t = (struct tab *) tt; 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);
return p->margined; return page->margined;
} }
static void tabSetMargined(uiTab *tt, uintmax_t n, int margined) static void tabSetMargined(uiTab *tt, uintmax_t n, int margined)
{ {
struct tab *t = (struct tab *) tt; 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);
p->margined = margined; page->margined = margined;
if (p->margined) if (page->margined)
uiBinSetMargins(p->bin, gtkXMargin, gtkYMargin, gtkXMargin, gtkYMargin); uiBinSetMargins(page->bin, gtkXMargin, gtkYMargin, gtkXMargin, gtkYMargin);
else else
uiBinSetMargins(p->bin, 0, 0, 0, 0); uiBinSetMargins(page->bin, 0, 0, 0, 0);
} }
uiTab *uiNewTab(void) uiTab *uiNewTab(void)

View File

@ -53,19 +53,19 @@ static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult)
static void onDestroy(void *data) static void onDestroy(void *data)
{ {
struct tab *t = (struct tab *) data; struct tab *t = (struct tab *) data;
struct tabPage *p; struct tabPage *page;
// first, hide the widget to avoid flicker // first, hide the widget to avoid flicker
ShowWindow(t->hwnd, SW_HIDE); ShowWindow(t->hwnd, SW_HIDE);
// because the pages don't have by a libui paent, we can simply destroy them // 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 // 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) { 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 // we do have to remove the page from the tab control, though
uiBinRemoveOSParent(p->bin); uiBinRemoveOSParent(page->bin);
uiControlDestroy(uiControl(p->bin)); uiControlDestroy(uiControl(page->bin));
ptrArrayDelete(t->pages, 0); ptrArrayDelete(t->pages, 0);
uiFree(p); uiFree(page);
} }
// and finally destroy ourselves // and finally destroy ourselves
ptrArrayDestroy(t->pages); 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) static void tabEnable(uiControl *c)
{ {
struct tab *t = (struct tab *) c; struct tab *t = (struct tab *) c;
struct tabPage *p; struct tabPage *page;
uintmax_t i; uintmax_t i;
(*(t->baseEnable))(uiControl(t)); (*(t->baseEnable))(uiControl(t));
for (i = 0; i < t->pages->len; i++) { for (i = 0; i < t->pages->len; i++) {
p = ptrArrayIndex(t->pages, struct tabPage *, i); page = ptrArrayIndex(t->pages, struct tabPage *, i);
uiControlEnable(uiControl(p->bin)); uiControlEnable(uiControl(page->bin));
} }
} }
static void tabDisable(uiControl *c) static void tabDisable(uiControl *c)
{ {
struct tab *t = (struct tab *) c; struct tab *t = (struct tab *) c;
struct tabPage *p; struct tabPage *page;
uintmax_t i; uintmax_t i;
(*(t->baseDisable))(uiControl(t)); (*(t->baseDisable))(uiControl(t));
for (i = 0; i < t->pages->len; i++) { for (i = 0; i < t->pages->len; i++) {
p = ptrArrayIndex(t->pages, struct tabPage *, i); page = ptrArrayIndex(t->pages, struct tabPage *, i);
uiControlDisable(uiControl(p->bin)); uiControlDisable(uiControl(page->bin));
} }
} }