From d00a881b24b5f6a066eb42f5b620ed4ca7465df7 Mon Sep 17 00:00:00 2001 From: Radegast Date: Mon, 25 Mar 2013 17:23:08 +0100 Subject: [PATCH] Fixed url opening on linux and Mac. --- radiant/gtkmisc.cpp | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index 352acac9..d6b1f675 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -1707,26 +1707,20 @@ bool WINAPI color_dialog( void *parent, float *color, const char* title ){ } void OpenURL( const char *url ){ - // let's put a little comment - Sys_Printf( "OpenURL: %s\n", url ); -#ifdef __linux__ - // \todo FIXME: the way we open URLs on *nix should be improved. A script is good (see how I do on RTCW) - char command[2 * PATH_MAX]; - snprintf( command, sizeof( command ), "%s/openurl.sh \"%s\" &", g_strAppPath.GetBuffer(), url ); - if ( system( command ) != 0 ) { - gtk_MessageBox( g_pParentWnd->m_pWidget, "Failed to launch Netscape!" ); - } -#endif -#ifdef __APPLE__ - char command[2 * PATH_MAX]; - snprintf( command, sizeof( command ), - "open \"%s\" &", url, url ); - if ( system( command ) != 0 ) { - gtk_MessageBox( g_pParentWnd->m_pWidget, "Unable to launch browser!" ); - } -#endif + char command[2 * PATH_MAX]; + + Sys_Printf( "OpenURL: %s\n", url ); #ifdef _WIN32 - ShellExecute( (HWND)GDK_WINDOW_HWND( g_pParentWnd->m_pWidget->window ), "open", url, NULL, NULL, SW_SHOW ); + ShellExecute( (HWND)GDK_WINDOW_HWND( g_pParentWnd->m_pWidget->window ), "open", url, NULL, NULL, SW_SHOW ); +#else +# ifdef __APPLE__ + snprintf(command, sizeof(command), "open '%s' &", url); +# else + snprintf(command, sizeof(command), "xdg-open '%s' &", url); +# endif + if (system(command) != 0) { + gtk_MessageBox( g_pParentWnd->m_pWidget, "Failed to launch web browser!" ); + } #endif }