From 8aeb650d165cba3e78928a3696d139cd64c36570 Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 7 May 2012 23:49:21 +0100 Subject: [PATCH] On OS-X, used NSWorkspace to launch the browser. --- src/GUI/FGCocoaMenuBar.hxx | 5 +++++ src/GUI/FGCocoaMenuBar.mm | 7 +++++++ src/GUI/gui_funcs.cxx | 13 +++++++++++++ 3 files changed, 25 insertions(+) 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(); -- 2.39.5