]> git.saurik.com Git - wxWidgets.git/commitdiff
Added mostly empty wxLaunchDefaultApplication
authorRobert Roebling <robert@roebling.de>
Fri, 27 Jun 2008 14:14:13 +0000 (14:14 +0000)
committerRobert Roebling <robert@roebling.de>
Fri, 27 Jun 2008 14:14:13 +0000 (14:14 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54383 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/utils.h
src/common/utilscmn.cpp

index 0458210efdb2787eeb97c5c437239a179e7e0fab..868e744809e92a711bd83c04c1d77198a814c4de 100644 (file)
@@ -578,6 +578,9 @@ enum
 // Launch url in the user's default internet browser
 WXDLLIMPEXP_CORE bool wxLaunchDefaultBrowser(const wxString& url, int flags = 0);
 
+// Launch document in the user's default application
+WXDLLIMPEXP_CORE bool wxLaunchDefaultApplication(const wxString& path, int flags = 0);
+
 // ----------------------------------------------------------------------------
 // Menu accelerators related things
 // ----------------------------------------------------------------------------
index 42d60c2c4d931bdace69807fb271a41150782abd..fad395b80079a8df48bd3eb997964541ec88b14b 100644 (file)
@@ -933,6 +933,32 @@ void wxQsort(void *const pbase, size_t total_elems,
 
 #if wxUSE_GUI
 
+// ----------------------------------------------------------------------------
+// Launch document with default app
+// ----------------------------------------------------------------------------
+
+bool wxLaunchDefaultApplication(const wxString &document, int flags)
+{
+    wxUnusedVar(flags);
+    
+#ifdef __UNIX__
+    // Our best best is to use xdg-open from freedesktop.org cross-desktop
+    // compatibility suite xdg-utils
+    // (see http://portland.freedesktop.org/wiki/) -- this is installed on
+    // most modern distributions and may be tweaked by them to handle
+    // distribution specifics.
+    wxString path, xdg_open;
+    if ( wxGetEnv("PATH", &path) &&
+         wxFindFileInPath(&xdg_open, path, "xdg-open") )
+    {
+        if ( wxExecute(xdg_open + " " + document) )
+            return true;
+    }
+#endif
+
+   return false;
+}
+
 // ----------------------------------------------------------------------------
 // Launch default browser
 // ----------------------------------------------------------------------------