From 3f81e125f13f39ad17d232ae7df3ea172fe7a50e Mon Sep 17 00:00:00 2001 From: Felitendo Date: Tue, 15 Sep 2026 14:52:50 +0200 Subject: [PATCH] feat: use the desktop's file picker on linux --- README.md | 5 +++ ...e-the-desktop-s-file-picker-on-Linux.patch | 39 +++++++++++++++++++ scripts/check.sh | 2 + 3 files changed, 46 insertions(+) create mode 100644 patches/0015-Use-the-desktop-s-file-picker-on-Linux.patch diff --git a/README.md b/README.md index fa3f934..4cf4f36 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ works. | `0012-Launch-a-running-instance-...` | A running instance can be started again on another account, with a console per copy. | | `0013-Explain-what-went-wrong-...` | The Logs tab says what a crash was and offers a fix where there is one, without a connection. | | `0014-Browse-skins-from-...` | A Browse tab on the skin page: Ely.by's catalogue in the app, and NameMC, laby.net and crafty.gg in a window. | +| `0015-Use-the-desktop-s-file-picker-...` | File pickers on Linux are the desktop's own, such as KDE's, through the XDG desktop portal. | ### Offline accounts @@ -96,6 +97,10 @@ A click with the middle mouse button on anything that scrolls starts autoscroll: to scroll until the next click, or hold and drag to scroll until you let go. Links and text fields keep their middle-click. Windows is left alone, since WebView2 autoscrolls by itself. +File pickers on Linux go through the XDG desktop portal, so KDE shows its own dialog and GNOME its +own, instead of a GTK dialog the AppImage themes as light Adwaita. Without a portal, GTK's dialog is +used as before. Windows and macOS already use their native pickers. + ### Skins With an Ely.by account selected, the skin page shows the account's skins on Ely.by: apply one, add diff --git a/patches/0015-Use-the-desktop-s-file-picker-on-Linux.patch b/patches/0015-Use-the-desktop-s-file-picker-on-Linux.patch new file mode 100644 index 0000000..31d1a7d --- /dev/null +++ b/patches/0015-Use-the-desktop-s-file-picker-on-Linux.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Modrinth Enhanced +Date: Tue, 15 Sep 2026 14:25:43 +0200 +Subject: [PATCH] Use the desktop's file picker on Linux + +File pickers - the webview's own, like the skin page's, and the dialog +plugin's - are GtkFileChooserNative on Linux, which only uses the XDG +desktop portal when asked. Unasked, it draws a GTK dialog, and inside the +AppImage that dialog is themed as light Adwaita whatever the desktop +looks like. GTK_USE_PORTAL is now set at startup, so KDE shows its own +file dialog and GNOME its own. A player who set it already keeps their +value, and without a portal GTK falls back to its own dialog as before. + +Windows and macOS already use the native pickers. +--- + apps/app/src/main.rs | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/apps/app/src/main.rs b/apps/app/src/main.rs +index 04eedbd..4c269a3 100644 +--- a/apps/app/src/main.rs ++++ b/apps/app/src/main.rs +@@ -115,6 +115,16 @@ async fn set_restart_after_pending_update( + // if Tauri app is called with arguments, then those arguments will be treated as commands + // ie: deep links or filepaths for .mrpacks + fn main() { ++ // File pickers on Linux - the webview's own and the dialog plugin's, both ++ // GtkFileChooserNative - go through the desktop portal, so KDE and GNOME ++ // show their own dialog rather than a GTK one the AppImage themes as ++ // Adwaita. Without a portal, GTK falls back to its own dialog. ++ #[cfg(target_os = "linux")] ++ if std::env::var_os("GTK_USE_PORTAL").is_none() { ++ // SAFETY: nothing else is running yet. ++ unsafe { std::env::set_var("GTK_USE_PORTAL", "1") }; ++ } ++ + #[cfg(feature = "export-app-events")] + theseus::export_app_event_bindings( + std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) diff --git a/scripts/check.sh b/scripts/check.sh index 7f30543..2e83bcb 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -156,6 +156,8 @@ check "its corners are rounded" \ contains "$WORKTREE/apps/app-frontend/src/App.vue" "'rounded-window'" check "the middle button autoscrolls" \ contains "$WORKTREE/apps/app-frontend/src/App.vue" 'installAutoscroll()' +check "file pickers use the desktop portal on Linux" \ + contains "$WORKTREE/apps/app/src/main.rs" 'set_var("GTK_USE_PORTAL", "1")' log "No advertising or upsells" check "no Modrinth+ upsell in the app" \