From 7a66251a681b206295dbcf65d74845138001f68d Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Fri, 27 Sep 2024 21:35:40 +0300 Subject: [PATCH] Fix Legacy editing --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- .../gui/apt_manage_page/legacy_edit_dialog.rs | 11 +++++----- src/bin/gui/apt_manage_page/mod.rs | 22 +++++++++---------- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 193933f..a408740 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1071,8 +1071,8 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "legacy-apt-list-tools-rs" -version = "0.1.1" -source = "git+https://github.com/CosmicFusion/legacy-apt-list-tools-rs#f6ad0545a2cc32bda63ba4d72f99374644c3abf9" +version = "0.1.3" +source = "git+https://github.com/CosmicFusion/legacy-apt-list-tools-rs#b3629432a1c8567763f6e3c06c9aaf9decb6e919" dependencies = [ "apt-sources-lists", ] diff --git a/Cargo.toml b/Cargo.toml index b5e0ab4..d145010 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ async-channel = "2.1.1" rust-i18n = "3.0.1" rust-apt = { git = "https://gitlab.com/volian/rust-apt" } apt-deb822-tools = { package = "deb822-tools", git = "https://github.com/CosmicFusion/deb822-tools" } -apt-legacy-tools = { version = "0.1.1", package = "legacy-apt-list-tools-rs", git = "https://github.com/CosmicFusion/legacy-apt-list-tools-rs" } +apt-legacy-tools = { version = "0.1.3", package = "legacy-apt-list-tools-rs", git = "https://github.com/CosmicFusion/legacy-apt-list-tools-rs" } tokio = { version = "1", features = ["full"] } tokio-uds = "0.2" serde = { version = "1.0.203", features = ["derive"] } diff --git a/src/bin/gui/apt_manage_page/legacy_edit_dialog.rs b/src/bin/gui/apt_manage_page/legacy_edit_dialog.rs index c70edb5..c69a9c3 100644 --- a/src/bin/gui/apt_manage_page/legacy_edit_dialog.rs +++ b/src/bin/gui/apt_manage_page/legacy_edit_dialog.rs @@ -221,7 +221,9 @@ pub fn legacy_edit_dialog_fn( unofficial_source_add_dialog.clone() .choose(None::<&gio::Cancellable>, move |choice| { match choice.as_str() { - "unofficial_source_edit_dialog_edit" => { + "unofficial_source_edit_dialog_edit" => { + let mut new_apt_legacy_vec = LegacyAptSource::get_legacy_sources().unwrap(); + new_apt_legacy_vec.retain(|x| x != &legacy_repo_clone0); let new_repo = LegacyAptSource { url: unofficial_source_add_uri_entry.text().to_string(), is_source: unofficial_source_add_is_source_switch.is_active(), @@ -231,7 +233,8 @@ pub fn legacy_edit_dialog_fn( enabled: unofficial_source_add_is_enabled_switch.is_active(), ..legacy_repo_clone0 }; - /*match LegacyAptSource::save_to_file(new_repo.clone(), LegacyAptSource::get_legacy_sources().unwrap(), &format!("/tmp/{}.list", repo_file_name)) { + new_apt_legacy_vec.push(new_repo.clone()); + match LegacyAptSource::save_to_file(new_repo, new_apt_legacy_vec, &format!("/tmp/{}.list", repo_file_name)) { Ok(_) => { match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "legacy_move", repo_file_name).run() { Ok(_) => {} @@ -261,9 +264,7 @@ pub fn legacy_edit_dialog_fn( apt_src_create_error_dialog.present(); reload_action_clone0.activate(None); } - }*/ - dbg!(&new_repo); - LegacyAptSource::save_to_file(new_repo.clone(), LegacyAptSource::get_legacy_sources().unwrap(), &format!("/tmp/{}.list", repo_file_name)).unwrap(); + } } _ => {} } diff --git a/src/bin/gui/apt_manage_page/mod.rs b/src/bin/gui/apt_manage_page/mod.rs index 02b847d..d26f4c4 100644 --- a/src/bin/gui/apt_manage_page/mod.rs +++ b/src/bin/gui/apt_manage_page/mod.rs @@ -112,10 +112,8 @@ pub fn apt_manage_page( let unofficial_sources_columnview_bin = adw::Bin::new(); let unofficial_sources_columnview_bin_clone0 = unofficial_sources_columnview_bin.clone(); - - let reload_unofficial_action = gio::SimpleAction::new("reload_unofficial_action", None); - reload_unofficial_action.connect_activate(clone!( + retry_signal_action.connect_activate(clone!( #[weak] unofficial_sources_columnview_bin_clone0, move |_, _| { @@ -264,7 +262,7 @@ pub fn apt_manage_page( unofficial_sources_columnview_bin_clone0.set_child(Some(&unofficial_sources_columnview)); })); - reload_unofficial_action.activate(None); + retry_signal_action.activate(None); let unofficial_sources_box = Box::builder() .orientation(Orientation::Vertical) @@ -320,13 +318,13 @@ pub fn apt_manage_page( #[strong] window, #[strong] - reload_unofficial_action, + retry_signal_action, move |_| { add_dialog::add_dialog_fn( window.clone(), - &reload_unofficial_action + &retry_signal_action ); } ) @@ -338,7 +336,7 @@ pub fn apt_manage_page( #[strong] unofficial_sources_selection_model_rc, #[strong] - reload_unofficial_action, + retry_signal_action, move |_| { @@ -348,10 +346,10 @@ pub fn apt_manage_page( let apt_src: Ref = item.borrow(); match apt_src.deref() { AptSourceConfig::DEB822(src) => { - deb822_edit_dialog::deb822_edit_dialog_fn(window.clone(), src, &reload_unofficial_action); + deb822_edit_dialog::deb822_edit_dialog_fn(window.clone(), src, &retry_signal_action); } AptSourceConfig::Legacy(list) => { - legacy_edit_dialog::legacy_edit_dialog_fn(window.clone(), list, &reload_unofficial_action) + legacy_edit_dialog::legacy_edit_dialog_fn(window.clone(), list, &retry_signal_action) } }; @@ -365,7 +363,7 @@ pub fn apt_manage_page( #[strong] unofficial_sources_selection_model_rc, #[strong] - reload_unofficial_action, + retry_signal_action, move |_| { @@ -400,13 +398,13 @@ pub fn apt_manage_page( &t!("apt_src_remove_warning_dialog_ok_label").to_string(), ); apt_src_remove_warning_dialog.set_response_appearance("apt_src_remove_warning_dialog_ok", adw::ResponseAppearance::Destructive); - let reload_unofficial_action_clone0 = reload_unofficial_action.clone(); + let retry_signal_action_clone0 = retry_signal_action.clone(); apt_src_remove_warning_dialog.clone() .choose(None::<&gio::Cancellable>, move |choice| { match choice.as_str() { "apt_src_remove_warning_dialog_ok" => { let _ = command.run().unwrap(); - reload_unofficial_action_clone0.activate(None); + retry_signal_action_clone0.activate(None); } _ => {} }