Changed the uiMainSteps() API as the GTK+ port will need it to be done this way...

This commit is contained in:
Pietro Gagliardi 2016-06-16 13:49:50 -04:00
parent da4b396aaf
commit d4492c06a9
3 changed files with 11 additions and 7 deletions

View File

@ -159,12 +159,13 @@ void uiMain(void)
[realNSApp() run]; [realNSApp() run];
} }
void uiMainSteps(void) void uiMainSteps(void (*f)(void *), void *data)
{ {
isRunning = ^{ isRunning = ^{
return stepsIsRunning; return stepsIsRunning;
}; };
stepsIsRunning = YES; stepsIsRunning = YES;
(*f)(data);
} }
// see also: // see also:

View File

@ -39,6 +39,12 @@ uiTab *mainTab;
uiBox *(*newhbox)(void); uiBox *(*newhbox)(void);
uiBox *(*newvbox)(void); uiBox *(*newvbox)(void);
static void stepsLoop(void *data)
{
while (uiMainStep(1))
;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
uiInitOptions o; uiInitOptions o;
@ -161,11 +167,8 @@ int main(int argc, char *argv[])
uiControlShow(uiControl(w)); uiControlShow(uiControl(w));
if (!steps) if (!steps)
uiMain(); uiMain();
else { else
uiMainSteps(); uiMainSteps(stepsLoop, NULL);
while (uiMainStep(1))
;
}
printf("after uiMain()\n"); printf("after uiMain()\n");
uiUninit(); uiUninit();
printf("after uiUninit()\n"); printf("after uiUninit()\n");

2
ui.h
View File

@ -45,7 +45,7 @@ _UI_EXTERN void uiUninit(void);
_UI_EXTERN void uiFreeInitError(const char *err); _UI_EXTERN void uiFreeInitError(const char *err);
_UI_EXTERN void uiMain(void); _UI_EXTERN void uiMain(void);
_UI_EXTERN void uiMainSteps(void); _UI_EXTERN void uiMainSteps(void (*f)(void *), void *data);
_UI_EXTERN int uiMainStep(int wait); _UI_EXTERN int uiMainStep(int wait);
_UI_EXTERN void uiQuit(void); _UI_EXTERN void uiQuit(void);