]> git.saurik.com Git - wxWidgets.git/commitdiff
Provide wxLaunchDefaultBrowser implementation for wxCocoa.
authorDavid Elliott <dfe@tgwbd.org>
Tue, 8 May 2007 19:37:06 +0000 (19:37 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Tue, 8 May 2007 19:37:06 +0000 (19:37 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45892 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/cocoa/utils.mm
src/common/utilscmn.cpp

index a2ae48aa1a9e89da70cc08286dc3bb1874fdcbe7..f4acf49cb8b0072d6d0b3ee5f4957937b7571607 100644 (file)
 #include <string.h>
 #include <stdarg.h>
 
+#include "wx/cocoa/string.h"
+
+#import <Foundation/NSURL.h>
+#import <AppKit/NSWorkspace.h>
+
 void wxDisplaySize(int *width, int *height)
 {
     // TODO
@@ -97,6 +102,13 @@ void wxBell()
     // TODO
 }
 
+// Private helper method for wxLaunchDefaultBrowser
+bool wxCocoaLaunchDefaultBrowser(const wxString& url, int flags)
+{
+    // NOTE: We ignore the flags
+    return [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString:wxNSStringWithWxString(url)]] != NO;
+}
+
 #if 0
 // DFE: These aren't even implemented by wxGTK, and no wxWidgets code calls
 // them.  If someone needs them, then they'll get a link error
index abc3d00ecfef9d2cb36e8b7d4b5a57c43ac64db4..55b70aed84ca4eb91a754770f477799afeda1d5c 100644 (file)
@@ -678,6 +678,11 @@ wxRegisterId (long id)
 // Launch default browser
 // ----------------------------------------------------------------------------
 
+#ifdef __WXCOCOA__
+// Private method in Objective-C++ source file.
+bool wxCocoaLaunchDefaultBrowser(const wxString& url, int flags);
+#endif
+
 bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
 {
     wxUnusedVar(flags);
@@ -778,6 +783,10 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
 #endif // __WXDEBUG__
         return true;
     }
+#elif defined(__WXCOCOA__)
+    // NOTE: We need to call the real implementation from src/cocoa/utils.mm
+    // because the code must use Objective-C features.
+    return wxCocoaLaunchDefaultBrowser(url, flags);
 #elif defined(__WXMAC__)
     OSStatus err;
     ICInstance inst;