native-toolkit/nfd

Name: nfd

Owner: native-toolkit

Description: null

Created: 2015-08-22 19:30:57.0

Updated: 2017-08-14 16:43:24.0

Pushed: 2016-01-08 23:12:46.0

Homepage: null

Size: 17

Language: C++

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Native File Dialog

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.

Features:

Example Usage

lude <nfd.h>
lude <stdio.h>
lude <stdlib.h>

main( void )

nfdchar_t *outPath = NULL;
nfdresult_t result = NFD_OpenDialog( NULL, NULL, &outPath );

if ( result == NFD_OKAY ) {
    puts("Success!");
    puts(outPath);
    free(outPath);
}
else if ( result == NFD_CANCEL ) {
    puts("User pressed cancel.");
}
else {
    printf("Error: %s\n", NFD_GetError() );
}

return 0;

See NFD.h for more options.

Screenshots

Windows 8 rendering an IFileOpenDialog GTK3 on Linux Cocoa on Yosemite

Building

NFD uses SCons for cross-platform builds. After installing SCons, build it with:

cd src
scons debug=[0,1]

Alternatively, you can avoid Scons by just including NFD files to your existing project:

  1. Add all header files in src/ and src/include to your project.
  2. Add src/include to your include search path or copy it into your existing search path.
  3. Add src/nfd_common.c to your project.
  4. Add src/nfd_<platform> to your project, where <platform> is the NFD backend for the platform you are fixing to build.
  5. On Visual Studio, define _CRT_SECURE_NO_WARNINGS to avoid warnings.
Compiling Your Programs
  1. Add src/include to your include search path.
  2. Add nfd.lib to the list of list of static libraries to link against.
  3. Add src/ to the library search path.

On Linux, you must compile and link against GTK+. Recommend use of pkg-config --cflags --libs gtk+-3.0.

On Mac OS X, add AppKit to the list of frameworks.

On Windows, ensure you are building against comctl32.lib.

Usage

See NFD.h for API calls. See tests/*.c for example code.

See tests/SConstruct for a working build script that compiles on all platforms.

File Filter Syntax

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.

A wildcard filter is always added to every dialog.

Separators
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

See test_opendialogmultiple.c.

Known Limitations

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

Copyright and Credit

Copyright © 2014 Frogtoss Games, Inc. File LICENSE covers all files in this repo.

Native File Dialog by Michael Labbe mike@frogtoss.com

Tomasz Konojacki for microutf8

Support

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

Contact Frogtoss Games.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.