google-chat-linux icon indicating copy to clipboard operation
google-chat-linux copied to clipboard

Is is possible to use the native Qt file chooser instead of the GTK one, on KDE

Open adrfantini opened this issue 3 years ago • 49 comments

As per title. On KDE, the native Qt file chooser (e.g. when uploading files) is much better than the GTK one, both in terms of looks and functionality. It'd be great if one could use that file chooser instead of the GTK one.

adrfantini avatar Aug 27 '21 08:08 adrfantini

I have absolutely no idea how electron is deciding what file chooser to use, I'll have a look. Best way to learn something new :)

squalou avatar Aug 27 '21 09:08 squalou

Awesome thanks!

adrfantini avatar Aug 27 '21 09:08 adrfantini

Reading this is interesting

https://tristan.partin.io/blog/2021/04/01/electron-linux-and-your-file-chooser/

From what I understand and to sum up things :

  • electron is based on chromium (we knew that)
  • chromium implements GTK only
  • there are things in GTK since 3.20 to allow a "use native file chooser"
  • ... but for ascendant compatibility reason electron will rely on GTK 3.18
  • and the auhtor of the article commited a fix to electron

All in all ... we need to wait for the electron release that will support it !

squalou avatar Aug 27 '21 10:08 squalou

Uhm, my chrome on both Arch and Ubuntu uses the native Qt file picker (via Kdialog, I think). I'm not sure if this is due to distribution-side patching, but I doubt it since Arch tends to ship vanilla software.

adrfantini avatar Aug 27 '21 10:08 adrfantini

Hm, I may have read too fast.

check xdg-desktop-portal-kde is installed on your system

then export GTK_USE_PORTAL=1

and then gtk apps should open native file chooser (qt in your case)

so, from a terminal, export GTK_USE_PORTAL=1; /opt/google-chat-linux/google-chat-linux

finger crossed it will maybe work ?

squalou avatar Aug 28 '21 11:08 squalou

I'll test this on Monday and let you know!

adrfantini avatar Aug 28 '21 11:08 adrfantini

Sorry for the delay! Tested, but alas no workie :(

adrfantini avatar Aug 31 '21 06:08 adrfantini

after reading quickly here : https://github.com/electron/electron/pull/19159 looks like it could be supported this way in electron 14, at best.

That doesn't explain how it works in other electron-based apps that work correctly though.

strange, really.

maybe you could try with a local build, using electron@beta ? That is, if you wanna play with npm and node and such :)

edit package.json : replace existing electon 12 by 14,

       "devDependencies": {
-        "electron": "=12.0.2",
+        "electron": "=14.0.0",
         "electron-builder": ">=22.6.0"
       }
     },

follow readme build instruction

npm install
 export GTK_USE_PORTAL=1
./google-chat-linux.sh

squalou avatar Aug 31 '21 13:08 squalou

good news is : electron 14 has just been released today !

https://www.electronjs.org/releases/stable#14.0.0

I did a quick check, it's promising. (ugly but promising)

On my system with xfce, without setting any variable, it does work. Buttons display "gtk-cancel" and "gtk-open" which is ugly.

Then, setting the variable : file chooser fail entirely with error :

 Can't open portal file chooser: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.portal.Desktop was not provided by any .service files

which tends to prove that it has an effect. I probably simply miss the required portal package.

I may add a dependency in arch aur package (or at least a optional dependency), still doing some tests first.

squalou avatar Aug 31 '21 13:08 squalou

Thanks! I'll check it out. Even though I'm not sure when electron 14 will be available for my work laptop running Ubuntu.

adrfantini avatar Aug 31 '21 20:08 adrfantini

I've just built a .deb for a quick test, you can try it, get it there :

https://github.com/squalou/google-chat-linux/releases/download/test-e14/google-chat-linux_5.14.1-1_amd64.deb

squalou avatar Sep 01 '21 07:09 squalou

Unfortunately I still have the GTK file picker on Kubuntu 20.04 LTS.

adrfantini avatar Sep 01 '21 07:09 adrfantini

Then, setting the variable : file chooser fail entirely with error :


 Can't open portal file chooser: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.portal.Desktop was not provided by any .service files

which tends to prove that it has an effect. I probably simply miss the required portal package.

I may add a dependency in arch aur package (or at least a optional dependency), still doing some tests first.

Random user stopping by, do you have xdg-desktop-portal installed? That is a completely necessary dependency for the portal to work.

vchernin avatar Sep 01 '21 07:09 vchernin

Then, setting the variable : file chooser fail entirely with error :


 Can't open portal file chooser: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.portal.Desktop was not provided by any .service files

which tends to prove that it has an effect. I probably simply miss the required portal package. I may add a dependency in arch aur package (or at least a optional dependency), still doing some tests first.

Random user stopping by, do you have xdg-desktop-portal installed? That is a completely necessary dependency for the portal to work.

I do, 1.6.0-1. Still nothing. And no logs on console specific to when I open the file picker, I would say. (thanks for stopping by!)

adrfantini avatar Sep 01 '21 07:09 adrfantini

too bad my other computers running ubuntu are using gnome. I may try a VM quickly, that's weird it really should work once you have set GTK_USE_PORTAL=1

