🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
4.5 KiB

  1. # Native File Dialog #
  2. A tiny, neat C library that portably invokes native file open and save dialogs. Write dialog code once and have it pop up native dialogs on all supported platforms. Avoid linking large dependencies like wxWidgets and qt.
  3. Features:
  4. - Lean C API, static library -- no ObjC, no C++, no STL.
  5. - Zlib licensed.
  6. - Consistent UTF-8 support on all platforms.
  7. - Simple universal file filter syntax.
  8. - Paid support available.
  9. - Multiple file selection support.
  10. - 64-bit and 32-bit friendly.
  11. - GCC, Clang and Visual Studio supported.
  12. - No third party dependencies.
  13. - Support for Vista's modern `IFileDialog` on Windows.
  14. - Support for non-deprecated Cocoa APIs on OS X.
  15. - GTK+3 dialog on Linux.
  16. - Tested, works alongside [http://www.libsdl.org](SDL2) on all platforms, for the game developers out there.
  17. # Example Usage #
  18. ```C
  19. #include <nfd.h>
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. int main( void )
  23. {
  24. nfdchar_t *outPath = NULL;
  25. nfdresult_t result = NFD_OpenDialog( NULL, NULL, &outPath );
  26. if ( result == NFD_OKAY ) {
  27. puts("Success!");
  28. puts(outPath);
  29. free(outPath);
  30. }
  31. else if ( result == NFD_CANCEL ) {
  32. puts("User pressed cancel.");
  33. }
  34. else {
  35. printf("Error: %s\n", NFD_GetError() );
  36. }
  37. return 0;
  38. }
  39. ```
  40. See [NFD.h](src/include/nfd.h) for more options.
  41. # Screenshots #
  42. ![Windows 8 rendering an IFileOpenDialog](screens/open_win8.png?raw=true)
  43. ![GTK3 on Linux](screens/open_gtk3.png?raw=true)
  44. ![Cocoa on Yosemite](screens/open_cocoa.png?raw=true)
  45. ## Building ##
  46. NFD uses [SCons](http://www.scons.org) for cross-platform builds. After installing SCons, build it with:
  47. cd src
  48. scons debug=[0,1]
  49. Alternatively, you can avoid Scons by just including NFD files to your existing project:
  50. 1. Add all header files in `src/` and `src/include` to your project.
  51. 2. Add `src/include` to your include search path or copy it into your existing search path.
  52. 3. Add `src/nfd_common.c` to your project.
  53. 4. Add `src/nfd_<platform>` to your project, where `<platform>` is the NFD backend for the platform you are fixing to build.
  54. 5. On Visual Studio, define `_CRT_SECURE_NO_WARNINGS` to avoid warnings.
  55. ### Compiling Your Programs ###
  56. 1. Add `src/include` to your include search path.
  57. 2. Add `nfd.lib` to the list of list of static libraries to link against.
  58. 3. Add `src/` to the library search path.
  59. On Linux, you must compile and link against GTK+. Recommend use of `pkg-config --cflags --libs gtk+-3.0`.
  60. On Mac OS X, add `AppKit` to the list of frameworks.
  61. On Windows, ensure you are building against `comctl32.lib`.
  62. ## Usage ##
  63. See `NFD.h` for API calls. See `tests/*.c` for example code.
  64. See `tests/SConstruct` for a working build script that compiles on all platforms.
  65. ## File Filter Syntax ##
  66. There is a form of file filtering in every file dialog, but no consistent means of supporting it. NFD provides support for filtering files by groups of extensions, providing its own descriptions (where applicable) for the extensions.
  67. A wildcard filter is always added to every dialog.
  68. ### Separators ###
  69. - `;` Begin a new filter.
  70. - `,` Add a separate type to the filter.
  71. #### Examples ####
  72. `txt` The default filter is for text files. There is a wildcard option in a dropdown.
  73. `png,jpg;psd` The default filter is for png and jpg files. A second filter is available for psd files. There is a wildcard option in a dropdown.
  74. `NULL` Wildcard only.
  75. ## Iterating Over PathSets ##
  76. See [test_opendialogmultiple.c](test/test_opendialogmultiple.c).
  77. # Known Limitations #
  78. I accept quality code patches, or will resolve these and other matters through support.
  79. - No support for Windows XP's legacy dialogs such as `GetOpenFileName`.
  80. - No support for file filter names -- ex: "Image Files" (*.png, *.jpg). Nameless filters are supported, though.
  81. - No support for selecting folders instead of files.
  82. - On Linux, GTK+ cannot be uninitialized to save memory. Launching a file dialog costs memory. I am open to accepting an alternative `nfd_zenity.c` implementation which uses Zenity and pipes.
  83. # Copyright and Credit #
  84. Copyright &copy; 2014 [Frogtoss Games](http://www.frogtoss.com), Inc.
  85. File [LICENSE](LICENSE) covers all files in this repo.
  86. Native File Dialog by Michael Labbe
  87. <mike@frogtoss.com>
  88. Tomasz Konojacki for [microutf8](http://puszcza.gnu.org.ua/software/microutf8/)
  89. ## Support ##
  90. Directed support for this work is available from the original author under a paid agreement.
  91. [Contact Frogtoss Games](http://www.frogtoss.com/pages/contact.html).