osx: Fix link activation (issue 31)

This commit is contained in:
Alexander Kojevnikov 2011-02-23 16:11:52 +08:00
parent b8c28560ef
commit 503eb705a1

View File

@ -26,6 +26,7 @@
#ifdef G_OS_DARWIN
#include <CoreFoundation/CoreFoundation.h>
#include <ApplicationServices/ApplicationServices.h>
#endif
#include "spek-platform.h"
@ -61,12 +62,24 @@ void spek_platform_show_uri (const gchar *uri) {
#ifdef G_OS_WIN32
/* gtk_show_uri doesn't work on Windows */
ShellExecuteA (NULL, "open", uri, "", NULL, SW_SHOWNORMAL);
#else
#ifdef G_OS_DARWIN
/* it doesn't work on OS X too */
CFStringRef str = NULL;
CFURLRef url = NULL;
str = CFStringCreateWithCString (NULL, uri, kCFStringEncodingASCII);
url = CFURLCreateWithString (NULL, str, NULL);
LSOpenCFURLRef (url, NULL);
CFRelease (url);
CFRelease (str);
#else
GError *error = NULL;
if (!gtk_show_uri (NULL, uri, gtk_get_current_event_time (), &error)) {
g_error_free (error);
}
#endif
#endif
}
gchar *spek_platform_read_line (const gchar *uri) {