added check for OSX' Carbon framework.

2007-05-14  Michael Natterer  <mitch@gimp.org>

	* configure.in: added check for OSX' Carbon framework.

	* libgimpbase/Makefile.am (libgimpbase_2_0_la_LDFLAGS): add
	$(CARBON_LDFLAGS)

	* libgimpbase/gimpenv.c (gimp_user_directory): add Carbon version.

	(find_folder): new Crabon-only utility function.


svn path=/trunk/; revision=22488
This commit is contained in:
Michael Natterer 2007-05-14 16:31:50 +00:00 committed by Michael Natterer
parent 9f72f79d7c
commit 86eac2cca2
4 changed files with 95 additions and 2 deletions

View File

@ -1,3 +1,14 @@
2007-05-14 Michael Natterer <mitch@gimp.org>
* configure.in: added check for OSX' Carbon framework.
* libgimpbase/Makefile.am (libgimpbase_2_0_la_LDFLAGS): add
$(CARBON_LDFLAGS)
* libgimpbase/gimpenv.c (gimp_user_directory): add Carbon version.
(find_folder): new Crabon-only utility function.
2007-05-14 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-transform.c: fixed gtk-doc comment.

View File

@ -1641,6 +1641,24 @@ AC_MSG_RESULT($mac_twain_ok)
AM_CONDITIONAL(HAVE_MAC_TWAIN, test x$mac_twain_ok = xyes)
#############################################################
# Check for Mac OS X Carbon framework (can't build on Darwin)
#############################################################
carbon_ok=no
AC_MSG_CHECKING([checking for Mac OS X Carbon support])
AC_TRY_CPP([
#include <Carbon/Carbon.h>
#include <CoreServices/CoreServices.h>
], carbon_ok=yes)
AC_MSG_RESULT($carbon_ok)
if test "x$carbon_ok" = "xyes"; then
AC_DEFINE(HAVE_CARBON, 1, [define to 1 if Carbon is available])
CARBON_LDFLAGS="-framework Carbon"
AC_SUBST(CARBON_LDFLAGS)
fi
##########################################################
# Determine where to install the desktop & mime info files
##########################################################

View File

@ -149,7 +149,8 @@ libgimpbaseinclude_HEADERS = \
libgimpbase_2_0_la_LDFLAGS = \
-version-info $(LT_VERSION_INFO) \
$(no_undefined) \
$(libgimpbase_export_symbols)
$(libgimpbase_export_symbols) \
$(CARBON_LDFLAGS)
libgimpbase_2_0_la_DEPENDENCIES = $(gimpbase_def)

View File

@ -42,7 +42,6 @@
#include "gimpversion.h"
#include "gimpreloc.h"
#ifdef G_OS_WIN32
#define STRICT
#define WIN32_LEAN_AND_MEAN
@ -66,8 +65,14 @@
#endif
#ifndef G_OS_WIN32
#ifndef HAVE_CARBON
#include "xdg-user-dir.h"
#endif
#endif
#ifdef HAVE_CARBON
#include "CoreServices/CoreServices.h"
#endif
static gchar * gimp_env_get_dir (const gchar *gimp_env_name,
@ -444,6 +449,45 @@ get_special_folder (int csidl)
}
#endif
#ifdef HAVE_CARBON
static gchar *
find_folder (OSType type)
{
gchar *filename = NULL;
FSRef found;
if (FSFindFolder (kUserDomain, type, kDontCreateFolder, &found) == noErr)
{
CFURLRef url = CFURLCreateFromFSRef (kCFAllocatorSystemDefault, &found);
if (url)
{
CFStringRef path = CFURLCopyFileSystemPath (url, kCFURLPOSIXPathStyle);
if (path)
{
filename = g_strdup (CFStringGetCStringPtr (path, kCFStringEncodingUTF8));
if (! filename)
{
filename = g_new0 (gchar, CFStringGetLength (path) * 3 + 1);
CFStringGetCString (path, filename,
CFStringGetLength (path) * 3 + 1,
kCFStringEncodingUTF8);
}
CFRelease (path);
}
CFRelease (url);
}
}
return filename;
}
#endif
/**
* gimp_user_directory:
* @type: the type of user directory to retrieve
@ -483,6 +527,25 @@ gimp_user_directory (GimpUserDirectory type)
case GIMP_USER_DIRECTORY_VIDEOS:
return get_special_folder (CSIDL_MYVIDEO);
#elif HAVE_CARBON
case GIMP_USER_DIRECTORY_DESKTOP:
return find_folder (kDesktopFolderType);
case GIMP_USER_DIRECTORY_DOCUMENTS:
return find_folder (kDocumentsFolderType);
case GIMP_USER_DIRECTORY_MUSIC:
return find_folder (kMusicDocumentsFolderType);
case GIMP_USER_DIRECTORY_PICTURES:
return find_folder (kPictureDocumentsFolderType);
case GIMP_USER_DIRECTORY_TEMPLATES:
return NULL;
case GIMP_USER_DIRECTORY_VIDEOS:
return find_folder (kMovieDocumentsFolderType);
#else
case GIMP_USER_DIRECTORY_DESKTOP:
return _xdg_user_dir_lookup ("DESKTOP");