Squashed 'deps/nfde/' changes from 28ade5a5c..5786fabce

5786fabce Release: v1.1.1
cdbc9e9df Build: Update minimum CMake version to 3.5 (#113)
a6d93cb12 CI: Downgrade from C++23 to C++20 on Ubuntu (#116)
f4bf38915 CI: Remove CircleCI config file (#114)
75cbdf819 Build: Add support for building shared libraries on Windows (#109)
800f58283 Release: v1.1.0
210ae0e76 Portal: Support defaultPath for OpenDialog, OpenDialogMultiple, and PickFolder (#108)
dbd7139b4 Build: Generate and install CMake config (#100)
1fde8a5aa CI: Update MacOS 10.15 to MacOS 11 (#101)
06a5c1f0a Release: v1.0.3
ae6718b68 Portal: Make `PickFolder()` check that portal interface version is >=3 (#94)
08216013f Portal: Support formatted error messages using sprintf() (#97)
da81bb077 README: Remove untested portal warning and link current_folder PR (#96)
2b55a1f83 CI: Upgrade Ubuntu 18.04 to Ubuntu 20.04 (#95)
7909f55d9 Release: v1.0.2
d1b80e3a6 MacOS: Add NFD_ClearError() definition (#88)
44e63d5e5 Portal: Add `getrandom` fallback for old versions of GLIBC (#86)
43fe9cf95 Build: Use XXX_LINK_LIBRARIES for linking to support *BSD (#85)
dd46d2a05 ClangFormat: Force ClangFormat 13 for now (#84)
699bb6f82 Build: Set target_include_directories correctly when NFDe is added as a subdirectory (#83)
6efc82407 Release: v1.0.1
74923e7c0 README: Add missing Windows shell32.lib dependency
31df8e30c README: Update NFD_BUILD_TESTS and add NFD_INSTALL flags (#78)
dee61e555 Add NFD_INSTALL option + disable install when in subproject (#77)
e018ec82b Option to generate shared library & use GNUInstallDirs (#76)
d4df2b6ad README: Add NFD_USE_ALLOWEDCONTENTTYPES_IF_AVAILABLE flag
6967d28b0 MacOS: Perform CMake check if allowedContentTypes will be used
f397884eb MacOS: Rename flag to NFD_USE_ALLOWEDCONTENTTYPES_IF_AVAILABLE
89a67f8a5 MacOS: Add CMake flag to avoid using and linking the UniformTypeIdentifiers framework (#72)
331159281 Portal: Don't automatically append file extension in SaveDialog()
008da08d0 Portal: Decode returned URIs
c886650bd README: Update MacOS quirk
eb465a366 Build: Choose latest C++ version based on CMake version
957cf8b0a CI: Build MacOS 10.15 and name things more properly
ff7c3e7cb MacOS:  Remove runtime version check and use deployment target version instead
800060ddb Portal: Fix typo in error messages
aa1debf5e README: Add dark mode images
b0e3db8b1 README: Mention the wiki
2f5732c12 GitHub CI: Fix Linux artefact naming
31f8a5c80 CI: Add stricter C compiler flags
6aba31f38 Circle CI: Initial config
70c11d4d0 MacOS: Use allowedContentTypes on >=12.0 instead of allowedFileTypes

git-subtree-dir: deps/nfde
git-subtree-split: 5786fabceeaee4d892f3c7a16b243796244cdddc
This commit is contained in:
2024-05-31 19:29:33 -05:00
parent 004534c8e7
commit 5461f6700d
7 changed files with 568 additions and 199 deletions
+24 -10
View File
@@ -43,6 +43,8 @@ Features added in Native File Dialog Extended:
There is also significant code refractoring, especially for the Windows implementation.
The [wiki](https://github.com/btzy/nativefiledialog-extended/wiki) keeps track of known language bindings and known popular projects that depend on this library.
# Basic Usage
```C
@@ -84,9 +86,12 @@ If you are using a platform abstraction framework such as SDL or GLFW, also see
# Screenshots #
![Windows 10](screens/open_win10.png?raw=true)
![MacOS 10.13](screens/open_macos_11.0.png?raw=true)
![GTK3 on Ubuntu 20.04](screens/open_gtk3.png?raw=true)
![Windows 10](screens/open_win10.png?raw=true#gh-light-mode-only)
![Windows 10](screens/open_win10_dark.png?raw=true#gh-dark-mode-only)
![MacOS 10.13](screens/open_macos_11.0.png?raw=true#gh-light-mode-only)
![MacOS 10.13](screens/open_macos_11.0_dark.png?raw=true#gh-dark-mode-only)
![GTK3 on Ubuntu 20.04](screens/open_gtk3.png?raw=true#gh-light-mode-only)
![GTK3 on Ubuntu 20.04](screens/open_gtk3_dark.png?raw=true#gh-dark-mode-only)
# Building
@@ -99,6 +104,9 @@ target_link_libraries(MyProgram PRIVATE nfd)
```
Make sure that you also have the needed [dependencies](#dependencies).
When included as a subproject, sample programs are not built and the install target is disabled by default.
Add `-DNFD_BUILD_TESTS=ON` to build sample programs and `-DNFD_INSTALL=ON` to enable the install target.
## Standalone Library
If you want to build the standalone static library,
execute the following commands (starting from the project root directory):
@@ -114,8 +122,8 @@ and build the project (in release mode) there.
If you are developing NFDe, you may want to do `-DCMAKE_BUILD_TYPE=Debug`
to build a debug version of the library instead.
If you want to build the sample programs,
add `-DNFD_BUILD_TESTS=ON` (sample programs are not built by default).
When building as a standalone library, sample programs are built and the install target is enabled by default.
Add `-DNFD_BUILD_TESTS=OFF` to disable building sample programs and `-DNFD_INSTALL=OFF` to disable the install target.
On Linux, if you want to use the Flatpak desktop portal instead of GTK, add `-DNFD_PORTAL=ON`. (Otherwise, GTK will be used.) See the "Usage" section below for more information.
@@ -148,10 +156,10 @@ Make sure `libgtk-3-dev` is installed on your system.
Make sure `libdbus-1-dev` is installed on your system.
### MacOS
On MacOS, add `AppKit` to the list of frameworks.
On MacOS, add `AppKit` and `UniformTypeIdentifiers` to the list of frameworks.
### Windows
On Windows (both MSVC and MinGW), ensure you are building against `ole32.lib` and `uuid.lib`.
On Windows (both MSVC and MinGW), ensure you are building against `ole32.lib`, `uuid.lib`, and `shell32.lib`.
# Usage
@@ -244,11 +252,11 @@ SDL_Quit(); // Then deinitialize SDL2
On Linux, you can use the portal implementation instead of GTK, which will open the "native" file chooser selected by the OS or customized by the user. The user must have `xdg-desktop-portal` and a suitable backend installed (this comes pre-installed with most common desktop distros), otherwise `NFD_ERROR` will be returned.
The portal implementation is much less battle-tested than the GTK implementation. There may be bugs — please report them on the issue tracker.
To use the portal implementation, add `-DNFD_PORTAL=ON` to the build command.
*Note: Setting a default path is not supported by the portal implementation, and any default path passed to NFDe will be ignored. This is a limitation of the portal API, so there is no way NFDe can work around it.*
*Note: Setting a default path is not supported by the portal implementation, and any default path passed to NFDe will be ignored. This is a limitation of the portal API, so there is no way NFDe can work around it. If this feature is something you desire, please show your interest on https://github.com/flatpak/xdg-desktop-portal/pull/874.*
*Note 2: The folder picker is only supported on org.freedesktop.portal.FileChooser interface version >= 3, which corresponds to xdg-desktop-portal version >= 1.7.1. `NFD_PickFolder()` will query the interface version at runtime, and return `NFD_ERROR` if the version is too low.
### What is a portal?
@@ -256,6 +264,12 @@ Unlike Windows and MacOS, Linux does not have a file chooser baked into the oper
Flatpak was introduced in 2015, and with it came a standardized interface to open a file chooser. Applications using this interface did not need to come with a file chooser, and could use the one provided by Flatpak. This interface became known as the desktop portal, and its use expanded to non-Flatpak applications. Now, most major desktop Linux distros come with the desktop portal installed, with file choosers that fit the theme of the distro. Users can also install a different portal backend if desired. There are currently two known backends: GTK and KDE. (XFCE does not currently seem to have a portal backend.)
## Platform-specific Quirks
### MacOS
- If the MacOS deployment target is ≥ 11.0, the [allowedContentTypes](https://developer.apple.com/documentation/appkit/nssavepanel/3566857-allowedcontenttypes?language=objc) property of NSSavePanel is used instead of the deprecated [allowedFileTypes](https://developer.apple.com/documentation/appkit/nssavepanel/1534419-allowedfiletypes?language=objc) property for file filters. Thus, if you are filtering by a custom file extension specific to your application, you will need to define the data type in your `Info.plist` file as per the [Apple documentation](https://developer.apple.com/documentation/uniformtypeidentifiers/defining_file_and_data_types_for_your_app). (It is possible to force NFDe to use allowedFileTypes by adding `-DNFD_USE_ALLOWEDCONTENTTYPES_IF_AVAILABLE=OFF` to your CMake build command, but this is not recommended. If you need to support older MacOS versions, you should be setting the correct deployment target instead.)
# Known Limitations #
- No support for Windows XP's legacy dialogs such as `GetOpenFileName`. (There are no plans to support this; you shouldn't be still using Windows XP anyway.)