diff options
author | Ole Loots <ole@monochrom.net> | 2012-08-27 20:05:35 +0200 |
---|---|---|
committer | Ole Loots <ole@monochrom.net> | 2012-08-27 20:05:35 +0200 |
commit | 02593d170a7163a141acf6f2f72686a7bdbfb828 (patch) | |
tree | 455e1f2f2fb2f9d291bca96124799aa84a9d5e83 /atari/ctxmenu.c | |
parent | 5a7ddb9e8478e18ac06871dc841cf7069a5ba949 (diff) | |
download | netsurf-02593d170a7163a141acf6f2f72686a7bdbfb828.tar.gz netsurf-02593d170a7163a141acf6f2f72686a7bdbfb828.tar.bz2 |
Added is_process_running
Now the source code viewer is launched when not already
running (ShelWrite wasn't handling this correctly)
Diffstat (limited to 'atari/ctxmenu.c')
-rw-r--r-- | atari/ctxmenu.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c index 79395ca1b..1a1755b12 100644 --- a/atari/ctxmenu.c +++ b/atari/ctxmenu.c @@ -23,7 +23,8 @@ #include <string.h>
#include <stdbool.h>
#include <assert.h>
-#include <windom.h>
+#include <windom.h> +#include <mint/osbind.h>
#include "desktop/gui.h"
#include "desktop/netsurf.h"
@@ -122,8 +123,8 @@ void context_popup( struct gui_window * gw, short x, short y ) FILE * fp_tmpfile;
char * tempfile;
int err = 0;
- char * editor;
- char cmdline[128];
+ char * editor, *lastslash;
+ char cmdline[PATH_MAX];
pop = get_tree( POP_CTX );
if (pop == NULL)
@@ -239,15 +240,24 @@ void context_popup( struct gui_window * gw, short x, short y ) fp_tmpfile = fopen( tempfile, "w" );
if (fp_tmpfile != NULL){
fwrite(data, size, 1, fp_tmpfile);
- fclose(fp_tmpfile );
-
- // TODO: check if app is runnin, if not, use pexec or such.
- /*
- sprintf((char*)&cmdline, "%s \"%s\"", nsoption_charp(atari_editor), tempfile );
- system( (char*)&cmdline );
- */
- err = ShelWrite( editor, tempfile , editor, 1, 0);
- LOG(("Launched: %s %s (%d)\n", editor, tempfile, err ));
+ fclose(fp_tmpfile ); + lastslash = strrchr(editor, '/'); + if (lastslash == NULL) + lastslash = strrchr(editor, '\\'); + if (lastslash == NULL) + lastslash = editor; + else + lastslash++; + if(is_process_running(lastslash)){ + err = ShelWrite( editor, tempfile , editor, 1, 0); + } else { + /* check for max length of simple commandline param: */ + if(strlen(tempfile)<=125){ + sprintf(cmdline, "%c%s", (char)strlen(tempfile), + tempfile); + Pexec(100, editor, cmdline, NULL); + } + }
} else {
printf("Could not open temp file: %s!\n", tempfile );
}
|