diff --git a/Cargo.lock b/Cargo.lock index 930a7a7..9eb9b5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -260,6 +260,12 @@ dependencies = [ "crossbeam-utils 0.8.20", ] +[[package]] +name = "configparser" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e57e3272f0190c3f1584272d613719ba5fc7df7f4942fe542e63d949cf3a649b" + [[package]] name = "core-foundation" version = "0.9.4" @@ -1659,6 +1665,7 @@ dependencies = [ "async-channel", "async-trait", "chrono", + "configparser", "crossbeam-utils 0.8.20", "deb822-tools", "duct", diff --git a/Cargo.toml b/Cargo.toml index 53a5a1d..4ca837c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,4 +42,5 @@ libflatpak = { version = "0.5.0", package = "libflatpak", features = ["v1_11_1"] regex = "1.10.6" duct = "0.13.7" reqwest = { version = "0.11", features = ["blocking"] } +configparser = "3.1.0" diff --git a/src/bin/gui/flatpak_manage_page/install_ref_dialog.rs b/src/bin/gui/flatpak_manage_page/install_ref_dialog.rs index 908c3b0..bb7c8de 100644 --- a/src/bin/gui/flatpak_manage_page/install_ref_dialog.rs +++ b/src/bin/gui/flatpak_manage_page/install_ref_dialog.rs @@ -22,6 +22,7 @@ use std::io::Write; use libflatpak::InstalledRef; use std::fs::OpenOptions; use pretty_bytes::converter::convert; +use configparser::ini::Ini; pub fn install_ref_dialog_fn( @@ -180,7 +181,28 @@ pub fn install_ref_dialog_fn( if !flatpak_ref_install_flatref_path_entry_clone0.text().is_empty() { - flatpak_ref_install_dialog_clone0.set_response_enabled("flatpak_ref_install_dialog_add", true); + match std::fs::read_to_string(flatpak_ref_install_flatref_path_entry_clone0.text()) { + Ok(t) => { + let mut flatref_file = Ini::new(); + match flatref_file.read(t) { + Ok(_) => { + let ref_name = flatref_file.get("Flatpak Ref", "Name"); + let ref_remote_name = flatref_file.get("Flatpak Ref", "SuggestRemoteName"); + //Write text + flatpak_ref_install_dialog_clone0.set_response_enabled("flatpak_ref_install_dialog_add", true); + } + Err(_) => { + // Delete Text + flatpak_ref_install_dialog_clone0.set_response_enabled("flatpak_ref_install_dialog_add", false); + } + } + } + Err(_) => { + // Delete Text + flatpak_ref_install_dialog_clone0.set_response_enabled("flatpak_ref_install_dialog_add", false); + } + } + // Write Text } else { flatpak_ref_install_dialog_clone0.set_response_enabled("flatpak_ref_install_dialog_add", false); }