Implemented uiInit() on Unix.

This commit is contained in:
Pietro Gagliardi 2019-04-21 12:24:19 -04:00
parent 2652772891
commit 469484415d
5 changed files with 60 additions and 1 deletions

View File

@ -18,6 +18,8 @@ static int checkInitErrorLengths(uiInitError *err, const char *initErrors[])
{ {
const char **p; const char **p;
if (initErrors == NULL)
return 1;
for (p = initErrors; *p != NULL; p++) for (p = initErrors; *p != NULL; p++)
if (strlen(*p) > 255) { if (strlen(*p) > 255) {
strcpy(err->Message, "[INTERNAL] uiInit() error too long: "); strcpy(err->Message, "[INTERNAL] uiInit() error too long: ");

View File

@ -148,7 +148,7 @@ elif libui_OS == 'darwin'
subdir('darwin') subdir('darwin')
install_headers('ui_darwin.h') install_headers('ui_darwin.h')
else else
# subdir('unix') subdir('unix')
install_headers('ui_unix.h') install_headers('ui_unix.h')
endif endif
libui_libui = library('ui', libui_sources, libui_libui = library('ui', libui_sources,

23
unix/main.c Normal file
View File

@ -0,0 +1,23 @@
// 6 april 2015
#include "uipriv_unix.h"
int uiInit(void *options, uiInitError *err)
{
GError *gerr = NULL;
if (!uiprivInitCheckParams(options, err, NULL))
return 0;
if (gtk_init_with_args(NULL, NULL, NULL, NULL, NULL, &gerr) == FALSE) {
strncpy(err->Message, gerr->message, 255);
g_error_free(gerr);
return 0;
}
uiprivMarkInitialized();
return 1;
}
void uiUninit(void)
{
}

19
unix/meson.build Normal file
View File

@ -0,0 +1,19 @@
# 23 march 2019
libui_sources += [
'unix/main.c',
]
libui_deps += [
dependency('gtk+-3.0',
version: '>=3.10.0',
method: 'pkg-config',
required: true),
# We specify these as not required because some Unix systems include them with libc instead of providing them as separate files (thanks textshell and jpakkane in freenode #mesonbuild)
meson.get_compiler('c').find_library('m',
required: false),
meson.get_compiler('c').find_library('dl',
required: false),
]
libui_soversion = '0'
libui_rpath = '$ORIGIN'

15
unix/uipriv_unix.h Normal file
View File

@ -0,0 +1,15 @@
// 22 april 2015
#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_40
#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_40
#define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_10
#define GDK_VERSION_MAX_ALLOWED GDK_VERSION_3_10
#include <gtk/gtk.h>
#include <math.h>
#include <dlfcn.h> // see future.c
#include <langinfo.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include "../ui.h"
#include "../ui_unix.h"
#include "../common/uipriv.h"