diff --git a/Cargo.lock b/Cargo.lock index a7a7a34..4d45812 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2978,6 +2978,7 @@ dependencies = [ "rfd", "serde", "syntect", + "tinyfiledialogs", "wasm-bindgen-futures", "winres", ] @@ -3591,6 +3592,16 @@ dependencies = [ "strict-num", ] +[[package]] +name = "tinyfiledialogs" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e25fa0bc43a6566e2cc6d7ac96df3fa5a57beba34445bead1b368ba8fe9ca568" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "tinyvec" version = "1.6.0" diff --git a/README.md b/README.md index 5a0d90c..d40147f 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,8 @@ SUBCOMMANDS: ## How to Build -On **Ubuntu**, you might need to install: `libxcb-shape0-dev` and `libxcb-xfixes0-dev`. +On **Ubuntu**, you might need to install: `libxcb-shape0-dev`, +`libxcb-xfixes0-dev` and `libglib2.0-dev`. ``` git clone https://github.com/ergrelet/resym.git && cd resym diff --git a/resym/Cargo.toml b/resym/Cargo.toml index 32d9758..58670d3 100644 --- a/resym/Cargo.toml +++ b/resym/Cargo.toml @@ -32,7 +32,6 @@ anyhow = "1.0" log = "0.4" memory_logger = { version = "0.1", features = ["blocking"] } crossbeam-channel = "0.5" -rfd = "0.11" # Note(ergrelet): `fancy-regex` is less performant than `onig` at the moment # but is more portable (i.e., compiles to wasm32) syntect = { version = "5.2", default-features = false, features=["default-fancy"] } @@ -41,10 +40,18 @@ ahash = { version = "0.8", default-features = false, features = [ "std", ] } -# Web: +# Non-Web +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +# Note(ergrlet): use `tinyfiledialogs` by default as it's quite portable on +# non-wasm platforms +tinyfiledialogs = "3.9" + +# Web [target.'cfg(target_arch = "wasm32")'.dependencies] console_error_panic_hook = "0.1" wasm-bindgen-futures = "0.4" +# Use rfd on wasm platforms, instead of `tinyfiledialogs` +rfd = "0.11" [target.'cfg(windows)'.build-dependencies] winres = "0.1" diff --git a/resym/src/resym_app.rs b/resym/src/resym_app.rs index 110c24a..2bb99ca 100644 --- a/resym/src/resym_app.rs +++ b/resym/src/resym_app.rs @@ -835,13 +835,15 @@ impl ResymApp { /// Function invoked on `Open PDB File` or when the Ctrl+O shortcut is used #[cfg(not(target_arch = "wasm32"))] fn start_open_pdb_file(&mut self, pdb_slot: PDBSlot) { - let file_path_opt = rfd::FileDialog::new() - .add_filter("PDB files (*.pdb)", &["pdb"]) - .pick_file(); + let file_path_opt = tinyfiledialogs::open_file_dialog( + "Select a PDB file", + "", + Some((&["*.pdb"], "PDB files (*.pdb)")), + ); if let Some(file_path) = file_path_opt { if let Err(err) = self .backend - .send_command(BackendCommand::LoadPDBFromPath(pdb_slot, file_path)) + .send_command(BackendCommand::LoadPDBFromPath(pdb_slot, file_path.into())) { log::error!("Failed to load the PDB file: {err}"); } @@ -901,19 +903,16 @@ impl ResymApp { #[cfg(not(target_arch = "wasm32"))] fn start_save_reconstruted_content(&self) { if let ResymAppMode::Browsing(_, _, ref reconstructed_type) = self.current_mode { - let file_path_opt = rfd::FileDialog::new() - .add_filter( - "C/C++ Source File (*.c;*.cc;*.cpp;*.cxx;*.h;*.hpp;*.hxx)", - &["c", "cc", "cpp", "cxx", "h", "hpp", "hxx"], - ) - .save_file(); + let file_path_opt = tinyfiledialogs::save_file_dialog_with_filter( + "Save content to file", + "", + &["*.c", "*.cc", "*.cpp", "*.cxx", "*.h", "*.hpp", "*.hxx"], + "C/C++ Source File (*.c;*.cc;*.cpp;*.cxx;*.h;*.hpp;*.hxx)", + ); if let Some(file_path) = file_path_opt { let write_result = std::fs::write(&file_path, reconstructed_type); match write_result { - Ok(()) => log::info!( - "Reconstructed content has been saved to '{}'.", - file_path.display() - ), + Ok(()) => log::info!("Reconstructed content has been saved to '{file_path}'."), Err(err) => { log::error!("Failed to write reconstructed content to file: {err}"); }