diff options
-rw-r--r-- | src/main.c | 7 | ||||
-rw-r--r-- | src/ui.c | 12 | ||||
-rw-r--r-- | xmake.lua | 67 |
3 files changed, 31 insertions, 55 deletions
@@ -1,7 +1,6 @@ #include <GL/glew.h> #include <GLFW/glfw3.h> #include <curl/curl.h> -#include <nfd.h> #include <stdio.h> #include <stdlib.h> @@ -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(); @@ -5,7 +5,7 @@ #include <string.h> #include "nuklear.h" -#include <nfd.h> +#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 { @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release", "mode.releasedbg", "mode.minsizerel") -add_requires("nuklear", "nuklear_glfw_gl3", "nuklear_fonts", "glew", "glfw", "nativefiledialog-extended", +add_requires("nuklear", "nuklear_glfw_gl3", "nuklear_fonts", "glew", "glfw", "tinyfiledialogs", "c11threads", "pcre2", "cjson") add_requires("libcurl", { configs = { zlib = true } }) @@ -17,60 +17,45 @@ set_languages("c11") if is_mode("debug") then add_defines("DEBUG") end -add_packages("nuklear", "nuklear_glfw_gl3", "nuklear_fonts", "glew", "glfw", "libcurl", "nativefiledialog-extended", +add_packages("nuklear", "nuklear_glfw_gl3", "nuklear_fonts", "glew", "glfw", "libcurl", "tinyfiledialogs", "c11threads", "pcre2", "cjson") -package("nativefiledialog-extended") +package("tinyfiledialogs") -set_homepage("https://github.com/btzy/nativefiledialog-extended") -set_description( - "Cross platform (Windows, Mac, Linux) native file dialog library with C and C++ bindings, based on mlabbe/nativefiledialog.") +set_homepage("https://sourceforge.net/projects/tinyfiledialogs/") +set_description("Native dialog library for WINDOWS MAC OSX GTK+ QT CONSOLE") +set_license("zlib") -add_urls("https://github.com/btzy/nativefiledialog-extended/archive/refs/tags/$(version).zip", - "https://github.com/btzy/nativefiledialog-extended.git") -add_versions("v1.1.0", "5827d17b6bddc8881406013f419c534e8459b38f34c2f266d9c1da8a7a7464bc") +add_urls("https://git.code.sf.net/p/tinyfiledialogs/code.git") -add_configs("portal", { description = "Use xdg-desktop-portal instead of GTK.", default = true, type = "boolean" }) -if is_plat("windows") then - add_configs("shared", { description = "Build shared library.", default = false, type = "boolean", readonly = true }) +if is_plat("windows", "mingw") then + add_syslinks("comdlg32", "ole32", "user32", "shell32") end - -add_deps("cmake") -if is_plat("windows") or is_plat("mingw") then - add_syslinks("shell32", "ole32", "uuid") -elseif is_plat("macosx") then - add_frameworks("AppKit", "UniformTypeIdentifiers") -end -on_load("linux", function(package) - if package:config("portal") then - package:add("deps", "dbus") - else - package:add("deps", "gtk+3") - end -end) - -on_install("windows", "macosx", "linux", "mingw", function(package) - local configs = { "-DNFD_BUILD_TESTS=OFF" } - table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) - table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) - table.insert(configs, "-DNFD_PORTAL=" .. (package:config("portal") and "ON" or "OFF")) - import("package.tools.cmake").install(package, configs) +on_install("windows", "mingw", "linux", "macosx", function(package) + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + target("tinyfiledialogs") + set_kind("static") + add_files("tinyfiledialogs.c") + add_headerfiles("tinyfiledialogs.h") + ]]) + import("package.tools.xmake").install(package) end) on_test(function(package) - assert(package:check_cxxsnippets({ + assert(package:check_csnippets({ test = [[ + #include <stdio.h> + #include <string.h> + #include "tinyfiledialogs.h" void test() { - NFD_Init(); - nfdchar_t *outPath = NULL; - nfdfilteritem_t filterItem[2] = {{"Source code", "c,cpp,cc"}, {"Headers", "h,hpp"}}; - nfdresult_t result = NFD_OpenDialog(&outPath, filterItem, 2, NULL); - NFD_Quit(); + char const * lWillBeGraphicMode; + lWillBeGraphicMode = tinyfd_inputBox("tinyfd_query", NULL, NULL); } ]] - }, { includes = "nfd.h" })) + })) end) package("c11threads") @@ -120,7 +105,7 @@ end) package("nuklear_fonts") add_urls( -"https://gist.github.com/135e2/656614a4a86cf6f8e9aea9f0de850634/archive/8d1dc2a079cef20d97acbc2a9874b1b77b25070b.zip") + "https://gist.github.com/135e2/656614a4a86cf6f8e9aea9f0de850634/archive/8d1dc2a079cef20d97acbc2a9874b1b77b25070b.zip") add_versions("8d1dc2a", "3dedfd45900cf68fed49ee50963c37c59af01c7f8deb327224f710c010565f87") |