Coder Social home page Coder Social logo

pawplo / nativefiledialog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mlabbe/nativefiledialog

0.0 2.0 0.0 432 KB

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

License: zlib License

Makefile 59.13% Lua 4.01% Python 3.20% C 13.36% Objective-C 5.33% C++ 14.97%

nativefiledialog's Introduction

Native File Dialog

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 modern IFileDialog on Windows.
  • Support for non-deprecated Cocoa APIs on OS X.
  • GTK+3 dialog on Linux.
  • Tested, works alongside http://www.libsdl.org on all platforms, for the game developers out there.

Example Usage

#include <nfd.h>
#include <stdio.h>
#include <stdlib.h>

int 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

Changelog

The current version is 1.1.1

release what's new date
1.0.0 initial oct 2014
1.1.0 premake5; scons deprecated aug 2016
1.1.1 mingw support, build fixes aug 2016
1.1.2 test_pickfolder() added aug 2016

Building

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

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

Previously, NFD used SCons to build. It still works, but is now deprecated; updates to it are discouraged. Opt to use the native build system where possible.

nfd.a will be built for release builds, and nfd_d.a will be built for debug builds.

Makefiles

The makefile offers four options, with release_x64 as the default.

make config=release_x86
make config=release_x64
make config=debug_x86
make config=debug_x64

Compiling Your Programs

  1. Add src/include to your include search path.
  2. Add nfd.lib or nfd_d.lib to the list of list of static libraries to link against (for release or debug, respectively).
  3. Add build/<debug|release>/<arch> 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.

After compiling, build/bin contains compiled test programs.

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

See test_opendialogmultiple.c.

Known Limitations

I accept quality code patches, or will resolve these and other matters through support. See submitting pull requests for details.

  • No support for Windows XP's legacy dialogs such as GetOpenFileName.
  • No support for file filter names -- ex: "Image Files" (*.png, *.jpg). Nameless filters are supported, however.
  • 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.

Copyright and Credit

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

Native File Dialog by Michael Labbe [email protected]

Tomasz Konojacki for microutf8

Denis Kolodin for mingw support.

Support

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

Contact Frogtoss Games.

nativefiledialog's People

Contributors

mlabbe avatar therustmonk avatar jgranick avatar mrsapps avatar

Watchers

Paweł Płóciennik avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.