diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-08-08 11:53:00 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-08-08 11:53:00 +0200 |
commit | b623f5953691b2a0614e6f1f4def86bdbb9a4113 (patch) | |
tree | 18102bd36f7e22eb2ba2b9f880e4cb29346f4cb8 /app/wlib/gtklib/browserhelp.c | |
parent | 359b557176b9bb2ff1aed2082641eed39c358d0d (diff) |
New upstream version 5.2.0Beta2.1upstream/5.2.0Beta2.1
Diffstat (limited to 'app/wlib/gtklib/browserhelp.c')
-rw-r--r-- | app/wlib/gtklib/browserhelp.c | 59 |
1 files changed, 10 insertions, 49 deletions
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 <stdlib.h> #include <assert.h> +#include <string.h> + +#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 @@ -63,36 +68,6 @@ TopicToUrl(char **helpUrl, const char *topic) 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 <topic>. First the * system's standard xdg-open command is attempted. If that is not available, the * version included with the XTrackCAD installation is executed. @@ -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); } |