Cardinal icon indicating copy to clipboard operation
Cardinal copied to clipboard

[X11] The menu item 'Save As/Export' doesn't do anything

Open yurivict opened this issue 3 years ago • 42 comments

Usually 'Save As' action is expected to ask the user about file path.

yurivict avatar Feb 07 '22 20:02 yurivict

Yes. This requires dbus with a desktop-portal implementation on the desktop environment. This is not the case for you?

The open file still works, correct?

falkTX avatar Feb 07 '22 20:02 falkTX

A better behavior here is to determine that desktop-portal isn't running and tell this to the user is a pop-up box.

open works.

yurivict avatar Feb 07 '22 21:02 yurivict

I am putting this in the FAQ, but it is expected that eventually all desktop environments are going to support it. https://github.com/flatpak/xdg-desktop-portal lists several backends already made. I have checked with some people and it works on Linux with Gnome, KDE and LXDE.

falkTX avatar Feb 07 '22 21:02 falkTX

But if it doesn't work for some reason - it's better to explain to the user why the action can't be completed.

yurivict avatar Feb 07 '22 21:02 yurivict

I can show an error, but knowing exactly why would break the API which I am not very keen on doing. A generic warning is pointless, so I guess it is best for us to try to figure this out then.

Do you have qdbusviewer ? It should help to debug this, as it can nicely traverse/introspect all the active DBus paths and methods.

falkTX avatar Feb 07 '22 21:02 falkTX

It doesn't show org.freedesktop.portal.Desktop. I am on XFCE4.

So it would seem like you could try to look up this name in DBus and if not found tell something like this to the user:

Desktop-portal doesn't seem to be running on your system. The requested action can't be completed.

yurivict avatar Feb 07 '22 22:02 yurivict

It doesn't show org.freedesktop.portal.Desktop. I am on XFCE4.

Are you able to install some package to get the gtk implementation?

falkTX avatar Feb 07 '22 22:02 falkTX

On our Devuan machine at the hackerspace I have to run /usr/libexec/xdg-desktop-portal manually, which is quite annoying.

However programs like Evince are able to either trigger the start of xdg-desktop-portal (on my debian machines) or access the file dialog themselves without the portal running (devuan), so it might be good to check the Evince source to see how they are doing this. [edit: they use GtkFileChooser that probably has some fallbacks for this]

For the user it is certainly quite annoying to have to debug and dig for work-arounds like this, just to get basic save functions to work.

dromer avatar Feb 08 '22 07:02 dromer

My Windows username has non-ascii characters. The save as dialog points to the wrong user directory. (Win7, Reaper, LV2).

bambax avatar Feb 08 '22 08:02 bambax

My Windows username has non-ascii characters. The save as dialog points to the wrong user directory. (Win7, Reaper, LV2).

that has nothing to do with this, please open a separate ticket

falkTX avatar Feb 08 '22 12:02 falkTX

My Windows username has non-ascii characters. The save as dialog points to the wrong user directory. (Win7, Reaper, LV2).

that has nothing to do with this, please open a separate ticket

Sorry. Opened #137

bambax avatar Feb 08 '22 12:02 bambax

Same thing for me, save as does nothing in standalone or in the vst2. I have qdbusviewer but I'm not sure what I should be looking for? I cannot see org.freedesktop.portal.Desktop listed.

spectromas avatar Feb 15 '22 09:02 spectromas

This is explained on the FAQ. https://github.com/DISTRHO/Cardinal/blob/main/docs/FAQ.md#on-bsdlinuxx11-the-menu-item-save-asexport-does-nothing Basically you need a xdg-freedesktop-portal implementation, be it for Gnome, KDE, LXDE or whatever applies to your system

falkTX avatar Feb 15 '22 09:02 falkTX

I have that installed and works elsewhere (I can change the implementation in firefox and Rack for example). Screenshot_20220215_095113

spectromas avatar Feb 15 '22 09:02 spectromas

Rack doesnt use desktop portal. And even while installed, doesn't mean it is active. As you stated:

I cannot see org.freedesktop.portal.Desktop listed

I dont know why this is the case, but it is the cause of the issue.

falkTX avatar Feb 15 '22 09:02 falkTX

For me Rack uses the KDE file dialog and changes to the GTK one if I don't have GTK_USE_PORTAL=1 in /etc/environment, just like firefox.

Strangely the save as is working now. I disabled GTK_USE_PORTAL=1, rebooted and it made no difference so I reverted, logged out and logged back in and now it is working and I can see the org.freedesktop.portal.Desktop entry.

spectromas avatar Feb 15 '22 10:02 spectromas

FYI: The Nuklear single-header library allows to show the file dialog using only OpenGL. There's no need to use DBus.

