add flatpakref parse

This commit is contained in:
Ward from fusion-voyager-3 2024-10-02 17:47:48 +03:00
parent 69d398e455
commit afb52f4eab
3 changed files with 31 additions and 1 deletions

7
Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -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);
}