diff options
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); } |