Skip to content

Commit

Permalink
feat(nfd) switch to NFD Extended
Browse files Browse the repository at this point in the history
Close #823
  • Loading branch information
Spasi committed Dec 17, 2022
1 parent db25ba7 commit 2b0e39d
Show file tree
Hide file tree
Showing 28 changed files with 4,614 additions and 4,919 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -125,7 +125,7 @@ improve the chances of a quick and useful response.
|-------|-----------|
|[GLFW](http://www.glfw.org/)|Create multiple windows, handle user input (keyboard, mouse, gaming peripherals) and manage contexts. Also features multi-monitor support, clipboard access, file drag-n-drop, and [much more](http://www.glfw.org/docs/latest/news.html).|
|[JAWT](http://docs.oracle.com/javase/8/docs/technotes/guides/awt/AWT_Native_Interface.html)|The AWT native interface.|
|[nfd](https://github.com/mlabbe/nativefiledialog)|A tiny, neat C library that portably invokes native file open and save dialogs.|
|[Native File Dialog Extended](https://github.com/btzy/nativefiledialog-extended)|A small C library that portably invokes native file open, folder select and file save dialogs.|
|[tinyfd](https://sourceforge.net/projects/tinyfiledialogs/)|A native dialog library.|

#### Audio
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Expand Up @@ -172,7 +172,7 @@ enum class Artifacts(
),
NFD(
"lwjgl-nfd", "LWJGL - Native File Dialog bindings",
"A tiny, neat C library that portably invokes native file open and save dialogs.",
"A small C library that portably invokes native file open, folder select and file save dialogs.",
*Platforms.ALL
),
NUKLEAR(
Expand Down
1 change: 0 additions & 1 deletion config/linux/build.xml
Expand Up @@ -270,7 +270,6 @@
<arg line="-I/usr/include/gtk-3.0 -I/usr/include/glib-2.0 -I/usr/lib/${linux.triplet}/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0"/>
<arg value="-I${src.main.rel}"/>
<arg value="-I${src.main.rel}/include"/>
<fileset dir="." includes="${src.main}/nfd_common.c"/>
<fileset dir="." includes="${src.main}/nfd_gtk.c"/>
</compile>
</beforeCompile>
Expand Down
1 change: 0 additions & 1 deletion config/macos/build.xml
Expand Up @@ -222,7 +222,6 @@
<build module="nfd" simple="true" if:true="${binding.nfd}">
<source>
<arg value="-I${src.main.rel}/include"/>
<fileset dir="." includes="${src.main}/nfd_common.c"/>
<fileset dir="." includes="${src.main}/nfd_cocoa.m"/>
</source>
<link>
Expand Down
7 changes: 5 additions & 2 deletions doc/notes/3.3.2.md
Expand Up @@ -27,6 +27,8 @@ This build includes the following changes:
- lmdb: Updated to 0.9.30 (up from 0.9.28)
- lz4: Updated to 1.9.4 (up from 1.9.3)
- meshoptimizer: Updated to 0.18 (up from 0.17)
- NativeFileDialog: Switched to [Native File Dialog Extended](https://github.com/btzy/nativefiledialog-extended) (#823)
* This is a fork of the original library with new features and breaking API changes.
- Nuklear: Updated to 4.10.4 (up from 4.9.6)
- OpenAL Soft: Updated to 1.22.2 (up from 1.21.1)
* Added `ALC_SOFT_output_mode` extension.
Expand Down Expand Up @@ -90,8 +92,9 @@ This build includes the following changes:

#### Breaking Changes

- NanoVG: The `freeData` parameters of `nvgCreateFontMem*` functions are now mapped to Java `boolean`.
- Nuklear: Renamed `NkConvertConfig::null_texture` to `tex_null` to match the change in the native API.
- NanoVG: The `freeData` parameters of `nvgCreateFontMem*` functions are now mapped to Java `boolean`. (S)
- NativeFileDialog: Now uses the [btzy/nativefiledialog-extended](https://github.com/btzy/nativefiledialog-extended) API. (S)
- Nuklear: Renamed `NkConvertConfig::null_texture` to `tex_null` to match the change in the native API. (S)

```
(B): binary incompatible change
Expand Down
Expand Up @@ -400,8 +400,8 @@ enum class Module(
"nfd",
"org.lwjgl.util.nfd",
"""
Contains bindings to ${url("https://github.com/mlabbe/nativefiledialog", "Native File Dialog")}, a tiny, neat C library that portably invokes native
file open and save dialogs. Write dialog code once and have it popup native dialogs on all supported platforms.
Contains bindings to ${url("https://github.com/btzy/nativefiledialog-extended", "Native File Dialog Extended")}, a small C library that portably
invokes native file open, folder select and file save dialogs. Write dialog code once and have it pop up native dialogs on all supported platforms.
""",
library = JNILibrary.create("LibNFD", setupAllocator = true)
),
Expand Down
Expand Up @@ -14,14 +14,14 @@

EXTERN_C_ENTER

JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NFDPathSet_offsets(JNIEnv *__env, jclass clazz, jlong bufferAddress) {
JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NFDPathSetEnum_offsets(JNIEnv *__env, jclass clazz, jlong bufferAddress) {
jint *buffer = (jint *)(uintptr_t)bufferAddress;

UNUSED_PARAMS(__env, clazz)

buffer[0] = alignof(nfdpathset_t);
buffer[0] = alignof(nfdpathsetenum_t);

return sizeof(nfdpathset_t);
return sizeof(nfdpathsetenum_t);
}

EXTERN_C_EXIT
Expand Up @@ -9,64 +9,118 @@

EXTERN_C_ENTER

JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1OpenDialog(JNIEnv *__env, jclass clazz, jlong filterListAddress, jlong defaultPathAddress, jlong outPathAddress) {
nfdchar_t const *filterList = (nfdchar_t const *)(uintptr_t)filterListAddress;
nfdchar_t const *defaultPath = (nfdchar_t const *)(uintptr_t)defaultPathAddress;
nfdchar_t **outPath = (nfdchar_t **)(uintptr_t)outPathAddress;
JNIEXPORT void JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1FreePath(JNIEnv *__env, jclass clazz, jlong filePathAddress) {
nfdchar_t *filePath = (nfdchar_t *)(uintptr_t)filePathAddress;
UNUSED_PARAMS(__env, clazz)
NFD_FreePath(filePath);
}

JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_NFD_1Init(JNIEnv *__env, jclass clazz) {
UNUSED_PARAMS(__env, clazz)
return (jint)NFD_OpenDialog(filterList, defaultPath, outPath);
return (jint)NFD_Init();
}

JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1OpenDialogMultiple(JNIEnv *__env, jclass clazz, jlong filterListAddress, jlong defaultPathAddress, jlong outPathsAddress) {
nfdchar_t const *filterList = (nfdchar_t const *)(uintptr_t)filterListAddress;
JNIEXPORT void JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_NFD_1Quit(JNIEnv *__env, jclass clazz) {
UNUSED_PARAMS(__env, clazz)
NFD_Quit();
}

JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1OpenDialog(JNIEnv *__env, jclass clazz, jlong outPathAddress, jlong filterListAddress, jint filterCount, jlong defaultPathAddress) {
nfdchar_t **outPath = (nfdchar_t **)(uintptr_t)outPathAddress;
nfdfilteritem_t const *filterList = (nfdfilteritem_t const *)(uintptr_t)filterListAddress;
nfdchar_t const *defaultPath = (nfdchar_t const *)(uintptr_t)defaultPathAddress;
nfdpathset_t *outPaths = (nfdpathset_t *)(uintptr_t)outPathsAddress;
UNUSED_PARAMS(__env, clazz)
return (jint)NFD_OpenDialogMultiple(filterList, defaultPath, outPaths);
return (jint)NFD_OpenDialog(outPath, filterList, (nfdfiltersize_t)filterCount, defaultPath);
}

JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1SaveDialog(JNIEnv *__env, jclass clazz, jlong filterListAddress, jlong defaultPathAddress, jlong outPathAddress) {
nfdchar_t const *filterList = (nfdchar_t const *)(uintptr_t)filterListAddress;
JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1OpenDialogMultiple(JNIEnv *__env, jclass clazz, jlong outPathAddress, jlong filterListAddress, jint filterCount, jlong defaultPathAddress) {
nfdpathset_t **outPath = (nfdpathset_t **)(uintptr_t)outPathAddress;
nfdfilteritem_t const *filterList = (nfdfilteritem_t const *)(uintptr_t)filterListAddress;
nfdchar_t const *defaultPath = (nfdchar_t const *)(uintptr_t)defaultPathAddress;
nfdchar_t **outPath = (nfdchar_t **)(uintptr_t)outPathAddress;
UNUSED_PARAMS(__env, clazz)
return (jint)NFD_SaveDialog(filterList, defaultPath, outPath);
return (jint)NFD_OpenDialogMultiple(outPath, filterList, (nfdfiltersize_t)filterCount, defaultPath);
}

JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1PickFolder(JNIEnv *__env, jclass clazz, jlong defaultPathAddress, jlong outPathAddress) {
JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1SaveDialog(JNIEnv *__env, jclass clazz, jlong outPathAddress, jlong filterListAddress, jint filterCount, jlong defaultPathAddress, jlong defaultNameAddress) {
nfdchar_t **outPath = (nfdchar_t **)(uintptr_t)outPathAddress;
nfdfilteritem_t const *filterList = (nfdfilteritem_t const *)(uintptr_t)filterListAddress;
nfdchar_t const *defaultPath = (nfdchar_t const *)(uintptr_t)defaultPathAddress;
nfdchar_t const *defaultName = (nfdchar_t const *)(uintptr_t)defaultNameAddress;
UNUSED_PARAMS(__env, clazz)
return (jint)NFD_SaveDialog(outPath, filterList, (nfdfiltersize_t)filterCount, defaultPath, defaultName);
}

JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1PickFolder(JNIEnv *__env, jclass clazz, jlong outPathAddress, jlong defaultPathAddress) {
nfdchar_t **outPath = (nfdchar_t **)(uintptr_t)outPathAddress;
nfdchar_t const *defaultPath = (nfdchar_t const *)(uintptr_t)defaultPathAddress;
UNUSED_PARAMS(__env, clazz)
return (jint)NFD_PickFolder(defaultPath, outPath);
return (jint)NFD_PickFolder(outPath, defaultPath);
}

JNIEXPORT jlong JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1GetError(JNIEnv *__env, jclass clazz) {
UNUSED_PARAMS(__env, clazz)
return (jlong)(uintptr_t)NFD_GetError();
}

JNIEXPORT jlong JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1PathSet_1GetCount(JNIEnv *__env, jclass clazz, jlong pathSetAddress) {
JNIEXPORT void JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_NFD_1ClearError(JNIEnv *__env, jclass clazz) {
UNUSED_PARAMS(__env, clazz)
NFD_ClearError();
}

JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1PathSet_1GetCount__JJ(JNIEnv *__env, jclass clazz, jlong pathSetAddress, jlong countAddress) {
nfdpathset_t const *pathSet = (nfdpathset_t const *)(uintptr_t)pathSetAddress;
nfdpathsetsize_t *count = (nfdpathsetsize_t *)(uintptr_t)countAddress;
UNUSED_PARAMS(__env, clazz)
return (jlong)NFD_PathSet_GetCount(pathSet);
return (jint)NFD_PathSet_GetCount(pathSet, count);
}

JNIEXPORT jlong JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1PathSet_1GetPath(JNIEnv *__env, jclass clazz, jlong pathSetAddress, jlong index) {
JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1PathSet_1GetPath(JNIEnv *__env, jclass clazz, jlong pathSetAddress, jint index, jlong outPathAddress) {
nfdpathset_t const *pathSet = (nfdpathset_t const *)(uintptr_t)pathSetAddress;
nfdchar_t **outPath = (nfdchar_t **)(uintptr_t)outPathAddress;
UNUSED_PARAMS(__env, clazz)
return (jlong)(uintptr_t)NFD_PathSet_GetPath(pathSet, (size_t)index);
return (jint)NFD_PathSet_GetPath(pathSet, (nfdpathsetsize_t)index, outPath);
}

JNIEXPORT void JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1PathSet_1FreePath(JNIEnv *__env, jclass clazz, jlong filePathAddress) {
nfdchar_t const *filePath = (nfdchar_t const *)(uintptr_t)filePathAddress;
UNUSED_PARAMS(__env, clazz)
NFD_PathSet_FreePath(filePath);
}

JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1PathSet_1GetEnum(JNIEnv *__env, jclass clazz, jlong pathSetAddress, jlong outEnumeratorAddress) {
nfdpathset_t const *pathSet = (nfdpathset_t const *)(uintptr_t)pathSetAddress;
nfdpathsetenum_t *outEnumerator = (nfdpathsetenum_t *)(uintptr_t)outEnumeratorAddress;
UNUSED_PARAMS(__env, clazz)
return (jint)NFD_PathSet_GetEnum(pathSet, outEnumerator);
}

JNIEXPORT void JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1PathSet_1FreeEnum(JNIEnv *__env, jclass clazz, jlong enumeratorAddress) {
nfdpathsetenum_t *enumerator = (nfdpathsetenum_t *)(uintptr_t)enumeratorAddress;
UNUSED_PARAMS(__env, clazz)
NFD_PathSet_FreeEnum(enumerator);
}

JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1PathSet_1EnumNext(JNIEnv *__env, jclass clazz, jlong enumeratorAddress, jlong outPathAddress) {
nfdpathsetenum_t *enumerator = (nfdpathsetenum_t *)(uintptr_t)enumeratorAddress;
nfdchar_t **outPath = (nfdchar_t **)(uintptr_t)outPathAddress;
UNUSED_PARAMS(__env, clazz)
return (jint)NFD_PathSet_EnumNext(enumerator, outPath);
}

JNIEXPORT void JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1PathSet_1Free(JNIEnv *__env, jclass clazz, jlong pathSetAddress) {
nfdpathset_t *pathSet = (nfdpathset_t *)(uintptr_t)pathSetAddress;
nfdpathset_t const *pathSet = (nfdpathset_t const *)(uintptr_t)pathSetAddress;
UNUSED_PARAMS(__env, clazz)
NFD_PathSet_Free(pathSet);
}

JNIEXPORT void JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1Free(JNIEnv *__env, jclass clazz, jlong outPathAddress) {
void *outPath = (void *)(uintptr_t)outPathAddress;
JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_NativeFileDialog_nNFD_1PathSet_1GetCount__J_3I(JNIEnv *__env, jclass clazz, jlong pathSetAddress, jintArray countAddress) {
nfdpathset_t const *pathSet = (nfdpathset_t const *)(uintptr_t)pathSetAddress;
jint __result;
jint *count = (*__env)->GetIntArrayElements(__env, countAddress, NULL);
UNUSED_PARAMS(__env, clazz)
NFD_Free(outPath);
__result = (jint)NFD_PathSet_GetCount(pathSet, (nfdpathsetsize_t *)count);
(*__env)->ReleaseIntArrayElements(__env, countAddress, count, 0);
return __result;
}

EXTERN_C_EXIT
@@ -0,0 +1,27 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
#include "common_tools.h"
#include "nfd.h"
#include <stddef.h>
#ifdef LWJGL_WINDOWS
#define alignof __alignof
#else
#include <stdalign.h>
#endif

EXTERN_C_ENTER

JNIEXPORT jint JNICALL Java_org_lwjgl_util_nfd_PFDPathSetEnum_offsets(JNIEnv *__env, jclass clazz, jlong bufferAddress) {
jint *buffer = (jint *)(uintptr_t)bufferAddress;

UNUSED_PARAMS(__env, clazz)

buffer[0] = alignof(nfdpathsetenum_t);

return sizeof(nfdpathsetenum_t);
}

EXTERN_C_EXIT

0 comments on commit 2b0e39d

Please sign in to comment.