]> git.mxchange.org Git - flightgear.git/commitdiff
On OS-X, used NSWorkspace to launch the browser.
authorJames Turner <zakalawe@mac.com>
Mon, 7 May 2012 22:49:21 +0000 (23:49 +0100)
committerJames Turner <zakalawe@mac.com>
Mon, 7 May 2012 22:49:21 +0000 (23:49 +0100)
src/GUI/FGCocoaMenuBar.hxx
src/GUI/FGCocoaMenuBar.mm
src/GUI/gui_funcs.cxx

index 694561aaec146ebcf6f63730de2e5861f8a70deb..3ddc30cb46cf777b7a8c56bc5cb67faad1c4606c 100644 (file)
@@ -62,4 +62,9 @@ private:
   
 };
 
+/**
+ * open a URL using the system's web-browser
+ */
+void cocoaOpenUrl(const std::string& url);
+
 #endif // __MENUBAR_HXX
index ac91732962cee3ebe27fa4e61f8080c2b697beb7..f34fc1490c3c9391c48bcf60b7cde7a15da62f8b 100644 (file)
@@ -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];
+}
index 22e3e6a8caa071caef55d6dd25360b2743e8805a..5d797d009ade2dd0560bcf91c1efebd404f8b462 100644 (file)
 #  include <shellapi.h>
 #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();