Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A tiny, neat C library that portably invokes native file open and save dialogs.

License

NotificationsYou must be signed in to change notification settings

mlabbe/nativefiledialog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A tiny, neat C library that portably invokes native file open, folder select 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.

Features:

  • Lean C API, static library -- no ObjC, no C++, no STL.
  • Zlib licensed.
  • Consistent UTF-8 support on all platforms.
  • Simple universal file filter syntax.
  • Paid support available.
  • Multiple file selection support.
  • 64-bit and 32-bit friendly.
  • GCC, Clang, Xcode, Mingw and Visual Studio supported.
  • No third party dependencies for building or linking.
  • Support for Vista's modernIFileDialog on Windows.
  • Support for non-deprecated Cocoa APIs on OS X.
  • GTK3 dialog on Linux.
  • Optional Zenity support on Linux to avoid linking GTK.
  • Tested, works alongsidehttp://www.libsdl.org on all platforms, for the game developers out there.

Example Usage

#include<nfd.h>#include<stdio.h>#include<stdlib.h>intmain(void ){nfdchar_t*outPath=NULL;nfdresult_tresult=NFD_OpenDialog(NULL,NULL,&outPath );if (result==NFD_OKAY ) {puts("Success!");puts(outPath);free(outPath);    }elseif (result==NFD_CANCEL ) {puts("User pressed cancel.");    }else {printf("Error: %s\n",NFD_GetError() );    }return0;}

See self-documenting APINFD.h for more options.

Screenshots

Windows rendering a dialogGTK3 on Linux rendering a dialogCocoa on MacOS rendering a dialog

Changelog

  • Major version increments denote API or ABI departure.
  • Minor version increments denote build or trivial departures.
  • Micro version increments just recompile and drop-in.
releasewhat's newdate
1.0.0initialoct 2014
1.1.0premake5; scons deprecatedaug 2016
1.1.1mingw support, build fixesaug 2016
1.1.2test_pickfolder() addedaug 2016
1.1.3zenity linux backend addednov 2017
fix char type in declsnov 2017
1.1.4fix win32 memleaksdec 2018
improve win32 errorhandlingdec 2018
macos fix focus bugdec 2018
1.1.5win32 fix com reinitializeaug 2019
1.1.6fix osx filter bugaug 2019
remove deprecated sconsaug 2019
fix mingw compilationaug 2019
-Wextra warning cleanupaug 2019

Building

NFD usesPremake5 generated Makefiles and IDE project files. The generated project files are checked in underbuild/ so you don't have to download and use Premake in most cases.

If you need to run Premake5 directly, furtherbuild documentation is available.

Previously, NFD used SCons to build. As of 1.1.6, SCons support has been removed entirely.

nfd.a will be built for release builds, andnfd_d.a will be built for debug builds.

Makefiles

The makefile offers up to four options, withrelease_x64 as the default.

make config=release_x86make config=release_x64make config=debug_x86make config=debug_x64

Compiling Your Programs

  1. Addsrc/include to your include search path.
  2. Addnfd.lib ornfd_d.lib to the list of list of static libraries to link against (for release or debug, respectively).
  3. Addbuild/<debug|release>/<arch> to the library search path.

Linux GTK

apt-get libgtk-3-dev installs the gtk dependency for library compilation.

On Linux, you have the option of compiling and linking against GTK. If you use it, the recommended way to compile is to include the arguments ofpkg-config --cflags --libs gtk+-3.0.

Linux Zenity

Alternatively, you can use the Zenity backend by running the Makefile inbuild/gmake_linux_zenity. Zenity runs the dialog in its own address space, but requires the user to have Zenity correctly installed and configured on their system.

MacOS

On Mac OS, addAppKit to the list of frameworks.

Windows

On Windows, ensure you are linking againstcomctl32.lib.

Usage

SeeNFD.h for API calls. Seetests/*.c for example code.

After compiling,build/bin contains compiled test programs. The appropriate subdirectory underbuild/lib contains the built library.

File Filter Syntax

There is a form of file filtering in every file dialog API, 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.

A wildcard filter is always added to every dialog.

Separators

  • ; Begin a new filter.
  • , Add a separate type to the filter.

Examples

txt The default filter is for text files. There is a wildcard option in a dropdown.

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.

NULL Wildcard only.

Iterating Over PathSets

Seetest_opendialogmultiple.c.

Known Limitations

I accept quality code patches, or will resolve these and other matters through support. Seecontributing for details.

  • No support for Windows XP's legacy dialogs such asGetOpenFileName.
  • No support for file filter names -- ex: "Image Files" (*.png, *.jpg). Nameless filters are supported, however.
  • GTK Zenity implementation's process exec error handling does not gracefully handle numerous error cases, choosing to abort rather than cleanup and return.
  • GTK 3 spams one warning per dialog created.

Copyright and Credit

Copyright © 2014-2019Frogtoss Games, Inc.FileLICENSE covers all files in this repo.

Native File Dialog by Michael Labbemike@frogtoss.com

Tomasz Konojacki formicroutf8

Denis Kolodin for mingw support.

Tom Mason for Zenity support.

Support

Directed support for this work is available from the original author under a paid agreement.

Contact Frogtoss Games.

About

A tiny, neat C library that portably invokes native file open and save dialogs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp