From 6fc145906eafdbd89f4558b79282a9e5d722afbc Mon Sep 17 00:00:00 2001 From: Mole Shang <135e2@135e2.dev> Date: Sun, 6 Aug 2023 12:54:47 +0800 Subject: xmake: migrate from NFD to tinyfiledialogs nativefiledialog-extended works great on Linux w/ portal support, but somehow is too complex to build on Windows. [1] Switch to tinyfd for simplicity. [1]: Visual Studio CL.exe would fail with MSB6001. ``` Error MSB6001: Invalid command line switch for "CL.exe". Item has already been added. Key in dictionary: 'VCInstallDir' Key being added: 'VCINSTALLDIR' ``` For further information, see below: https://social.msdn.microsoft.com/Forums/vstudio/en-US/5de6d7e3-7a38-4712-ba59-be179808bf9e/error-msb6001-invalid-command-line-switch-for-clexe https://github.com/dotnet/msbuild/issues/5726 It's been over 10 years, and Microsoft still claims that case sensitivity thing is a FEATURE. Holy M$, Thank you. --- src/main.c | 7 +------ src/ui.c | 12 ++++-------- 2 files changed, 5 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index d60112e..4306b87 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,6 @@ #include #include #include -#include #include #include @@ -21,12 +20,12 @@ #include "nuklear_glfw_gl3.h" #include "constants.h" -#include "unifont.h" #include "logger.h" #include "main.h" #include "process_url.h" #include "style.h" #include "ui.h" +#include "unifont.h" extern int win_width, win_height; extern void load_ui(struct ui_struct *); @@ -77,9 +76,6 @@ int main(void) { exit(EXIT_FAILURE); } - /* Native File Dialog */ - NFD_Init(); - /* Logger setup */ struct logger *logger = setup_logger(); // Put it in ui_struct @@ -155,7 +151,6 @@ int main(void) { MAX_ELEMENT_BUFFER); glfwSwapBuffers(win); } - NFD_Quit(); curl_cleanup(&stat); nk_glfw3_shutdown(&glfw); glfwTerminate(); diff --git a/src/ui.c b/src/ui.c index 7f1dc52..da6fd1b 100644 --- a/src/ui.c +++ b/src/ui.c @@ -5,7 +5,7 @@ #include #include "nuklear.h" -#include +#include "tinyfiledialogs.h" #include "constants.h" #include "logger.h" @@ -13,7 +13,7 @@ #include "ui.h" static nk_size pct; -static nfdchar_t *outPath; +static char *outPath; void load_ui(struct ui_struct *ui) { static char text[USHRT_MAX], box_buffer[UINT16_MAX], status_string[UCHAR_MAX]; @@ -52,14 +52,10 @@ void load_ui(struct ui_struct *ui) { // Clear logger text clear_log(); - nfdresult_t result = NFD_PickFolder(&outPath, ""); - if (result == NFD_OKAY) { - DEBUG_PRINT("[NFD] outPath: %s\n", outPath); - } else if (result == NFD_ERROR) { - LOG("NFD", "Error: %s\n", NFD_GetError()); - } + outPath = tinyfd_selectFolderDialog("Pick a download folder: ", NULL); if (outPath) { + DEBUG_PRINT("tinyfd gets outPath: %s\n", outPath); append_log("Got URL: %s\n", text); add_url(text, outPath, NULL, NULL); } else { -- cgit v1.2.3