From b623f5953691b2a0614e6f1f4def86bdbb9a4113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 8 Aug 2020 11:53:00 +0200 Subject: New upstream version 5.2.0Beta2.1 --- app/wlib/gtklib/browserhelp.c | 59 ++++++++----------------------------------- 1 file changed, 10 insertions(+), 49 deletions(-) (limited to 'app/wlib/gtklib/browserhelp.c') diff --git a/app/wlib/gtklib/browserhelp.c b/app/wlib/gtklib/browserhelp.c index 9351e86..aa8f5c7 100644 --- a/app/wlib/gtklib/browserhelp.c +++ b/app/wlib/gtklib/browserhelp.c @@ -22,12 +22,17 @@ #include #include +#include + +#include "misc.h" #include "gtkint.h" #include "i18n.h" #include "dynstring.h" +#define debug 0 + #define DEFAULTBROWSERCOMMAND "xdg-open" #define HELPERRORTEXT "Help Error - help information can not be found.\n" \ @@ -38,7 +43,7 @@ "variable.\n Also make sure that the user has sufficient access rights to read these" \ "files." /** - * Create a fully qualified url froma topic + * Create a fully qualified url from a topic * * \param helpUrl OUT pointer to url, free by caller * \param topic IN the help topic @@ -62,36 +67,6 @@ TopicToUrl(char **helpUrl, const char *topic) *helpUrl = strdup(DynStringToCStr(&url)); DynStringFree(&url); } -/** - * Extend the PATH variable inthe environment to include XTrackCAD's - * script directory. - * - * \return pointer to old path - */ - -static char * -ExtendPath(void) -{ - char *path = getenv("PATH"); - DynString newPath; - DynStringMalloc(&newPath, 16); - - // append XTrackCAD's directory to the path as a fallback - DynStringCatCStrs(&newPath, - path, - ":", - wGetAppLibDir(), - NULL); - - setenv("PATH", - DynStringToCStr(&newPath), - TRUE); - - DynStringFree(&newPath); - - return (path); -} - /** * Invoke the system's default browser to display help for . First the * system's standard xdg-open command is attempted. If that is not available, the @@ -104,34 +79,20 @@ void wHelp(const char * topic) { int rc; char *url; - DynString commandLine; char *currentPath; assert(topic != NULL); assert(strlen(topic)); - currentPath = ExtendPath(); - TopicToUrl(&url, topic); + if (!CheckHelpTopicExists(topic)) return; - DynStringMalloc(&commandLine, 16); - DynStringCatCStrs(&commandLine, - DEFAULTBROWSERCOMMAND, - " ", - url, - NULL); + TopicToUrl(&url, topic); - // the command should be found via the PATH - rc = system(DynStringToCStr(&commandLine)); + rc = wOpenFileExternal(url); - if (rc) { + if (!rc) { wNotice(HELPERRORTEXT, _("Cancel"), NULL); } - // restore the PATH - setenv("PATH", - currentPath, - TRUE); - free(url); - DynStringFree(&commandLine); } -- cgit v1.2.3