Decided to kill uiInitError and return the message as a const char * instead. Will need to implement on Windows.

This commit is contained in:
Pietro Gagliardi 2015-04-10 16:54:06 -04:00
parent e49f6f7da8
commit d326407f05
4 changed files with 17 additions and 32 deletions

View File

@ -42,7 +42,7 @@
uiInitOptions options;
uiInitError *uiInit(uiInitOptions *o)
const char *uiInit(uiInitOptions *o)
{
options = *o;
[uiApplication sharedApplication];
@ -53,11 +53,6 @@ uiInitError *uiInit(uiInitOptions *o)
return NULL;
}
const char *uiInitErrorMessage(uiInitError *err)
{
return "";
}
void uiInitErrorFree(uiInitError *err)
void uiFreeInitError(const char *err)
{
}

View File

@ -1,31 +1,23 @@
// 6 april 2015
#include "uipriv_unix.h"
struct uiInitError {
GError *err;
};
uiInitOptions options;
uiInitError *uiInit(uiInitOptions *o)
const char *uiInit(uiInitOptions *o)
{
uiInitError *err;
GError *err = NULL;
const char *msg;
options = *o;
err = uiNew(uiInitError);
if (gtk_init_with_args(NULL, NULL, NULL, NULL, NULL, &(err->err)) == FALSE)
return err;
uiFree(err);
if (gtk_init_with_args(NULL, NULL, NULL, NULL, NULL, &err) == FALSE) {
msg = g_strdup(err->message);
g_error_free(err);
return msg;
}
return NULL;
}
const char *uiInitErrorMessage(uiInitError *err)
void uiFreeInitError(const char *err)
{
return err->err->message;
}
void uiInitErrorFree(uiInitError *err)
{
g_error_free(err->err);
uiFree(err);
g_free((gpointer) err);
}

View File

@ -114,7 +114,7 @@ int main(int argc, char *argv[])
{
uiInitOptions o;
int i;
uiInitError *err;
const char *err;
uiControl *getButton, *setButton;
memset(&o, 0, sizeof (uiInitOptions));
@ -128,8 +128,8 @@ int main(int argc, char *argv[])
err = uiInit(&o);
if (err != NULL) {
fprintf(stderr, "error initializing ui: %s\n", uiInitErrorMessage(err));
uiInitErrorFree(err);
fprintf(stderr, "error initializing ui: %s\n", err);
uiFreeInitError(err);
return 1;
}

View File

@ -5,7 +5,6 @@
#include <stdint.h>
typedef struct uiInitError uiInitError;
typedef struct uiInitOptions uiInitOptions;
// TODO note that should be initialized to zero
@ -17,9 +16,8 @@ struct uiInitOptions {
int debugLogAllocations;
};
uiInitError *uiInit(uiInitOptions *);
const char *uiInitErrorMessage(uiInitError *);
void uiInitErrorFree(uiInitError *);
const char *uiInit(uiInitOptions *);
void uiFreeInitError(const char *);
void uiMain(void);
void uiQuit(void);