Decided to kill uiInitError and return the message as a const char * instead. Will need to implement on Windows.
This commit is contained in:
parent
e7adf623ae
commit
6277c34337
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
uiInitOptions options;
|
uiInitOptions options;
|
||||||
|
|
||||||
uiInitError *uiInit(uiInitOptions *o)
|
const char *uiInit(uiInitOptions *o)
|
||||||
{
|
{
|
||||||
options = *o;
|
options = *o;
|
||||||
[uiApplication sharedApplication];
|
[uiApplication sharedApplication];
|
||||||
|
@ -53,11 +53,6 @@ uiInitError *uiInit(uiInitOptions *o)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *uiInitErrorMessage(uiInitError *err)
|
void uiFreeInitError(const char *err)
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void uiInitErrorFree(uiInitError *err)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
28
init_unix.c
28
init_unix.c
|
@ -1,31 +1,23 @@
|
||||||
// 6 april 2015
|
// 6 april 2015
|
||||||
#include "uipriv_unix.h"
|
#include "uipriv_unix.h"
|
||||||
|
|
||||||
struct uiInitError {
|
|
||||||
GError *err;
|
|
||||||
};
|
|
||||||
|
|
||||||
uiInitOptions options;
|
uiInitOptions options;
|
||||||
|
|
||||||
uiInitError *uiInit(uiInitOptions *o)
|
const char *uiInit(uiInitOptions *o)
|
||||||
{
|
{
|
||||||
uiInitError *err;
|
GError *err = NULL;
|
||||||
|
const char *msg;
|
||||||
|
|
||||||
options = *o;
|
options = *o;
|
||||||
err = uiNew(uiInitError);
|
if (gtk_init_with_args(NULL, NULL, NULL, NULL, NULL, &err) == FALSE) {
|
||||||
if (gtk_init_with_args(NULL, NULL, NULL, NULL, NULL, &(err->err)) == FALSE)
|
msg = g_strdup(err->message);
|
||||||
return err;
|
g_error_free(err);
|
||||||
uiFree(err);
|
return msg;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *uiInitErrorMessage(uiInitError *err)
|
void uiFreeInitError(const char *err)
|
||||||
{
|
{
|
||||||
return err->err->message;
|
g_free((gpointer) err);
|
||||||
}
|
|
||||||
|
|
||||||
void uiInitErrorFree(uiInitError *err)
|
|
||||||
{
|
|
||||||
g_error_free(err->err);
|
|
||||||
uiFree(err);
|
|
||||||
}
|
}
|
||||||
|
|
6
test.c
6
test.c
|
@ -114,7 +114,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
uiInitOptions o;
|
uiInitOptions o;
|
||||||
int i;
|
int i;
|
||||||
uiInitError *err;
|
const char *err;
|
||||||
uiControl *getButton, *setButton;
|
uiControl *getButton, *setButton;
|
||||||
|
|
||||||
memset(&o, 0, sizeof (uiInitOptions));
|
memset(&o, 0, sizeof (uiInitOptions));
|
||||||
|
@ -128,8 +128,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
err = uiInit(&o);
|
err = uiInit(&o);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
fprintf(stderr, "error initializing ui: %s\n", uiInitErrorMessage(err));
|
fprintf(stderr, "error initializing ui: %s\n", err);
|
||||||
uiInitErrorFree(err);
|
uiFreeInitError(err);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
ui.h
6
ui.h
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct uiInitError uiInitError;
|
|
||||||
typedef struct uiInitOptions uiInitOptions;
|
typedef struct uiInitOptions uiInitOptions;
|
||||||
|
|
||||||
// TODO note that should be initialized to zero
|
// TODO note that should be initialized to zero
|
||||||
|
@ -17,9 +16,8 @@ struct uiInitOptions {
|
||||||
int debugLogAllocations;
|
int debugLogAllocations;
|
||||||
};
|
};
|
||||||
|
|
||||||
uiInitError *uiInit(uiInitOptions *);
|
const char *uiInit(uiInitOptions *);
|
||||||
const char *uiInitErrorMessage(uiInitError *);
|
void uiFreeInitError(const char *);
|
||||||
void uiInitErrorFree(uiInitError *);
|
|
||||||
|
|
||||||
void uiMain(void);
|
void uiMain(void);
|
||||||
void uiQuit(void);
|
void uiQuit(void);
|
||||||
|
|
Loading…
Reference in New Issue