mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 18:52:09 +01:00
Fix special user dir lookup on OSX
This uses newer methods that support more folders such as Downloads. Closes #1048
This commit is contained in:
parent
e1eaea3eea
commit
4a4d7188f6
@ -357,6 +357,11 @@ libglib_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
|
|||||||
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
|
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
|
||||||
-export-dynamic $(no_undefined)
|
-export-dynamic $(no_undefined)
|
||||||
|
|
||||||
|
if OS_COCOA
|
||||||
|
libglib_2_0_la_CFLAGS += -xobjective-c
|
||||||
|
libglib_2_0_la_LDFLAGS += -Wl,-framework,Foundation
|
||||||
|
endif
|
||||||
|
|
||||||
INSTALL_PROGS=
|
INSTALL_PROGS=
|
||||||
|
|
||||||
if ENABLE_DTRACE
|
if ENABLE_DTRACE
|
||||||
|
@ -119,8 +119,8 @@
|
|||||||
# include <process.h>
|
# include <process.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CARBON
|
#ifdef HAVE_COCOA
|
||||||
#include <CoreServices/CoreServices.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CODESET
|
#ifdef HAVE_CODESET
|
||||||
@ -1402,56 +1402,38 @@ g_get_user_runtime_dir (void)
|
|||||||
return runtime_dir;
|
return runtime_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_CARBON
|
#ifdef HAVE_COCOA
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
find_folder (OSType type)
|
find_folder (NSSearchPathDirectory type)
|
||||||
{
|
{
|
||||||
gchar *filename = NULL;
|
gchar *filename;
|
||||||
FSRef found;
|
NSString *path;
|
||||||
|
NSArray *paths;
|
||||||
|
|
||||||
if (FSFindFolder (kUserDomain, type, kDontCreateFolder, &found) == noErr)
|
paths = NSSearchPathForDirectoriesInDomains (type, NSUserDomainMask, YES);
|
||||||
|
path = [paths firstObject];
|
||||||
|
if (path == nil)
|
||||||
{
|
{
|
||||||
CFURLRef url = CFURLCreateFromFSRef (kCFAllocatorSystemDefault, &found);
|
return NULL;
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filename = g_strdup ([path UTF8String]);
|
||||||
|
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
load_user_special_dirs (void)
|
load_user_special_dirs (void)
|
||||||
{
|
{
|
||||||
g_user_special_dirs[G_USER_DIRECTORY_DESKTOP] = find_folder (kDesktopFolderType);
|
g_user_special_dirs[G_USER_DIRECTORY_DESKTOP] = find_folder (NSDesktopDirectory);
|
||||||
g_user_special_dirs[G_USER_DIRECTORY_DOCUMENTS] = find_folder (kDocumentsFolderType);
|
g_user_special_dirs[G_USER_DIRECTORY_DOCUMENTS] = find_folder (NSDocumentDirectory);
|
||||||
g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = find_folder (kDesktopFolderType); /* XXX correct ? */
|
g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = find_folder (NSDownloadsDirectory);
|
||||||
g_user_special_dirs[G_USER_DIRECTORY_MUSIC] = find_folder (kMusicDocumentsFolderType);
|
g_user_special_dirs[G_USER_DIRECTORY_MUSIC] = find_folder (NSMusicDirectory);
|
||||||
g_user_special_dirs[G_USER_DIRECTORY_PICTURES] = find_folder (kPictureDocumentsFolderType);
|
g_user_special_dirs[G_USER_DIRECTORY_PICTURES] = find_folder (NSPicturesDirectory);
|
||||||
g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = NULL;
|
g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = find_folder (NSSharedPublicDirectory);
|
||||||
g_user_special_dirs[G_USER_DIRECTORY_TEMPLATES] = NULL;
|
g_user_special_dirs[G_USER_DIRECTORY_TEMPLATES] = NULL;
|
||||||
g_user_special_dirs[G_USER_DIRECTORY_VIDEOS] = find_folder (kMovieDocumentsFolderType);
|
g_user_special_dirs[G_USER_DIRECTORY_VIDEOS] = find_folder (NSMoviesDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(G_OS_WIN32)
|
#elif defined(G_OS_WIN32)
|
||||||
|
@ -569,6 +569,7 @@ if host_system == 'linux'
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
osx_ldflags = []
|
osx_ldflags = []
|
||||||
|
osx_cargs = []
|
||||||
glib_have_os_x_9_or_later = false
|
glib_have_os_x_9_or_later = false
|
||||||
glib_have_carbon = false
|
glib_have_carbon = false
|
||||||
glib_have_cocoa = false
|
glib_have_cocoa = false
|
||||||
@ -603,12 +604,14 @@ if host_system == 'darwin'
|
|||||||
if glib_have_cocoa
|
if glib_have_cocoa
|
||||||
glib_conf.set('HAVE_COCOA', true)
|
glib_conf.set('HAVE_COCOA', true)
|
||||||
osx_ldflags += ['-Wl,-framework,Foundation', '-Wl,-framework,AppKit']
|
osx_ldflags += ['-Wl,-framework,Foundation', '-Wl,-framework,AppKit']
|
||||||
|
osx_cargs += ['-xobjective-c']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# FIXME: libgio mix C and objC source files and there is no way to reliably
|
# FIXME: libgio mix C and objC source files and there is no way to reliably
|
||||||
# know which language flags it's going to use to link. Add to both languages
|
# know which language flags it's going to use to link. Add to both languages
|
||||||
# for now. See https://github.com/mesonbuild/meson/issues/3585.
|
# for now. See https://github.com/mesonbuild/meson/issues/3585.
|
||||||
add_project_link_arguments(osx_ldflags, language : ['objc', 'c'])
|
add_project_link_arguments(osx_ldflags, language : ['objc', 'c'])
|
||||||
|
add_project_arguments(osx_cargs, language : ['c'])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Check for futex(2)
|
# Check for futex(2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user