View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000313 | Ecere SDK | ecere | public | 2010-02-05 06:43 | 2013-05-19 22:15 |
Reporter | joey | Assigned To | redj | ||
Priority | immediate | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Target Version | 0.44 Ryoan-ji | Fixed in Version | 0.44 Ryoan-ji | ||
Summary | 0000313: On Linux, "Browse Project Folder" doesn't (patch included) | ||||
Description | On Linux, the "Browse Project Folder" menu item does nothing but print "/path/to/project: is a directory". The underlying function, System_ShellOpen in ecere/ecere/src/sys/_System.c, simply appends " &" to the path and runs it with the system shell. This does nothing but print the message above if the path is a directory. According to http://stackoverflow.com/questions/41969/standard-way-to-open-a-folder-window-in-linux , calling xdg-open is The Right Way to open a path with the preferred application. It also works for files and URLs. xdg-open on a file acts like double-clicking it in a file manager like Nautilus. The attached patch makes System_ShellOpen() fork and call the xdg-open script instead of calling system(). To the best of my knowledge, xdg-open is exactly what ShellOpen() is all about. However, this patch could introduce bugs in other areas where ShellOpen is, say, expected to execute commands. | ||||
Tags | No tags attached. | ||||
2010-02-05 06:43
|
shell_xdg_open.patch (983 bytes)
--- sdk/ecere/src/sys/_System.c 2010-02-05 01:25:44.616141944 -0500 +++ sdk/ecere/src/sys/_System.c 2010-02-05 01:29:33.016143083 -0500 @@ -278,9 +278,23 @@ #if !defined(__WIN32__) { - strcat(filePath, " &"); - if(system(filePath) != -1) - result = true; + const char *cmd = "xdg-open"; + switch (fork()) { + case -1: // fork() failed + //fprintf(stderr, "%s: %s\n", cmd, strerror(errno)); + break; + case 0: // child process + execlp(cmd, cmd, filePath, NULL); + exit(EXIT_FAILURE); //if exec failed, end child process + default: // parent process + /* + * The fork succeeded, and the child process is on its way. + * We don't know if the command will start successfully or not; + * all we can say is "Bon voyage!" + */ + result = true; + break; + } } #elif defined(ECERE_VANILLA) { |
|
Hey thanks Joey this is a nice patch, hadn't noticed it yet :) If Mantis was a bit more up to date I might catch these goodies faster. We got the patch, what are we waiting for :) |
|
damn! where did this come from!!! this mantis issue and this patch have been forgotten oblivion strikes again here's Joey's patch for easy review: --- sdk/ecere/src/sys/_System.c 2010-02-05 01:25:44.616141944 -0500 +++ sdk/ecere/src/sys/_System.c 2010-02-05 01:29:33.016143083 -0500 @@ -278,9 +278,23 @@ #if !defined(__WIN32__) { - strcat(filePath, " &"); - if(system(filePath) != -1) - result = true; + const char *cmd = "xdg-open"; + switch (fork()) { + case -1: // fork() failed + //fprintf(stderr, "%s: %s\n", cmd, strerror(errno)); + break; + case 0: // child process + execlp(cmd, cmd, filePath, NULL); + exit(EXIT_FAILURE); //if exec failed, end child process + default: // parent process + /* + * The fork succeeded, and the child process is on its way. + * We don't know if the command will start successfully or not; + * all we can say is "Bon voyage!" + */ + result = true; + break; + } } #elif defined(ECERE_VANILLA) { a solution was later implemented by: https://github.com/ecere/sdk/commit/92f99c5158fe5526aa5ba1b1726706a06dfc183e according to: http://www.ubuntugeek.com/xdg-open-%E2%80%94-opens-a-file-or-url-in-the-users-preferred-application.html xdg-open is a shell script which attempts to call the appropriate ‘open’ utility given the current environment (so if you are using gnome it will call gnome-open). do we want to use the shell script alone? or keep using the currently implemented logic and fall back on the shell script? or not use the shell script at all? |
|
how about this? (which would be keep using the currently implemented logic and fall back on the shell script) diff --git a/ecere/src/sys/System.c b/ecere/src/sys/System.c index 126a9ea..4eb4c3c 100644 --- a/ecere/src/sys/System.c +++ b/ecere/src/sys/System.c @@ -361,10 +361,7 @@ bool System_ShellOpen(char * fileName, va_list args) else if(__ecereNameSpace__ecere__sys__SearchString(desktop, 0, "kde", false, false)) sprintf(command, "kde-open \"%s\" &", filePath); else - { - if(FILE_FileExists(filePath) != isDirectory) - sprintf(command, "%s &", filePath); - } + sprintf(command, "xdg-open \"%s\" &", filePath); } if(command[0] && system(command) != -1) |
|
see http://budts.be/weblog/2011/07/xdf-open-vs-exo-open I guess we should detect XFCE (call exo-open) and LXDE (call what?) |
|
the later implemented solution used to not try to open directories if a desktop session couldn't be detected. if(FILE_FileExists(filePath) != isDirectory) sprintf(command, "%s &", filePath); what will xdg-open do if a desktop cannot be detected? do we care? |
Date Modified | Username | Field | Change |
---|---|---|---|
2010-02-05 06:43 | joey | New Issue | |
2010-02-05 06:43 | joey | File Added: shell_xdg_open.patch | |
2010-07-25 20:36 | redj | Relationship added | child of 0000429 |
2010-07-26 01:39 | jerome | Note Added: 0000225 | |
2010-07-26 19:10 | thexa4 | Target Version | => 0.44 draft 2 |
2010-07-29 15:06 | jerome | Priority | normal => immediate |
2012-03-06 07:46 | redj | Note Added: 0000503 | |
2012-03-06 07:47 | redj | Note Added: 0000504 | |
2012-03-06 07:47 | redj | Note Edited: 0000504 | |
2012-03-06 07:59 | redj | Status | new => resolved |
2012-03-06 07:59 | redj | Resolution | open => fixed |
2012-03-06 07:59 | redj | Assigned To | => redj |
2012-03-06 08:00 | redj | Note Added: 0000505 | |
2012-03-06 08:03 | redj | Note Edited: 0000505 | |
2012-03-06 08:07 | redj | Note Added: 0000506 | |
2012-03-06 10:23 | redj | Note Edited: 0000503 | |
2012-03-06 10:23 | redj | Note Edited: 0000503 | |
2012-03-08 15:34 | redj | Target Version | old 0.44.pre2 => 0.44 Ryoan-ji |
2012-03-08 17:18 | redj | Relationship deleted | child of 0000429 |
2012-03-08 18:08 | redj | Fixed in Version | => 0.44 Ryoan-ji |
2012-03-09 18:58 | redj | Relationship added | related to 0000669 |
2012-03-09 19:17 | redj | Relationship added | related to 0000690 |
2012-03-29 07:53 | redj | Category | => Ecere Runtime Library |
2012-03-29 07:53 | redj | Project | @1@ => Ecere SDK |
2013-05-19 22:15 | jerome | Status | resolved => closed |