rfd
rfd copied to clipboard
[BUG] Dialog not showing up with `xdg-desktop-portal > 1.16`
Hi,
I am running Arch Linux, with the 6.1 LTS kernel.
I have the xdg-desktop-portal (1.18.0)
installed with the xdg-desktop-portal-gtk (1.15.1)
backend.
When compiling rfd with the xdg-portal
feature, the dialog won't show up.
I was able to make it work by downgrading xdg-desktop-portal
to version 1.16, though, so this might be some breaking API changes.
Kind regards,
For references, here are my main.rs and Cargo.toml. I also add that everything works well when using the default feature flags with the gtk backend.
use rfd::FileDialog;
fn main() {
println!("Hello, world!");
let files = FileDialog::new()
.set_directory("/")
.pick_file();
println!("files: {:?}", files);
}
[package]
name = "test"
version = "0.1.0"
edition = "2021"
[dependencies]
rfd = { version = "0.12.1", default-features = false, features = [
"xdg-portal",
] }
I'm having similar issues. The main difference in my setup is I'm using xdg-desktop-portal-hyprland
as the backend instead of -gtk
.
I have encountered this problem in tauri with xdg-desktop-portal-hyprland
running cargo run --example save --no-default-features --features xdg-portal
works on both my desktop arch box running gnome and xdg-desktop-portal
1.18.2 as well as my fedora laptop running the same configuration
Name : xdg-desktop-portal
Version : 1.18.2
Name : xdg-desktop-portal-gtk
Version : 1.15.1
Name : xdg-desktop-portal-gnome
Version : 45.0
Works fine here.
@alerque
The main difference in my setup is I'm using xdg-desktop-portal-hyprland as the backend instead of -gtk.
hyperland portal does not provide a file picker, or anything beyond screen sharing. You have to have a portal that does next to hyperland portal. (You can, and should run both)
I have encountered this problem in tauri with xdg-desktop-portal-hyprland
@LIMPIX31 Probably same as above
(PS. just don't mistake freedesktop's gtk portal for gnome portal, as the former one will most likely not work for you on hyperland)
EDIT: Yep. hyperland wiki says the same thing: https://wiki.hyprland.org/Useful-Utilities/Hyprland-desktop-portal/#installing
Hello,
I come from Tauri v2 alpha here, and open a Dialog freeze the application. I'm using archlinux with wayland and hyprland, seems to be related to this. With the taui v1.3 version I don't have the problem.
Hello,
I come from Tauri v2 alpha here, and open a Dialog freeze the application. I'm using archlinux with wayland and hyprland, seems to be related to this. With the taui v1.3 version I don't have the problem.
The same. I have tried different versions of rfd and xdg-desktop-portal but no result.
That's unrelated, Tauri does not use xdp backend
For me a workaround is to pin the rfd version to 0.12.0:
rfd = "=0.12.0"
Change this to a newer version (e.g. 0.12.1) causes this issue again.
How about master? We updated ashpd perhaps that helps somehow
With master:
rfd = { git = "https://github.com/PolyMeilex/rfd.git", branch = "master" }
I still have the same issue as with version 0.12.1 or 0.13.0
How about now? Either master or new 0.14 XDG Backend now has zenity fallback. And XDG Backend is not the default, without the need to enable any features.
Great, for me the issue is solved with version 0.14.0.
==============
Some more information from my testing in the last days: I my case it seems to be an issue with a combination of rfd with some other framework (in my case slint).
The following minimal code was also working with the problematic versions 0.12.1 and 0.13.0:
use std::path::PathBuf;
fn main() {
rfd();
}
fn rfd() {
let current_dir = PathBuf::from("/tmp");
println!("Current dir: {}", current_dir.display());
let new_dir: PathBuf = rfd::FileDialog::new()
.set_title("Folder selection")
.set_directory(¤t_dir)
.pick_folder()
.unwrap_or(current_dir)
.to_string_lossy()
.to_string()
.into();
println!("New dir: {}", new_dir.display());
}
But adding slint to the party with the following code, the problem was reproducible:
use std::path::PathBuf;
slint::slint!{
import { Button } from "std-widgets.slint";
export component HelloWorld {
callback rfd;
Button {
text: "rfd";
clicked => { rfd() }
}
}
}
fn main() {
let app = HelloWorld::new().unwrap();
app.on_rfd({
move || {
rfd()
}
});
app.run().unwrap();
}
fn rfd() {
let current_dir = PathBuf::from("/tmp");
println!("Current dir: {}", current_dir.display());
let new_dir: PathBuf = rfd::FileDialog::new()
.set_title("Folder selection")
.set_directory(¤t_dir)
.pick_folder()
.unwrap_or(current_dir)
.to_string_lossy()
.to_string()
.into();
println!("New dir: {}", new_dir.display());
}