Skip to content

linux: use GTK_USE_PORTAL=1 to support the XDG Desktop Portal - #126113

Closed
Tristan Partin (tristan957) wants to merge 1 commit into
microsoft:mainfrom
tristan957:gtk-use-portal
Closed

Tristan Partin (tristan957) wants to merge 1 commit into
microsoft:mainfrom
tristan957:gtk-use-portal

Conversation

@tristan957

@tristan957 Tristan Partin (tristan957) commented Jun 12, 2021 •

Copy link
Copy Markdown

Electron 14 will have support for file managers through the XDG Desktop
Portal Specification. In order to explicitly opt into support assuming
a user has an xdg-desktop-portal-* package installed, GTK needs to be
told to use it. This will allow for alternative file managers on KDE or
wlroots-based systems.

This PR fixes #50386 amongst others, once VSCode adopts Electron v14.

Comment thread resources/linux/bin/code.sh Resolved
@Ashark

Copy link
Copy Markdown

Tristan Partin (@tristan957) I have built the vscodium (also tried vscodium-git from aur) with your patch. And it did not work. Then I have found out how to check electron version of app (from here). Surprisingly, it was 13.5.1. But I only have the electron package in system, which is currently v15.2.0. So it looks like vscodium brings its own electron 13.

Now the question is, is it possible to switch it to use system's version of electron?

@deepak1556 Robo (deepak1556) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM following Electron 16 update to main branch.

@tristan957

Copy link
Copy Markdown
Author

Oh I did submit this PR...

Still wonder how necessary it is, but it probably wouldn't hurt.

@deepak1556

Copy link
Copy Markdown
Collaborator

yeah considering this more of a good thing to have with no negative side effects, I am fine with the change. Thanks for the PR!

@tristan957

Tristan Partin (tristan957) commented Feb 10, 2022 •

Copy link
Copy Markdown
Author

Should we set GTK_USE_PORTAL=1 unconditionally?

Edit: Oh wait...now I get it. Yea this is fine :). Didn't even remember the code

Is using export here correct? Probably don't want to pollute the parent environment.

@deepak1556

Copy link
Copy Markdown
Collaborator

Is using export here correct? Probably don't want to pollute the parent environment.

Yeah you are right, can you update the PR. Thanks!

Btw, this code path will get executed only user launches the application from the cli, if they are triggered from launchers then we might need to set it up in https://github.com/microsoft/vscode/blob/main/resources/linux/code.desktop

@tristan957

Copy link
Copy Markdown
Author

I think that should do it?

Electron 14 will have support for file managers through the XDG Desktop
Portal Specification. In order to explicitly opt into support assuming
a user has an xdg-desktop-portal-* package installed, GTK needs to be
told to use it. This will allow for alternative file managers on KDE or
wlroots-based systems.
@deepak1556

Copy link
Copy Markdown
Collaborator

I don't have a good way to verify this on my machine, would you be willing to verify the fix if I were to make a custom build from this branch ? Thanks!

@tristan957

Copy link
Copy Markdown
Author

I could give it a go. Need to break out my dbus-foo

@Moonlight63

Copy link
Copy Markdown

I just tried this on code-insiders build on electron 16. It didn't work.

@tristan957

Copy link
Copy Markdown
Author

What didn't work?

@Moonlight63

Copy link
Copy Markdown

Sorry, using the gtk protal env var didn't allow vscode to use the plasma filepicker when I tried it. I have since switched back to gnome so it no longer affects me, but I wonder if anyone else has gotten it working?

@tristan957

Copy link
Copy Markdown
Author

Dalen Catt (@Moonlight63) are you using a version of VSCode with electron >= v14 and do you have xdg-desktop-portal-kde installed?

@Moonlight63

Copy link
Copy Markdown

Yes, I did. I had vs code insiders and other applications like Firefox did respect the portal, but vs code still ignored it. Like I said, I just switched back to gnome.

@sonnyp Sonny Piers (sonnyp) left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GTK_USE_PORTAL was a debug flag and shouldn't be used. It has been moved to a flag in GDK_DEBUG for clarity.

Here is a small recap

Thanks to Tristan Partin (@tristan957) (thanks!) work in electron/electron#19159, Electron already use the native Linux file picker if it's running in a sandboxed env (Snap / Flatpak).

IIRC in order for Electron to always use the native file picker, even when not running sandboxed, Electron needs to swap GtkFileChooserNative for the new GtkFileDialog.

However, GtkFileDialog is only available in Gtk 4.10 . I don't know what Electron policy is regarding dependencies.

Should I file an issue on the Electron repository, and we can pick it up there?

I suggest closing this PR as it won't do anything.

@deepak1556

Copy link
Copy Markdown
Collaborator

Thanks for summarizing Sonny Piers (@sonnyp). Agree with closing this PR, as for gtk4 support it is currently tracked under electron/electron#33690

Additionally we would want to refactor the file dialog impl in Electron to reuse Chromium's impl, ref electron/electron#35110 (comment). I am looking into that as part of #146422

@tristan957
Tristan Partin (tristan957) deleted the gtk-use-portal branch April 28, 2023 15:05
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I set Dolphin as default file manager, but VSCode opens Nautilus instead of Dolphin

6 participants