summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2022-01-13 14:10:58 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2022-01-13 14:10:58 +0200
commit2c4faf01db772b642ccc068383df96ee5633321b (patch)
treed05cc968a4d975b040e8fd2cd9a507137b75ed2b /src/app.c
parent061a5d5e37a145281d668c1d659cafbb62d5f0ec (diff)
Showing files using `dbus-send` under Freedesktop
D-Bus command line tools can be called to make method calls to reveal a file's location in the file manager.
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/app.c b/src/app.c
index 0a17a665..65f6fde6 100644
--- a/src/app.c
+++ b/src/app.c
@@ -3404,28 +3404,52 @@ void openInDefaultBrowser_App(const iString *url) {
3404 "xdg-open", 3404 "xdg-open",
3405 cstr_String(url), 3405 cstr_String(url),
3406#elif defined (iPlatformMsys) 3406#elif defined (iPlatformMsys)
3407 concatPath_CStr(cstr_String(execPath_App()), "../urlopen.bat"), 3407 concatPath_CStr(cstr_String(execPath_App()), "../urlopen.bat"),
3408 cstr_String(url), 3408 cstr_String(url),
3409 /* TODO: The prompt window is shown momentarily... */ 3409 /* TODO: The prompt window is shown momentarily... */
3410#endif 3410#endif
3411 NULL)) 3411 NULL))
3412 ); 3412 );
3413 start_Process(proc); 3413 start_Process(proc);
3414 waitForFinished_Process(proc); /* TODO: test on Windows */ 3414 waitForFinished_Process(proc);
3415 iRelease(proc); 3415 iRelease(proc);
3416} 3416}
3417 3417
3418#include <the_Foundation/thread.h>
3419
3418void revealPath_App(const iString *path) { 3420void revealPath_App(const iString *path) {
3419#if defined (iPlatformAppleDesktop) 3421#if defined (iPlatformAppleDesktop)
3420 iProcess *proc = new_Process(); 3422 iProcess *proc = new_Process();
3421 setArguments_Process( 3423 setArguments_Process(
3422 proc, iClob(newStringsCStr_StringList("/usr/bin/open", "-R", cstr_String(path), NULL))); 3424 proc, iClob(newStringsCStr_StringList("/usr/bin/open", "-R", cstr_String(path), NULL)));
3423 start_Process(proc); 3425 start_Process(proc);
3424 iRelease(proc); 3426 iRelease(proc);
3425#elif defined (iPlatformAppleMobile) 3427#elif defined (iPlatformAppleMobile)
3426 /* Use a share sheet. */ 3428 /* Use a share sheet. */
3427 openFileActivityView_iOS(path); 3429 openFileActivityView_iOS(path);
3428#elif defined (iPlatformLinux) || defined (iPlatformHaiku) 3430#elif defined (iPlatformLinux) || defined (iPlatformHaiku)
3431 iProcess *proc = NULL;
3432 /* Try with `dbus-send` first. */ {
3433 proc = new_Process();
3434 setArguments_Process(
3435 proc,
3436 iClob(newStringsCStr_StringList(
3437 "/usr/bin/dbus-send",
3438 "--print-reply",
3439 "--dest=org.freedesktop.FileManager1",
3440 "/org/freedesktop/FileManager1",
3441 "org.freedesktop.FileManager1.ShowItems",
3442 format_CStr("array:string:%s", makeFileUrl_CStr(cstr_String(path))),
3443 "string:",
3444 NULL)));
3445 start_Process(proc);
3446 waitForFinished_Process(proc);
3447 const iBool dbusDidSucceed = (exitStatus_Process(proc) == 0);
3448 iRelease(proc);
3449 if (dbusDidSucceed) {
3450 return;
3451 }
3452 }
3429 iFileInfo *inf = iClob(new_FileInfo(path)); 3453 iFileInfo *inf = iClob(new_FileInfo(path));
3430 iRangecc target; 3454 iRangecc target;
3431 if (isDirectory_FileInfo(inf)) { 3455 if (isDirectory_FileInfo(inf)) {
@@ -3434,7 +3458,7 @@ void revealPath_App(const iString *path) {
3434 else { 3458 else {
3435 target = dirName_Path(path); 3459 target = dirName_Path(path);
3436 } 3460 }
3437 iProcess *proc = new_Process(); 3461 proc = new_Process();
3438 setArguments_Process( 3462 setArguments_Process(
3439 proc, iClob(newStringsCStr_StringList("/usr/bin/env", "xdg-open", cstr_Rangecc(target), NULL))); 3463 proc, iClob(newStringsCStr_StringList("/usr/bin/env", "xdg-open", cstr_Rangecc(target), NULL)));
3440 start_Process(proc); 3464 start_Process(proc);