osx: Fix new version detection

This commit is contained in:
Alexander Kojevnikov 2011-02-23 15:48:07 +08:00
parent f1f63561f9
commit b8c28560ef
2 changed files with 27 additions and 0 deletions

View File

@ -42,6 +42,7 @@ if test "x$_gdk_tgt" = xquartz; then
PKG_CHECK_MODULES(IGE_MAC, ige-mac-integration)
AC_SUBST(IGE_MAC_LIBS)
AC_SUBST(IGE_MAC_CFLAGS)
AC_DEFINE(G_OS_DARWIN, 1, [Platform detection macro missing in GLib])
fi
GETTEXT_PACKAGE=spek

View File

@ -24,6 +24,10 @@
#include <shellapi.h>
#endif
#ifdef G_OS_DARWIN
#include <CoreFoundation/CoreFoundation.h>
#endif
#include "spek-platform.h"
void spek_platform_fix_args (gchar **argv, gint argc) {
@ -66,6 +70,27 @@ void spek_platform_show_uri (const gchar *uri) {
}
gchar *spek_platform_read_line (const gchar *uri) {
#ifdef G_OS_DARWIN
/* GIO doesn't work on OS X */
CFStringRef str = NULL;
CFURLRef url = NULL;
CFDataRef data = NULL;
CFIndex length = 0;
gchar *buf = NULL;
str = CFStringCreateWithCString (NULL, uri, kCFStringEncodingASCII);
url = CFURLCreateWithString (NULL, str, NULL);
if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data, NULL, NULL, NULL)) {
length = CFDataGetLength (data);
buf = (gchar *) g_malloc (length + 1);
CFDataGetBytes (data, CFRangeMake (0, length), (UInt8 *) buf);
buf[length] = '\0';
CFRelease (data);
}
CFRelease (url);
CFRelease (str);
return buf;
#else
gchar *line = NULL;
GFile *file = NULL;
GFileInputStream *file_stream = NULL;
@ -83,4 +108,5 @@ gchar *spek_platform_read_line (const gchar *uri) {
}
g_object_unref (file);
return line;
#endif
}