Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

Merge origin/main into #260 (keep both new HostHooks fields: run_dialog, open_url)

MrCloudy282242c38171c
diff --cc apps/filmcraft/src/main.rs
index 307908dc6,591bc00fb..d0870b642
--- a/apps/filmcraft/src/main.rs
+++ b/apps/filmcraft/src/main.rs
@@@ -231,14 -236,12 +236,19 @@@ fn main() -> eframe::Result
app.hooks.pick_folder = Some(Box::new(|| rfd::FileDialog::new().pick_folder().map(|p| p.to_string_lossy().to_string())));
app.hooks.pick_folder_at =
Some(Box::new(|dir: &str| rfd::FileDialog::new().set_directory(dir).pick_folder().map(|p| p.to_string_lossy().into_owned())));
+ // Linux: the XDG portal call blocks until the user chooses, which would stop the frame
+ // loop (GNOME offers to force-quit the window after about five seconds, #260). Show the
+ // dialog on its own thread instead; the app keeps running and acts on the answer.
+ #[cfg(target_os = "linux")]
+ {
+ app.hooks.run_dialog = Some(Box::new(run_dialog_off_thread));
+ }
app.hooks.open_path = Some(Box::new(open_path));
+ // Help menu, About and Discord links (#642): eframe is built without its `links`
+ // feature, so `ctx.open_url` does nothing on the desktop. Detached, so a launcher
+ // that waits for the browser never freezes the UI.
+ app.hooks.open_url = Some(Box::new(|url: &str| open::that_detached(url).map_err(|e| e.to_string())));
+ app.hooks.clipboard_media = Some(Box::new(clipboard_media));
// Settings ▸ General ▸ Interface Language ▸ System Language (#218).
app.hooks.cursor_screen_position = Some(Box::new(filmcraft_platform::cursor::cursor_screen_position));
app.hooks.system_languages = Some(Box::new(|| sys_locale::get_locales().collect()));
diff --cc crates/ui-egui/src/lib.rs
index 4e4982eb3,2bfa8a561..533b36654
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@@ -141,11 -139,10 +141,15 @@@ pub struct HostHooks
/// Open a file in its default application, or (`true`) reveal it in the file manager (Edit ▸
/// Edit Original, Help ▸ Reveal Log Files).
pub open_path: Option<Box<dyn FnMut(&str, bool) -> Result<(), String>>>,
+ /// Show a file dialog without blocking the UI thread and answer on the returned channel with
+ /// the chosen paths (none: cancelled). With it, [`FilmcraftApp::pick`] keeps the frame loop
+ /// running while the dialog is open (the desktop app on Linux, #260); without it the
+ /// synchronous pickers above are used.
+ pub run_dialog: Option<Box<dyn FnMut(native_dialogs::FileDialog) -> Receiver<Vec<String>>>>,
+ /// Open a URL in the system browser (Help menu links, About dialog, Discord button, Import
+ /// screen). Without it, or when it fails, links go through `egui::Context::open_url`, which
+ /// opens a new tab on the web (the native egui backend is built without its `links` feature).
+ pub open_url: Option<Box<dyn FnMut(&str) -> Result<(), String>>>,
/// The operating system's light or dark appearance when egui cannot report it (Linux desktops
/// whose Wayland compositor sends no theme to winit). Without it, or without an answer, Auto
/// uses `egui::Context::system_theme`.