* src/support/os_unix.C (canAutoOpenFile, autoOpenFile): add support for Mac

OS X.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@13960 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2006-05-29 16:41:31 +00:00
parent 7217551b45
commit 48f0a4b681
3 changed files with 64 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2006-05-29 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* os_unix.C (canAutoOpenFile, autoOpenFile): add support for Mac
OS X.
2006-05-16 Bo Peng <ben.bob@gmail.com>
* Makefile.am: under win32, link against shlwapi.dll.

View File

@ -14,6 +14,10 @@
#include "support/os.h"
#ifdef __APPLE__
#include <Carbon/Carbon.h>
#endif
using std::string;
@ -115,19 +119,69 @@ char path_separator()
void cygwin_path_fix(bool)
{}
bool canAutoOpenFile(string const & /*ext*/, auto_open_mode const /*mode*/)
bool canAutoOpenFile(string const & ext, auto_open_mode const mode)
{
#ifdef __APPLE__
// Reference: http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/
CFStringRef cfs_ext = CFStringCreateWithBytes(kCFAllocatorDefault,
(UInt8 *) ext.c_str(), ext.length(),
kCFStringEncodingISOLatin1, false);
LSRolesMask role = (mode == VIEW) ? kLSRolesViewer : kLSRolesEditor;
FSRef outAppRef;
OSStatus status =
LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator,
cfs_ext, role, &outAppRef, NULL);
CFRelease(cfs_ext);
return status != kLSApplicationNotFoundErr;
#else
// silence compiler warnings
(void)ext;
(void)mode;
// currently, no default viewer is tried for non-windows system
// support for KDE/Gnome/Macintosh may be added later
return false;
#endif
}
bool autoOpenFile(string const & /*filename*/, auto_open_mode const /*mode*/)
bool autoOpenFile(string const & filename, auto_open_mode const mode)
{
#ifdef __APPLE__
// Reference: http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/
FSRef fileref;
OSStatus status =
FSPathMakeRef((UInt8 *) filename.c_str(), &fileref, NULL);
if (status != 0)
return false;
LSRolesMask role = (mode == VIEW) ? kLSRolesViewer : kLSRolesEditor;
FSRef outAppRef;
status = LSGetApplicationForItem(&fileref, role, &outAppRef, NULL);
if (status == kLSApplicationNotFoundErr)
return false;
LSLaunchFSRefSpec inLaunchSpec;
inLaunchSpec.appRef = &outAppRef;
inLaunchSpec.numDocs = 1;
inLaunchSpec.itemRefs = &fileref;
inLaunchSpec.passThruParams = NULL;
inLaunchSpec.launchFlags = kLSLaunchDefaults;
inLaunchSpec.asyncRefCon = NULL;
status = LSOpenFromRefSpec(&inLaunchSpec, NULL);
return status != kLSApplicationNotFoundErr;
#else
// silence compiler warnings
(void)filename;
(void)mode;
// currently, no default viewer is tried for non-windows system
// support for KDE/Gnome/Macintosh may be added later
return false;
#endif
}
} // namespace os

View File

@ -19,6 +19,9 @@ What's new
** Updates
- LyX now automatically uses file viewers and editors set at OS level
[Windows and Mac OS X only].
- Update Hungarian localization of the interface.
- Update translations of documentation for German (all) and Hungarian
@ -82,9 +85,6 @@ What's new
- Don't jump back to previous cursor position when trying to click on
an inset (bug 2526).
- LyX now automatically uses file viewers and editors set at OS level
[windows only].
- Automatically use fonts in the fonts/ subdirectory of LyX support
directory in windows.