commit b8c28560efdd3e99d053cfa33fb6b0bf7953cd71
parent f1f63561f944cdedac79bebaa72ca8afa8419a24
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date: Wed, 23 Feb 2011 15:48:07 +0800
osx: Fix new version detection
Diffstat:
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -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
diff --git a/src/spek-platform.c b/src/spek-platform.c
@@ -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
}