How to use the same file picker for QT and GTK apps
The file picker for GTK+ apps (eg. Firefox) looks like this:

For qt apps (eg. nomacs) it looks like this:

Is there a way to use the QT file picker for both GTK and QT apps?
I am running arch 4.20 with KDE installed.
arch-linux kde gtk qt
add a comment |
The file picker for GTK+ apps (eg. Firefox) looks like this:

For qt apps (eg. nomacs) it looks like this:

Is there a way to use the QT file picker for both GTK and QT apps?
I am running arch 4.20 with KDE installed.
arch-linux kde gtk qt
add a comment |
The file picker for GTK+ apps (eg. Firefox) looks like this:

For qt apps (eg. nomacs) it looks like this:

Is there a way to use the QT file picker for both GTK and QT apps?
I am running arch 4.20 with KDE installed.
arch-linux kde gtk qt
The file picker for GTK+ apps (eg. Firefox) looks like this:

For qt apps (eg. nomacs) it looks like this:

Is there a way to use the QT file picker for both GTK and QT apps?
I am running arch 4.20 with KDE installed.
arch-linux kde gtk qt
arch-linux kde gtk qt
edited Jan 13 at 20:44
HanMah
asked Jan 13 at 12:15
HanMahHanMah
62
62
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Generally, no. GTK and Qt have different file browser dialog windows because the file browser dialog window is an integral part of the toolkit, it's not some external module that you can simply swap with another.
That said, it's kind of possible, but only for GTK 3.20 and later. It will not affect GTK 2 programs. (Actually it won't affect all GTK 3 programs either, only some. Primarily it won't work with apps which add their own custom elements to the dialog, and then most others I don't know why. Fortunately, it works with Firefox, which is probably going to be 95% of your use case.)
To do this, you can force the GTK toolkit to use 'portals' – a Flatpak integration feature, which normally allows sandboxed programs to open various pickers on the host system (outside the sandbox) and receive the result. This necessarily means that the app/toolkit has to somehow call an external picker instead of using its built-in one, and said external picker can be swappable.
In this situation, you want to force-enable this feature without involving Flatpak, and there is a hidden option for that (although meant for developers only – and, as I've already mentioned, works for some apps only).
Additional warning: This is a very broad option and might cause many other operations to go through the 'portal' – such as desktop settings, proxy configuration, and so on. Your mileage may vary. Warranty void if seal broken.
You'll need to install two components:
The main portal service (broker), called xdg-desktop-portal.
The KDE portal implementation (user interface), called xdg-desktop-portal-kde.
As you're using KDE, it is enough to install these packages and they will be automatically started when needed. Skip the rest of this part and jump straight to step 3.
Meanwhile, those trying to do this within GNOME will need to start everything manually and add an environment variable forcing both components to use KDE behaviors. First start the KDE-specific implementation, telling it to disable Qt's usual "masquerade as GTK" thing:
XDG_CURRENT_DESKTOP="KDE" /usr/lib/xdg-desktop-portal-kde &
Then start the portal broker, using the same environment variable to make it choose the earlier-started KDE portal implementation and not the GNOME one:
XDG_CURRENT_DESKTOP="KDE" /usr/lib/xdg-desktop-portal &
Alternatively, to make everything automagically start via D-Bus, you might want to pass these environment variables to dbus-daemon and systemd instead:
dbus-update-activation-environment --systemd XDG_CURRENT_DESKTOP="KDE"
systemctl --user stop xdg-desktop-portal{,-gtk}
pkill -f xdg-desktop-portal
Finally, start your GTK3-based app, telling to use portals even outside Flatpak environment:
GTK_USE_PORTAL="1" zenity --file-selection
GTK_USE_PORTAL="1" firefox
From my tests, this works with Zenity, Firefox, GEdit, but does not work with Mousepad or Evince. (I haven't tested Chromium but it already has its own swappable file pickers anyway.)
Can you clarify how to do step 3? Should I write that to a file, to the terminal, or something else? How can I swap Chromium's file picker?
– HanMah
Jan 13 at 20:45
For anyone reading: I figured out how to do it. 1) Right click on the app 2) Click edit application 3) Go to Applications 4) In the box command prepend "GTK_USE_PORTAL=1 "
– HanMah
Jan 16 at 10:29
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1393755%2fhow-to-use-the-same-file-picker-for-qt-and-gtk-apps%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Generally, no. GTK and Qt have different file browser dialog windows because the file browser dialog window is an integral part of the toolkit, it's not some external module that you can simply swap with another.
That said, it's kind of possible, but only for GTK 3.20 and later. It will not affect GTK 2 programs. (Actually it won't affect all GTK 3 programs either, only some. Primarily it won't work with apps which add their own custom elements to the dialog, and then most others I don't know why. Fortunately, it works with Firefox, which is probably going to be 95% of your use case.)
To do this, you can force the GTK toolkit to use 'portals' – a Flatpak integration feature, which normally allows sandboxed programs to open various pickers on the host system (outside the sandbox) and receive the result. This necessarily means that the app/toolkit has to somehow call an external picker instead of using its built-in one, and said external picker can be swappable.
In this situation, you want to force-enable this feature without involving Flatpak, and there is a hidden option for that (although meant for developers only – and, as I've already mentioned, works for some apps only).
Additional warning: This is a very broad option and might cause many other operations to go through the 'portal' – such as desktop settings, proxy configuration, and so on. Your mileage may vary. Warranty void if seal broken.
You'll need to install two components:
The main portal service (broker), called xdg-desktop-portal.
The KDE portal implementation (user interface), called xdg-desktop-portal-kde.
As you're using KDE, it is enough to install these packages and they will be automatically started when needed. Skip the rest of this part and jump straight to step 3.
Meanwhile, those trying to do this within GNOME will need to start everything manually and add an environment variable forcing both components to use KDE behaviors. First start the KDE-specific implementation, telling it to disable Qt's usual "masquerade as GTK" thing:
XDG_CURRENT_DESKTOP="KDE" /usr/lib/xdg-desktop-portal-kde &
Then start the portal broker, using the same environment variable to make it choose the earlier-started KDE portal implementation and not the GNOME one:
XDG_CURRENT_DESKTOP="KDE" /usr/lib/xdg-desktop-portal &
Alternatively, to make everything automagically start via D-Bus, you might want to pass these environment variables to dbus-daemon and systemd instead:
dbus-update-activation-environment --systemd XDG_CURRENT_DESKTOP="KDE"
systemctl --user stop xdg-desktop-portal{,-gtk}
pkill -f xdg-desktop-portal
Finally, start your GTK3-based app, telling to use portals even outside Flatpak environment:
GTK_USE_PORTAL="1" zenity --file-selection
GTK_USE_PORTAL="1" firefox
From my tests, this works with Zenity, Firefox, GEdit, but does not work with Mousepad or Evince. (I haven't tested Chromium but it already has its own swappable file pickers anyway.)
Can you clarify how to do step 3? Should I write that to a file, to the terminal, or something else? How can I swap Chromium's file picker?
– HanMah
Jan 13 at 20:45
For anyone reading: I figured out how to do it. 1) Right click on the app 2) Click edit application 3) Go to Applications 4) In the box command prepend "GTK_USE_PORTAL=1 "
– HanMah
Jan 16 at 10:29
add a comment |
Generally, no. GTK and Qt have different file browser dialog windows because the file browser dialog window is an integral part of the toolkit, it's not some external module that you can simply swap with another.
That said, it's kind of possible, but only for GTK 3.20 and later. It will not affect GTK 2 programs. (Actually it won't affect all GTK 3 programs either, only some. Primarily it won't work with apps which add their own custom elements to the dialog, and then most others I don't know why. Fortunately, it works with Firefox, which is probably going to be 95% of your use case.)
To do this, you can force the GTK toolkit to use 'portals' – a Flatpak integration feature, which normally allows sandboxed programs to open various pickers on the host system (outside the sandbox) and receive the result. This necessarily means that the app/toolkit has to somehow call an external picker instead of using its built-in one, and said external picker can be swappable.
In this situation, you want to force-enable this feature without involving Flatpak, and there is a hidden option for that (although meant for developers only – and, as I've already mentioned, works for some apps only).
Additional warning: This is a very broad option and might cause many other operations to go through the 'portal' – such as desktop settings, proxy configuration, and so on. Your mileage may vary. Warranty void if seal broken.
You'll need to install two components:
The main portal service (broker), called xdg-desktop-portal.
The KDE portal implementation (user interface), called xdg-desktop-portal-kde.
As you're using KDE, it is enough to install these packages and they will be automatically started when needed. Skip the rest of this part and jump straight to step 3.
Meanwhile, those trying to do this within GNOME will need to start everything manually and add an environment variable forcing both components to use KDE behaviors. First start the KDE-specific implementation, telling it to disable Qt's usual "masquerade as GTK" thing:
XDG_CURRENT_DESKTOP="KDE" /usr/lib/xdg-desktop-portal-kde &
Then start the portal broker, using the same environment variable to make it choose the earlier-started KDE portal implementation and not the GNOME one:
XDG_CURRENT_DESKTOP="KDE" /usr/lib/xdg-desktop-portal &
Alternatively, to make everything automagically start via D-Bus, you might want to pass these environment variables to dbus-daemon and systemd instead:
dbus-update-activation-environment --systemd XDG_CURRENT_DESKTOP="KDE"
systemctl --user stop xdg-desktop-portal{,-gtk}
pkill -f xdg-desktop-portal
Finally, start your GTK3-based app, telling to use portals even outside Flatpak environment:
GTK_USE_PORTAL="1" zenity --file-selection
GTK_USE_PORTAL="1" firefox
From my tests, this works with Zenity, Firefox, GEdit, but does not work with Mousepad or Evince. (I haven't tested Chromium but it already has its own swappable file pickers anyway.)
Can you clarify how to do step 3? Should I write that to a file, to the terminal, or something else? How can I swap Chromium's file picker?
– HanMah
Jan 13 at 20:45
For anyone reading: I figured out how to do it. 1) Right click on the app 2) Click edit application 3) Go to Applications 4) In the box command prepend "GTK_USE_PORTAL=1 "
– HanMah
Jan 16 at 10:29
add a comment |
Generally, no. GTK and Qt have different file browser dialog windows because the file browser dialog window is an integral part of the toolkit, it's not some external module that you can simply swap with another.
That said, it's kind of possible, but only for GTK 3.20 and later. It will not affect GTK 2 programs. (Actually it won't affect all GTK 3 programs either, only some. Primarily it won't work with apps which add their own custom elements to the dialog, and then most others I don't know why. Fortunately, it works with Firefox, which is probably going to be 95% of your use case.)
To do this, you can force the GTK toolkit to use 'portals' – a Flatpak integration feature, which normally allows sandboxed programs to open various pickers on the host system (outside the sandbox) and receive the result. This necessarily means that the app/toolkit has to somehow call an external picker instead of using its built-in one, and said external picker can be swappable.
In this situation, you want to force-enable this feature without involving Flatpak, and there is a hidden option for that (although meant for developers only – and, as I've already mentioned, works for some apps only).
Additional warning: This is a very broad option and might cause many other operations to go through the 'portal' – such as desktop settings, proxy configuration, and so on. Your mileage may vary. Warranty void if seal broken.
You'll need to install two components:
The main portal service (broker), called xdg-desktop-portal.
The KDE portal implementation (user interface), called xdg-desktop-portal-kde.
As you're using KDE, it is enough to install these packages and they will be automatically started when needed. Skip the rest of this part and jump straight to step 3.
Meanwhile, those trying to do this within GNOME will need to start everything manually and add an environment variable forcing both components to use KDE behaviors. First start the KDE-specific implementation, telling it to disable Qt's usual "masquerade as GTK" thing:
XDG_CURRENT_DESKTOP="KDE" /usr/lib/xdg-desktop-portal-kde &
Then start the portal broker, using the same environment variable to make it choose the earlier-started KDE portal implementation and not the GNOME one:
XDG_CURRENT_DESKTOP="KDE" /usr/lib/xdg-desktop-portal &
Alternatively, to make everything automagically start via D-Bus, you might want to pass these environment variables to dbus-daemon and systemd instead:
dbus-update-activation-environment --systemd XDG_CURRENT_DESKTOP="KDE"
systemctl --user stop xdg-desktop-portal{,-gtk}
pkill -f xdg-desktop-portal
Finally, start your GTK3-based app, telling to use portals even outside Flatpak environment:
GTK_USE_PORTAL="1" zenity --file-selection
GTK_USE_PORTAL="1" firefox
From my tests, this works with Zenity, Firefox, GEdit, but does not work with Mousepad or Evince. (I haven't tested Chromium but it already has its own swappable file pickers anyway.)
Generally, no. GTK and Qt have different file browser dialog windows because the file browser dialog window is an integral part of the toolkit, it's not some external module that you can simply swap with another.
That said, it's kind of possible, but only for GTK 3.20 and later. It will not affect GTK 2 programs. (Actually it won't affect all GTK 3 programs either, only some. Primarily it won't work with apps which add their own custom elements to the dialog, and then most others I don't know why. Fortunately, it works with Firefox, which is probably going to be 95% of your use case.)
To do this, you can force the GTK toolkit to use 'portals' – a Flatpak integration feature, which normally allows sandboxed programs to open various pickers on the host system (outside the sandbox) and receive the result. This necessarily means that the app/toolkit has to somehow call an external picker instead of using its built-in one, and said external picker can be swappable.
In this situation, you want to force-enable this feature without involving Flatpak, and there is a hidden option for that (although meant for developers only – and, as I've already mentioned, works for some apps only).
Additional warning: This is a very broad option and might cause many other operations to go through the 'portal' – such as desktop settings, proxy configuration, and so on. Your mileage may vary. Warranty void if seal broken.
You'll need to install two components:
The main portal service (broker), called xdg-desktop-portal.
The KDE portal implementation (user interface), called xdg-desktop-portal-kde.
As you're using KDE, it is enough to install these packages and they will be automatically started when needed. Skip the rest of this part and jump straight to step 3.
Meanwhile, those trying to do this within GNOME will need to start everything manually and add an environment variable forcing both components to use KDE behaviors. First start the KDE-specific implementation, telling it to disable Qt's usual "masquerade as GTK" thing:
XDG_CURRENT_DESKTOP="KDE" /usr/lib/xdg-desktop-portal-kde &
Then start the portal broker, using the same environment variable to make it choose the earlier-started KDE portal implementation and not the GNOME one:
XDG_CURRENT_DESKTOP="KDE" /usr/lib/xdg-desktop-portal &
Alternatively, to make everything automagically start via D-Bus, you might want to pass these environment variables to dbus-daemon and systemd instead:
dbus-update-activation-environment --systemd XDG_CURRENT_DESKTOP="KDE"
systemctl --user stop xdg-desktop-portal{,-gtk}
pkill -f xdg-desktop-portal
Finally, start your GTK3-based app, telling to use portals even outside Flatpak environment:
GTK_USE_PORTAL="1" zenity --file-selection
GTK_USE_PORTAL="1" firefox
From my tests, this works with Zenity, Firefox, GEdit, but does not work with Mousepad or Evince. (I haven't tested Chromium but it already has its own swappable file pickers anyway.)
edited Jan 13 at 16:01
answered Jan 13 at 15:25
grawitygrawity
236k37498553
236k37498553
Can you clarify how to do step 3? Should I write that to a file, to the terminal, or something else? How can I swap Chromium's file picker?
– HanMah
Jan 13 at 20:45
For anyone reading: I figured out how to do it. 1) Right click on the app 2) Click edit application 3) Go to Applications 4) In the box command prepend "GTK_USE_PORTAL=1 "
– HanMah
Jan 16 at 10:29
add a comment |
Can you clarify how to do step 3? Should I write that to a file, to the terminal, or something else? How can I swap Chromium's file picker?
– HanMah
Jan 13 at 20:45
For anyone reading: I figured out how to do it. 1) Right click on the app 2) Click edit application 3) Go to Applications 4) In the box command prepend "GTK_USE_PORTAL=1 "
– HanMah
Jan 16 at 10:29
Can you clarify how to do step 3? Should I write that to a file, to the terminal, or something else? How can I swap Chromium's file picker?
– HanMah
Jan 13 at 20:45
Can you clarify how to do step 3? Should I write that to a file, to the terminal, or something else? How can I swap Chromium's file picker?
– HanMah
Jan 13 at 20:45
For anyone reading: I figured out how to do it. 1) Right click on the app 2) Click edit application 3) Go to Applications 4) In the box command prepend "GTK_USE_PORTAL=1 "
– HanMah
Jan 16 at 10:29
For anyone reading: I figured out how to do it. 1) Right click on the app 2) Click edit application 3) Go to Applications 4) In the box command prepend "GTK_USE_PORTAL=1 "
– HanMah
Jan 16 at 10:29
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1393755%2fhow-to-use-the-same-file-picker-for-qt-and-gtk-apps%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown