Added mostly empty wxLaunchDefaultApplication

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54383 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2008-06-27 14:14:13 +00:00
parent 1dff2537d3
commit 1dea1566c8
2 changed files with 29 additions and 0 deletions

View 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
// ----------------------------------------------------------------------------

View 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
// ----------------------------------------------------------------------------