mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-24 17:58:45 +00:00
Changed: Give priority to xdg-open (if present) to open URLs under Linux
This commit is contained in:
parent
953e7b3df6
commit
4d99b9d3bc
1 changed files with 29 additions and 12 deletions
|
@ -1078,9 +1078,36 @@ static bool openDocWithExtension (const char *document, const char *ext)
|
|||
{
|
||||
return true;
|
||||
}
|
||||
#elif defined(NL_OS_MAC)
|
||||
return launchProgram("open", document);
|
||||
#else
|
||||
// TODO: implement for Linux and Mac OS X
|
||||
nlunreferenced(document);
|
||||
std::string command = "/usr/bin/xdg-open";
|
||||
|
||||
if (!CFile::fileExists(command))
|
||||
{
|
||||
if (strcmp(ext, "htm") == 0)
|
||||
{
|
||||
command = "/etc/alternatives/x-www-browser";
|
||||
|
||||
if (!CFile::fileExists(command))
|
||||
{
|
||||
command.clear();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
command.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (command.empty())
|
||||
{
|
||||
nlwarning("Unable to open %s", document);
|
||||
return false;
|
||||
}
|
||||
|
||||
return launchProgram(command, document);
|
||||
|
||||
#endif // NL_OS_WINDOWS
|
||||
|
||||
return false;
|
||||
|
@ -1088,17 +1115,7 @@ static bool openDocWithExtension (const char *document, const char *ext)
|
|||
|
||||
bool openURL (const char *url)
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
return openDocWithExtension(url, "htm");
|
||||
#elif defined(NL_OS_MAC)
|
||||
return launchProgram("open", url);
|
||||
#elif defined(NL_OS_UNIX)
|
||||
return launchProgram("/etc/alternatives/x-www-browser", url);
|
||||
#else
|
||||
nlwarning("openURL() is not implemented for this OS");
|
||||
#endif // NL_OS_WINDOWS
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool openDoc (const char *document)
|
||||
|
|
Loading…
Reference in a new issue