squalou avatar Sep 01 '21 07:09 squalou

From Kubuntu LTS, vanilla liveCD (not even installed), then just installed the .deb : looks like it works. (even without GTK_USE_PORTAL apparently)

Here's what appears when I click the "upload file" button in a room

image

squalou avatar Sep 01 '21 07:09 squalou

Wait, no, maybe then it's not clear what I mean. This is the correct Qt file picker that pops up from Chrome on Kubuntu: Screenshot_20210901_095811

adrfantini avatar Sep 01 '21 07:09 adrfantini

Ah, damn ! never used Plasma before, I thought the one I saw had non-gtk look enough to be convinced it worked :)

Do you have the same as in my screenshot at least ? with whatever version ?

squalou avatar Sep 01 '21 08:09 squalou

Do you have the same as in my screenshot at least ? with whatever version ?

Yes, I do. As far as I understand that is the qt-fyied version of the GTK file picker using the native plasma translation layer between the two that tries to integrate GTK apps into the Qt environment.

(my bad, I should have provided screenshots)

adrfantini avatar Sep 01 '21 08:09 adrfantini

I've tried to remove xdg-desktop-portal on the kubuntu VM, set the env variable, or any combination of the two : I see the same thing as you. No error on console, and no native picker displayed. (but yet, a picker displayed, no error)

So there's something different from what happens on my arch laptop. ... really but no idea what.

squalou avatar Sep 01 '21 08:09 squalou

also tried kde neon distrib, latest plasma DE on ubuntu LTS => same result. There's something I don't get. Arch gives xdg-desktop-portal 1.8 whereas ubuntu lts gives 1.6 but ... considering early development of electron patch dates back to 2019 I don't see how it would make any difference. Will have to try another distrib, maybe kubuntu 21.04

squalou avatar Sep 01 '21 11:09 squalou

same result with kunbuntu 21.04 and xdg-desktop-portal 1.8 ... I'm totally clueless

squalou avatar Sep 01 '21 11:09 squalou

final test using Anarchy installer in a VM, with KDE and xdg-desktop-portal

git clone, npm install, run : looks better. (I mean : looks like there's an effect)

BUT not satisfying yet, as it apparently still launches a gtk-thing (from the button labels)

image

squalou avatar Sep 01 '21 12:09 squalou

@vchernin if you ever happen to step by again, any further idea will be welcome ;-)

squalou avatar Sep 01 '21 12:09 squalou

@adrfantini you may want to try this

https://forum.manjaro.org/t/change-firefox-file-manager/54760

and check if it works fine with firefox.

If so ... it would mean that somehow electron is still having issues.

I did the test in a Kubuntu VM : looks fine for firefox. ...

as for Chromium working :

As I understand it Chromium might be moving in a direction where they always use the ChromiumOS file chooser and not native toolkits also. So Electron probably wants to retain that native integration. (I pointed them in the direction of the file chooser portal but I don't really follow Chromium much)

squalou avatar Sep 01 '21 13:09 squalou

git clone, npm install, run : looks better. (I mean : looks like there's an effect)

BUT not satisfying yet, as it apparently still launches a gtk-thing (from the button labels) final test using Anarchy installer in a VM, with KDE and xdg-desktop-portal

As far as I can what you saw here looks correct. It looks extremely close to the Chrome example above.

I don't think the gtk-open is anything to be worried about, maybe it's a bug though that can be improved. It even says xdg-desktop-portal-kde above.

The question is then what is Ubuntu doing wrong here.

What version of xdg-desktop-portal and associated backend packages (xdg-desktop-portal-kde, maybe xdg-desktop-portal-gtk, etc.) were installed when you did this test? Which ones did you have when you tried on Ubuntu? Maybe try installing the same packages from here on Ubuntu?

xdg-desktop-portal-gtk for one shouln't really be necessary on KDE for this. But maybe it's involved I'm not sure.

I would have offered to help more directly but my internet is currently not suitable to download a bunch of ISOs :(

vchernin avatar Sep 01 '21 15:09 vchernin

I managed to install this on a Fedora 34 KDE vm I forgot I had...

git clone https://github.com/squalou/google-chat-linux
cd google-chat-linux
git checkout e14
sudo dnf install nodejs
npm install
./google-chat-linux.sh

I didn't work with whatever I had out of the box with xdg-desktop-portal 1.8.1 and xdg-desktop-portal-kde 5.22.4 installed.

Time to play around with things...

Edit: I was on the wrong branch...

Edit 2: I still can't get things to work after trying various combinations.

vchernin avatar Sep 01 '21 15:09 vchernin

Firefox works reliably with GTK_USE_PORTAL=1, but that variable seems to have no effect here.

Having xdg-desktop-portal-gtk also present doesn't change anything either.

I did notice something somewhat suspicious in the log when starting the app:

useXdgOpen: false

Could that be the cause?

Edit: no doesn't look like it changes anything :(

vchernin avatar Sep 01 '21 15:09 vchernin

Chromium shows you the KDE dialog because it shells out to an external kdialog process.

tristan957 avatar Sep 01 '21 16:09 tristan957

@squalou so were you able to get it to work?

tristan957 avatar Sep 01 '21 16:09 tristan957