Filer icon indicating copy to clipboard operation
Filer copied to clipboard

Support "show in file manager" operations

Open probonopd opened this issue 5 years ago • 12 comments

User story: When I select "show in folder" for a download in a browser, then not only the Downloads folder should open but also the downloaded file should be selected.

Looks like GNOME and KDE use https://www.freedesktop.org/wiki/Specifications/file-manager-interface/, org.freedesktop.FileManager1 DBus name and the /org/freedesktop/FileManager1 object path.

And e.g., Chromium implements it: https://chromium.googlesource.com/chromium/src/+/master/chrome/browser/platform_util_linux.cc

Reference: https://github.com/probonopd/go-appimage/issues/12

This was also requested upstream.

probonopd avatar Sep 06 '20 07:09 probonopd

https://github.com/linuxdeepin/dde-file-manager/search?q=dbusfilemanager1 seems to be relatively straightforward.

probonopd avatar Sep 06 '20 07:09 probonopd

Nautilus implements it, XFCE file manager doesn't.

image

probonopd avatar Sep 07 '20 20:09 probonopd

… also (for example) this Open folder button in multimedia/simplescreenrecorder:

image

Other non-browser apps affected by this issue include:

  • … I have seen a few in recent weeks, I'll list some here …

grahamperrin avatar Jan 31 '21 14:01 grahamperrin

SSR is using https://doc.qt.io/qt-5/qdesktopservices.html#openUrl

https://github.com/MaartenBaert/ssr/blob/5f50ceff93cbdc1eab8ad09af880f5b8ffb28702/src/GUI/PageDone.cpp#L54-L57

[static]bool QDesktopServices::openUrl(const QUrl &url) Opens the given url in the appropriate Web browser for the user's desktop environment, and returns true if successful; otherwise returns false.

If the URL is a reference to a local file (i.e., the URL scheme is "file") then it will be opened with a suitable application instead of a Web browser.

I think this is not about "show in file manager", and is not using /org/freedesktop/FileManager1 -- "show in file manager" highlights the file in question in the file manager.

probonopd avatar Jan 31 '21 14:01 probonopd

Thanks … with KDE Plasma on FreeBSD 14.0-CURRENT, the Open folder button opens the folder that contains the screen recording in a new tab in Dolphin.

Do you need a separate issue for applications that should show the folder but not select the file?

grahamperrin avatar Jan 31 '21 15:01 grahamperrin

the Open folder button opens the folder that contains the screen recording in a new tab in Dolphin.

Yes, but this ticket is about applications being able to not only open the folder but also select the file in the file manager. Filer does not implement the protocol needed for this yet.

Do you need a separate issue for applications that should show the folder but not select the file?

Not yet. This stuff is expected to work only once we have a proper "open with" database/implementation.

probonopd avatar Jan 31 '21 18:01 probonopd

Looks like @Ashish-Bansal had sent a patch for KDE Dolphin that implements this.

https://phabricator.kde.org/source/dolphin/browse/master/src/dbusinterface.cpp

Can we port this to Filer? Possibly somewhere around

https://github.com/helloSystem/Filer/blob/7824dea7916a27a0f6d87616178292e0847d930c/src/application.cpp#L88

probonopd avatar Jul 18 '21 15:07 probonopd

Did I ever mention that I find D-Bus way too complicated? ;-)

Added https://github.com/helloSystem/Filer/commit/4c1f261220f9d0993b219c32f57a929aec753b80

But the wrong methods get exported to D-Bus under the org.freedesktop.FileManager1 service as shown by QDBusViewer below:

  • Why is there Application/org.filer.application with methods like desktopPreferences?
  • Why is there MenuBar?

All these things we were already exporting under the D-Bus org.filer.Filer Service. But under the org.freedesktop.FileManager1 we want to export the methods needed by the File Manager DBus Interface:

  • Why is there not /org/freedesktop/FileManager1 with methods like ShowFolders, ShowItems, and ShowItemProperties?

image

In my personal opinion, D-Bus being too complicated starts right with the fact that there is org.freedesktop.FileManager1 and /org/freedesktop/FileManager1 and that the two are not one and the same. As we can see, this complicates things immensely because now one needs to ensure (how?) that /org/freedesktop/FileManager1 (and only it) actually gets published under org.freedesktop.FileManager1. Why?

probonopd avatar Jul 18 '21 16:07 probonopd

What I seem to be missing entirely is how to tell Qt "publish the Qt method DBusInterface::ShowFolders(const QStringList& uriList, const QString& startUpId) as the D-Bus method ShowFolders under /org/freedesktop/FileManager1 under org.freedesktop.FileManager1. Exactly there and only there.

probonopd avatar Jul 18 '21 17:07 probonopd

Thanks @zyga for the following explanation:

I don't know Qt but it's fairly simple if you think about it the following way.

  • Any client can connect to the bus and publish objects with paths.
  • Any object can offer one or more interface.
  • All methods and properties belong to an interface.
  • A client can claim a bus name.
  • Anyone trying to find a given bus name, object path and interface can trigger bus activation, starting the providing service.
  • Interface is a personality. Each object can present arbitrary many. That’s the idea. Method Foo and property Bar are only meaningful if you add the interface (personality) name to it. You can have any number of methods Foo as long as the interface is different.

Maybe if I meditate long enough over it, then one day I will understand and appreciate the concepts behind D-Bus ;-)

probonopd avatar Jul 18 '21 17:07 probonopd

This works:

gdbus call --session --dest org.freedesktop.FileManager1 --object-path /org/freedesktop/FileManager1 --method org.freedesktop.FileManager1.ShowItems '["file:///Applications"]' ""

It will open a Filer window at / and highlight the Applications folder therein.

Thanks @mszoek.

probonopd avatar Sep 19 '21 15:09 probonopd

Looks like ShowFolders is not implemented here yet.

https://github.com/helloSystem/Filer/blob/5fc509ad04ba7f51e3af9c16deeaac9fe24f3844/src/application.cpp#L692-L694

Causes:

  • https://github.com/helloSystem/ISO/issues/554#issuecomment-1807183444

It is implemented correctly in https://github.com/probonopd/Filer

probonopd avatar Nov 12 '23 17:11 probonopd