summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/app.c40
-rw-r--r--src/ui/certlistwidget.c3
-rw-r--r--src/ui/documentwidget.c8
-rw-r--r--src/ui/mediaui.c6
4 files changed, 49 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);
diff --git a/src/ui/certlistwidget.c b/src/ui/certlistwidget.c
index 5a1c481b..2a7562d8 100644
--- a/src/ui/certlistwidget.c
+++ b/src/ui/certlistwidget.c
@@ -107,6 +107,9 @@ static void updateContextMenu_CertListWidget_(iCertListWidget *d) {
107#if defined (iPlatformAppleDesktop) 107#if defined (iPlatformAppleDesktop)
108 { magnifyingGlass_Icon " ${menu.reveal.macos}", 0, 0, "ident.reveal" }, 108 { magnifyingGlass_Icon " ${menu.reveal.macos}", 0, 0, "ident.reveal" },
109#endif 109#endif
110#if defined (iPlatformLinux)
111 { magnifyingGlass_Icon " ${menu.reveal.filemgr}", 0, 0, "ident.reveal" },
112#endif
110 { export_Icon " ${ident.export}", 0, 0, "ident.export" }, 113 { export_Icon " ${ident.export}", 0, 0, "ident.export" },
111 { "---", 0, 0, NULL }, 114 { "---", 0, 0, NULL },
112 { delete_Icon " " uiTextCaution_ColorEscape "${ident.delete}", 0, 0, "ident.delete confirm:1" }, 115 { delete_Icon " " uiTextCaution_ColorEscape "${ident.delete}", 0, 0, "ident.delete confirm:1" },
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 2ea0a4b7..58e6a11e 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -5032,6 +5032,14 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
5032 format_CStr("!reveal url:%s", 5032 format_CStr("!reveal url:%s",
5033 cstr_String(linkUrl)) }); 5033 cstr_String(linkUrl)) });
5034#endif 5034#endif
5035#if defined (iPlatformLinux)
5036 pushBack_Array(&items,
5037 &(iMenuItem){ "${menu.reveal.filemgr}",
5038 0,
5039 0,
5040 format_CStr("!reveal url:%s",
5041 cstr_String(linkUrl)) });
5042#endif
5035 } 5043 }
5036 } 5044 }
5037 else if (!willUseProxy_App(scheme)) { 5045 else if (!willUseProxy_App(scheme)) {
diff --git a/src/ui/mediaui.c b/src/ui/mediaui.c
index ab88c94a..f0070688 100644
--- a/src/ui/mediaui.c
+++ b/src/ui/mediaui.c
@@ -269,6 +269,12 @@ iBool processEvent_DownloadUI(iDownloadUI *d, const SDL_Event *ev) {
269 0, 269 0,
270 format_CStr("!reveal path:%s", cstr_String(path)) }, 270 format_CStr("!reveal path:%s", cstr_String(path)) },
271#endif 271#endif
272#if defined (iPlatformLinux)
273 { "${menu.reveal.filemgr}",
274 0,
275 0,
276 format_CStr("!reveal path:%s", cstr_String(path)) },
277#endif
272 { "---" }, 278 { "---" },
273 /* Generic items */ 279 /* Generic items */
274 { "${menu.downloads}", 0, 0, "downloads.open newtab:1" }, 280 { "${menu.downloads}", 0, 0, "downloads.open newtab:1" },