diff --git a/pot-browser/Cargo.toml b/pot-browser/Cargo.toml index d8c26ed6e..7174f4682 100644 --- a/pot-browser/Cargo.toml +++ b/pot-browser/Cargo.toml @@ -28,7 +28,10 @@ bytesize.workspace = true camino.workspace = true anyhow.workspace = true url.workspace = true -opener = { version = "0.7.1", features = ["reveal"] } [target.'cfg(target_os = "macos")'.dependencies] -rfd = "0.12.1" \ No newline at end of file +rfd = "0.12.1" + +[target.'cfg(not(all(target_os = "windows", target_arch = "x86")))'.dependencies] +# This doesn't work on win32 +opener = { version = "0.7.1", features = ["reveal"] } diff --git a/pot-browser/src/pot_browser_panel.rs b/pot-browser/src/pot_browser_panel.rs index 0d555d247..62fbee232 100644 --- a/pot-browser/src/pot_browser_panel.rs +++ b/pot-browser/src/pot_browser_panel.rs @@ -1367,7 +1367,7 @@ fn process_dialogs(input: ProcessDialogsInput, ctx: |ui, change_dialog| { if ui.button("Close").clicked() { if let PreviewOutputConfig::Export(c) = output_config_clone { - reveal(c.base_dir.as_std_path()); + reveal_path(c.base_dir.as_std_path()); } *change_dialog = Some(None); }; @@ -1634,7 +1634,7 @@ fn add_preset_table(mut input: PresetTableInput, ui: &mut Ui, preset_cache: &mut if let pot::PotPresetKind::FileBased(k) = &data.preset.kind { if ui.button("Show preset in file manager").clicked() { if k.path.exists() { - reveal(&k.path); + reveal_path(&k.path); } else { show_error_toast( "Preset file doesn't exist", @@ -1646,7 +1646,7 @@ fn add_preset_table(mut input: PresetTableInput, ui: &mut Ui, preset_cache: &mut } if let Some(preview_file) = &data.preview_file { if ui.button("Show preview in file manager").clicked() { - reveal(preview_file); + reveal_path(preview_file); ui.close_menu(); } } @@ -3480,20 +3480,42 @@ fn get_preview_rpp_path( fn open_link(thing: &str) { if thing.starts_with("file://") { - reveal(Path::new(thing)); + reveal_path(Path::new(thing)); } else { - let _ = opener::open_browser(thing); + #[cfg(not(all(target_os = "windows", target_arch = "x86")))] + { + if opener::open_browser(thing).is_err() { + open_link_fallback(thing); + } + } + #[cfg(all(target_os = "windows", target_arch = "x86"))] + { + open_link_fallback(thing); + } } } -fn reveal(path: impl AsRef) { +fn open_link_fallback(link: &str) { + Reaper::get().show_console_msg(format!( + "Failed to open the following link in your browser. Please open it manually:\n\n{link}\n\n" + )); +} + +fn reveal_path(path: impl AsRef) { let path = path.as_ref(); - if opener::reveal(path).is_err() { - reveal_fallback(path); + #[cfg(not(all(target_os = "windows", target_arch = "x86")))] + { + if opener::reveal(path).is_err() { + reveal_path_fallback(path); + } + } + #[cfg(all(target_os = "windows", target_arch = "x86"))] + { + reveal_path_fallback(path); } } -fn reveal_fallback(path: &Path) { +fn reveal_path_fallback(path: &Path) { Reaper::get().show_console_msg( format!("Failed to open the following path in your file manager. Please open it manually:\n\n{path:?}\n\n") );