yurivict avatar Feb 26 '22 15:02 yurivict

DPF can do it too with sofd, but only for opening not for saving. text input is not an easy thing to do.

falkTX avatar Feb 26 '22 15:02 falkTX

Nuklear allows to type in text. There are examples there.

yurivict avatar Feb 26 '22 15:02 yurivict

Yes I know. but works quite differently, I cant simply copy&paste that code, it is not how it works.

falkTX avatar Feb 26 '22 15:02 falkTX

Can't File/Save dialog be reduced to just one function?

yurivict avatar Feb 26 '22 16:02 yurivict

No, we dont have such native dialogs on linux, we always need custom code. This is clearly not simple https://github.com/DISTRHO/DPF/blob/develop/distrho/extra/sofd/libsofd.c

falkTX avatar Feb 26 '22 16:02 falkTX

Portentially fixed in 05cac6e738e5c4811aa7131fff99f9c08fef8e41, testing is welcome. Still requires a desktop portal thing, but now it will try to automatically start it if not available.

falkTX avatar Mar 28 '22 13:03 falkTX

Works for me on debian bullseye!

Should take care of the majority of cases at least (I expect this to still fail on devuan which has a broken xdg-desktop-portal package).

dromer avatar Mar 28 '22 14:03 dromer

The "Save as/Export..." dialogue doesn't appear for me in Cardinal 22.04 (standalone or as a plugin inside Carla). The "Open/Import..." dialogue works, though.

I'm running Arch Linux with i3, so without a full-fledged desktop environment. I've tried installing xdg-desktop-portal-gtk and xdg-desktop-portal-gnome, but I get the same results. Do I need to install anything else?

maxigaz avatar Apr 10 '22 10:04 maxigaz

I think those are the ones to install, but you need to be running xdg-desktop-portal in order for the dbus service to be available.

falkTX avatar Apr 10 '22 13:04 falkTX

I've found that there are systemd service files for both xdg-desktop-portal-gtk and xdg-desktop-portal-gnome. I can run them with systemctl (e.g. systemctl xdg-desktop-portal-gtk --user), but no change.

Running systemctl enable shows a message that these unit files are not meant to be enabled manually.

I've even tried running /usr/lib/xdg-desktop-portal-gtk, what the unit file points to, from a terminal. Still no dialogue for saving.

Edit: With some help, I managed to figure it out. I also needed xdg-desktop-portal itself in addition to xdg-desktop-portal-gtk. With both installed, It's working now.

maxigaz avatar Apr 10 '22 20:04 maxigaz

I think the right command for the start is

systemctl --user --start xdg-desktop-portal-gtk

but well, quite a few things are moving into the desktop portal direction, special sandboxed applications like snap and flathub. this ends up being a system problem.

if you have suggestions on how to make this better, I am all ears, but the approach to the file dialogs is not really changing in meaningful ways.

falkTX avatar Apr 10 '22 21:04 falkTX

After some more testing, here's what else I've found:

  • Running Firefox automatically triggers the portal service, so after that no manual action is required.
  • If the service is not running (i.e. Firefox hasn't been run at least once during a login session), I need to select File > Save/Export... inside Cardinal twice. (The service is started the first time, and the dialogue appears the second time.)
  • systemctl enable xdg-desktop-portal --user can be used to run the service manually.
  • At least under Arch Linux and i3, having xdg-desktop-portal-gnome installed in addition to xdg-desktop-portal and xdg-desktop-portal-gtk seems to introduce some issues: The dialogue doesn't follow the system theme and typing every other character in the filename field shifts focus to the search field, which makes it borderline unusable. Uninstalling xdg-desktop-portal-gnome solved it all for me.

maxigaz avatar Apr 11 '22 11:04 maxigaz

  • Running Firefox automatically triggers the portal service, so after that no manual action is required.

  • If the service is not running (i.e. Firefox hasn't been run at least once during a login session), I need to select File > Save/Export... inside Cardinal twice. (The service is started the first time, and the dialogue appears the second time.)

This sounds very much like a bug we had before and that was fixed. You sure you are running 22.04?

  • systemctl enable xdg-desktop-portal --user can be used to run the service manually.

Will add this info to the FAQ, thanks

  • At least under Arch Linux and i3, having xdg-desktop-portal-gnome installed in addition to xdg-desktop-portal and xdg-desktop-portal-gtk seems to introduce some issues: The dialogue doesn't follow the system theme and typing every other character in the filename field shifts focus to the search field, which makes it borderline unusable. Uninstalling xdg-desktop-portal-gnome solved it all for me.

Something to report upstream.

falkTX avatar Apr 11 '22 13:04 falkTX