Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Dialog not showing up with xdg-desktop-portal > 1.16 #157

Open
RenjiSann opened this issue Nov 2, 2023 · 13 comments
Open

[BUG] Dialog not showing up with xdg-desktop-portal > 1.16 #157

RenjiSann opened this issue Nov 2, 2023 · 13 comments

Comments

@RenjiSann
Copy link

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,

@RenjiSann
Copy link
Author

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",
] }

@alerque
Copy link

alerque commented Nov 2, 2023

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.

@LIMPIX31
Copy link

LIMPIX31 commented Nov 25, 2023

I have encountered this problem in tauri with xdg-desktop-portal-hyprland

@Friz64
Copy link

Friz64 commented Nov 27, 2023

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

@PolyMeilex
Copy link
Owner

PolyMeilex commented Nov 27, 2023

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

@Blist
Copy link

Blist commented Dec 15, 2023

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.

@LIMPIX31
Copy link

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.

@PolyMeilex
Copy link
Owner

That's unrelated, Tauri does not use xdp backend

@mibuthu
Copy link

mibuthu commented Feb 18, 2024

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.

@PolyMeilex
Copy link
Owner

PolyMeilex commented Feb 18, 2024

How about master? We updated ashpd perhaps that helps somehow

@mibuthu
Copy link

mibuthu commented Feb 19, 2024

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

@PolyMeilex
Copy link
Owner

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.

@mibuthu
Copy link

mibuthu commented Feb 26, 2024

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(&current_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(&current_dir)
        .pick_folder()
        .unwrap_or(current_dir)
        .to_string_lossy()
        .to_string()
        .into();
    println!("New dir: {}", new_dir.display());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants