From: James Turner Date: Mon, 7 May 2012 22:49:21 +0000 (+0100) Subject: On OS-X, used NSWorkspace to launch the browser. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8aeb650d165cba3e78928a3696d139cd64c36570;p=flightgear.git On OS-X, used NSWorkspace to launch the browser. --- diff --git a/src/GUI/FGCocoaMenuBar.hxx b/src/GUI/FGCocoaMenuBar.hxx index 694561aae..3ddc30cb4 100644 --- a/src/GUI/FGCocoaMenuBar.hxx +++ b/src/GUI/FGCocoaMenuBar.hxx @@ -62,4 +62,9 @@ private: }; +/** + * open a URL using the system's web-browser + */ +void cocoaOpenUrl(const std::string& url); + #endif // __MENUBAR_HXX diff --git a/src/GUI/FGCocoaMenuBar.mm b/src/GUI/FGCocoaMenuBar.mm index ac9173296..f34fc1490 100644 --- a/src/GUI/FGCocoaMenuBar.mm +++ b/src/GUI/FGCocoaMenuBar.mm @@ -297,3 +297,10 @@ void FGCocoaMenuBar::hide() { // no-op } + +void cocoaOpenUrl(const std::string& url) +{ + CocoaAutoreleasePool pool; + NSURL* nsu = [NSURL URLWithString:stdStringToCocoa(url)]; + [[NSWorkspace sharedWorkspace] openURL:nsu]; +} diff --git a/src/GUI/gui_funcs.cxx b/src/GUI/gui_funcs.cxx index 22e3e6a8c..5d797d009 100644 --- a/src/GUI/gui_funcs.cxx +++ b/src/GUI/gui_funcs.cxx @@ -60,6 +60,10 @@ # include #endif +#ifdef SG_MAC +# include "FGCocoaMenuBar.hxx" // for cocoaOpenUrl +#endif + #include "gui.h" using std::string; @@ -182,6 +186,15 @@ bool openBrowser(string address) } } +#ifdef SG_MAC + if (address.find("://")==string::npos) { + address = "file://" + address; + } + + cocoaOpenUrl(address); + return ok; +#endif + #ifndef _WIN32 string command = globals->get_browser();