From 155e099f4a67f1031a1a77e9eba9789b74c15a44 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Tue, 13 Nov 2012 13:03:20 +0000 Subject: [PATCH] Documented how to make a Mac OS FLTK application launchable by dropping files on its icon. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9718 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- README.OSX.txt | 27 +++++++++++++++++++++++++-- ide/Xcode3/plists/editor-Info.plist | 23 ++++++++++++++++++++--- ide/Xcode4/plists/editor-Info.plist | 23 ++++++++++++++++++++--- test/editor.cxx | 8 +++++++- 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/README.OSX.txt b/README.OSX.txt index 16c36b6e9..9d05199dd 100644 --- a/README.OSX.txt +++ b/README.OSX.txt @@ -33,7 +33,8 @@ README.OSX.txt - 2010-10-23 - Building FLTK under Apple OS X 4.5 Testing FLTK 4.6 Uninstalling previous versions of FLTK 4.7 Installing FLTK - 5 DOCUMENT HISTORY + 5 MAKE AN APPLICATION LAUNCHABLE BY DROPPING FILES ON ITS ICON + 6 DOCUMENT HISTORY 1 INTRODUCTION @@ -411,7 +412,28 @@ tools: (TODO: 4.8 Installing Little Helpers) (TODO: 4.9 Creating new Projects) - 5 DOCUMENT HISTORY + + + 5 MAKE AN APPLICATION LAUNCHABLE BY DROPPING FILES ON ITS ICON +================================================================= +- Prepare an Info.plist file for your application derived from file +ide/Xcode4/plists/editor-Info.plist which allows any file to be dropped +on the application icon. +You can edit this file in Xcode and change +Document types/Item 0/CFBundleTypeExtensions/Item 0 +from the current "*" to the desired file extension. Use several items to declare +several extensions. + +- Call fl_open_callback() at the beginning of your main() function that +sets what function will be called when a file is dropped on the application icon. + +- In Xcode, set the "Info.plist File" build setting of your target application +to the Info.plist file you have prepared. + +- Rebuild your application. + + + 6 DOCUMENT HISTORY ===================== Oct 29 2010 - matt: removed warnings @@ -420,3 +442,4 @@ Dec 19 2010 - Manolo: corrected typos Dec 29 2010 - Manolo: removed reference to AudioToolbox.framework that's no longer needed Feb 24 2011 - Manolo: architecture flags are not propagated to the fltk-config script. Apr 17 2012 - matt: added Xcode4 documentation +Nov 13 2012 - Manolo: added "MAKE AN APPLICATION LAUNCHABLE BY DROPPING FILES ON ITS ICON" diff --git a/ide/Xcode3/plists/editor-Info.plist b/ide/Xcode3/plists/editor-Info.plist index 3e59bff2f..d49c55592 100644 --- a/ide/Xcode3/plists/editor-Info.plist +++ b/ide/Xcode3/plists/editor-Info.plist @@ -4,8 +4,27 @@ CFBundleDevelopmentRegion English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + * + + CFBundleTypeName + AllFiles + CFBundleTypeRole + Editor + LSTypeIsPackage + + NSPersistentStoreTypeKey + XML + + CFBundleExecutable ${EXECUTABLE_NAME} + CFBundleGetInfoString + Part of the FLTK library. Please visit www.fltk.org. CFBundleIdentifier org.fltk.editor CFBundleInfoDictionaryVersion @@ -18,7 +37,5 @@ 1.0 NSHumanReadableCopyright Copyright 1998-2010 by Bill Spitzak and others. - CFBundleGetInfoString - Part of the FLTK library. Please visit www.fltk.org. - + diff --git a/ide/Xcode4/plists/editor-Info.plist b/ide/Xcode4/plists/editor-Info.plist index 3e59bff2f..d49c55592 100644 --- a/ide/Xcode4/plists/editor-Info.plist +++ b/ide/Xcode4/plists/editor-Info.plist @@ -4,8 +4,27 @@ CFBundleDevelopmentRegion English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + * + + CFBundleTypeName + AllFiles + CFBundleTypeRole + Editor + LSTypeIsPackage + + NSPersistentStoreTypeKey + XML + + CFBundleExecutable ${EXECUTABLE_NAME} + CFBundleGetInfoString + Part of the FLTK library. Please visit www.fltk.org. CFBundleIdentifier org.fltk.editor CFBundleInfoDictionaryVersion @@ -18,7 +37,5 @@ 1.0 NSHumanReadableCopyright Copyright 1998-2010 by Bill Spitzak and others. - CFBundleGetInfoString - Part of the FLTK library. Please visit www.fltk.org. - + diff --git a/test/editor.cxx b/test/editor.cxx index 3e38a5022..1c9db095f 100644 --- a/test/editor.cxx +++ b/test/editor.cxx @@ -789,16 +789,22 @@ Fl_Window* new_view() { return w; } +void cb(const char *fname) { + load_file(fname, -1); +} + int main(int argc, char **argv) { textbuf = new Fl_Text_Buffer; //textbuf->transcoding_warning_action = NULL; style_init(); + fl_open_callback(cb); Fl_Window* window = new_view(); window->show(1, argv); - +#ifndef __APPLE__ if (argc > 1) load_file(argv[1], -1); +#endif return Fl::run(); }