Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
mlabbe committed Sep 30, 2019
2 parents b58794c + 244e256 commit 67345b8
Show file tree
Hide file tree
Showing 44 changed files with 1,098 additions and 1,624 deletions.
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Features:
- Optional Zenity support on Linux to avoid linking GTK.
- Tested, works alongside [http://www.libsdl.org](SDL2) on all platforms, for the game developers out there.

**Note:** I am considering deprecating mingw support on Windows. Please contribute your thoughts at [this issue](https://github.com/mlabbe/nativefiledialog/issues/68).

# Example Usage #

```C
Expand Down Expand Up @@ -49,7 +47,7 @@ int main( void )
}
```
See [NFD.h](src/include/nfd.h) for more options.
See self-documenting API [NFD.h](src/include/nfd.h) for more options.
# Screenshots #
Expand All @@ -59,33 +57,40 @@ See [NFD.h](src/include/nfd.h) for more options.
## 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.
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
1.1.3 | zenity linux backend added | nov 2017
1.1.3 | fix char type in decls | nov 2017
<i></i> | fix char type in decls | nov 2017
1.1.4 | fix win32 memleaks | dec 2018
1.1.4 | improve win32 errorhandling | dec 2018
1.1.4 | macos fix focus bug | dec 2018
<i></i> | improve win32 errorhandling | dec 2018
<i></i> | macos fix focus bug | dec 2018
1.1.5 | win32 fix com reinitialize | aug 2019
1.1.6 | fix osx filter bug | aug 2019
<i></i> | remove deprecated scons | aug 2019
<i></i> | fix mingw compilation | aug 2019
<i></i> | -Wextra warning cleanup | aug 2019
## Building ##
NFD uses [Premake5](https://premake.github.io/download.html) 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](docs/build.md) 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.
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, and `nfd_d.a` will be built for debug builds.
### Makefiles ###
The makefile offers five options, with `release_x64` as the default.
The makefile offers up to four options, with `release_x64` as the default.
make config=release_x86
make config=release_x64
Expand All @@ -99,6 +104,7 @@ The makefile offers five options, with `release_x64` as the default.
3. Add `build/<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 of `pkg-config --cflags --libs gtk+-3.0`.
Expand All @@ -108,16 +114,18 @@ On Linux, you have the option of compiling and linking against GTK. If you use
Alternatively, you can use the Zenity backend by running the Makefile in `build/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, add `AppKit` to the list of frameworks.
#### Windows ####
On Windows, ensure you are building against `comctl32.lib`.
On Windows, ensure you are linking against `comctl32.lib`.
## Usage ##
See `NFD.h` for API calls. See `tests/*.c` for example code.
After compiling, `build/bin` contains compiled test programs.
After compiling, `build/bin` contains compiled test programs. The appropriate subdirectory under `build/lib` contains the built library.
## File Filter Syntax ##
Expand All @@ -144,10 +152,12 @@ See [test_opendialogmultiple.c](test/test_opendialogmultiple.c).
# Known Limitations #
I accept quality code patches, or will resolve these and other matters through support. See [submitting pull requests](docs/submitting_pull_requests.md) for details.
I accept quality code patches, or will resolve these and other matters through support. See [contributing](docs/contributing.md) 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.
- 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 #
Expand Down
2 changes: 1 addition & 1 deletion build/gmake_linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ help:
@echo " test_opendialogmultiple"
@echo " test_savedialog"
@echo ""
@echo "For more information, see http://industriousone.com/premake/quick-start"
@echo "For more information, see https://github.com/premake/premake-core/wiki"
65 changes: 31 additions & 34 deletions build/gmake_linux/nfd.make
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ ifeq ($(config),release_x64)
INCLUDES += -I../../src/include
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -Wall -Wextra -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -Wall -Wextra -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
Expand All @@ -46,8 +46,8 @@ ifeq ($(config),release_x86)
INCLUDES += -I../../src/include
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O2 -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O2 -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O2 -Wall -Wextra -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O2 -Wall -Wextra -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
Expand All @@ -73,8 +73,8 @@ ifeq ($(config),debug_x64)
INCLUDES += -I../../src/include
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -Wextra -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -Wextra -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
Expand All @@ -100,8 +100,8 @@ ifeq ($(config),debug_x86)
INCLUDES += -I../../src/include
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -g -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g -Wall -Wextra -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -g -Wall -Wextra -fno-exceptions `pkg-config --cflags gtk+-3.0`
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
Expand All @@ -126,23 +126,33 @@ RESOURCES := \

CUSTOMFILES := \

SHELLTYPE := msdos
ifeq (,$(ComSpec)$(COMSPEC))
SHELLTYPE := posix
endif
ifeq (/bin,$(findstring /bin,$(SHELL)))
SHELLTYPE := posix
SHELLTYPE := posix
ifeq (.exe,$(findstring .exe,$(ComSpec)))
SHELLTYPE := msdos
endif

$(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES)
$(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES) | $(TARGETDIR)
@echo Linking nfd
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)

$(CUSTOMFILES): | $(OBJDIR)

$(TARGETDIR):
@echo Creating $(TARGETDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(TARGETDIR)
else
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
endif
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)

$(OBJDIR):
@echo Creating $(OBJDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif

clean:
@echo Cleaning nfd
Expand All @@ -161,32 +171,19 @@ prelink:
$(PRELINKCMDS)

ifneq (,$(PCH))
$(OBJECTS): $(GCH) $(PCH)
$(GCH): $(PCH)
$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR)
$(GCH): $(PCH) | $(OBJDIR)
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
else
$(OBJECTS): | $(OBJDIR)
endif

$(OBJDIR)/nfd_common.o: ../../src/nfd_common.c
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/nfd_gtk.o: ../../src/nfd_gtk.c
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"

-include $(OBJECTS:%.o=%.d)
Expand Down
52 changes: 27 additions & 25 deletions build/gmake_linux/test_opendialog.make
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ifeq ($(config),release_x64)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += ../lib/Release/x64/libnfd.a
LDDEPS += ../lib/Release/x64/libnfd.a
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Release/x64 -m64 -s -lnfd `pkg-config --libs gtk+-3.0`
ALL_LDFLAGS += $(LDFLAGS) -L../lib/Release/x64 -L/usr/lib64 -m64 -s -lnfd `pkg-config --libs gtk+-3.0`
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
Expand All @@ -51,7 +51,7 @@ ifeq ($(config),release_x86)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += ../lib/Release/x86/libnfd.a
LDDEPS += ../lib/Release/x86/libnfd.a
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Release/x86 -m32 -s -lnfd `pkg-config --libs gtk+-3.0`
ALL_LDFLAGS += $(LDFLAGS) -L../lib/Release/x86 -L/usr/lib32 -m32 -s -lnfd `pkg-config --libs gtk+-3.0`
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
Expand All @@ -78,7 +78,7 @@ ifeq ($(config),debug_x64)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lnfd_d
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Debug/x64 -m64 -lnfd_d `pkg-config --libs gtk+-3.0`
ALL_LDFLAGS += $(LDFLAGS) -L../lib/Debug/x64 -L/usr/lib64 -m64 -lnfd_d `pkg-config --libs gtk+-3.0`
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
Expand All @@ -105,7 +105,7 @@ ifeq ($(config),debug_x86)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lnfd_d
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Debug/x86 -m32 -lnfd_d `pkg-config --libs gtk+-3.0`
ALL_LDFLAGS += $(LDFLAGS) -L../lib/Debug/x86 -L/usr/lib32 -m32 -lnfd_d `pkg-config --libs gtk+-3.0`
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
Expand All @@ -125,23 +125,33 @@ RESOURCES := \

CUSTOMFILES := \

SHELLTYPE := msdos
ifeq (,$(ComSpec)$(COMSPEC))
SHELLTYPE := posix
endif
ifeq (/bin,$(findstring /bin,$(SHELL)))
SHELLTYPE := posix
SHELLTYPE := posix
ifeq (.exe,$(findstring .exe,$(ComSpec)))
SHELLTYPE := msdos
endif

$(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES)
$(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES) | $(TARGETDIR)
@echo Linking test_opendialog
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)

$(CUSTOMFILES): | $(OBJDIR)

$(TARGETDIR):
@echo Creating $(TARGETDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(TARGETDIR)
else
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
endif
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)

$(OBJDIR):
@echo Creating $(OBJDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif

clean:
@echo Cleaning test_opendialog
Expand All @@ -160,24 +170,16 @@ prelink:
$(PRELINKCMDS)

ifneq (,$(PCH))
$(OBJECTS): $(GCH) $(PCH)
$(GCH): $(PCH)
$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR)
$(GCH): $(PCH) | $(OBJDIR)
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
else
$(OBJECTS): | $(OBJDIR)
endif

$(OBJDIR)/test_opendialog.o: ../../test/test_opendialog.c
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"

-include $(OBJECTS:%.o=%.d)
Expand Down
Loading

0 comments on commit 67345b8

Please sign in to comment.