From d24efe2f8cf10c8207ff667ab64a275add24bb8a Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Tue, 1 Oct 2024 23:53:39 +0300 Subject: [PATCH] fix apt double run --- src/bin/gui/apt_manage_page/add_dialog.rs | 10 +++++++++- .../gui/apt_manage_page/deb822_edit_dialog.rs | 5 +++++ .../gui/apt_manage_page/legacy_edit_dialog.rs | 4 ++++ src/bin/gui/apt_manage_page/mod.rs | 19 +++++++++++++++---- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/bin/gui/apt_manage_page/add_dialog.rs b/src/bin/gui/apt_manage_page/add_dialog.rs index fd236d1..5be5d59 100644 --- a/src/bin/gui/apt_manage_page/add_dialog.rs +++ b/src/bin/gui/apt_manage_page/add_dialog.rs @@ -19,7 +19,8 @@ use tokio::runtime::Runtime; pub fn add_dialog_fn( window: adw::ApplicationWindow, - reload_action: &gio::SimpleAction + reload_action: &gio::SimpleAction, + apt_retry_signal_action: &gio::SimpleAction, ) { let unofficial_source_add_dialog_child_box = Box::builder() @@ -283,6 +284,7 @@ pub fn add_dialog_fn( unofficial_source_add_dialog_child_box.append(&unofficial_source_add_signed_prefrencesgroup); let reload_action_clone0 = reload_action.clone(); + let apt_retry_signal_action_clone0 = apt_retry_signal_action.clone(); unofficial_source_add_dialog.clone() .choose(None::<&gio::Cancellable>, move |choice| { @@ -326,6 +328,8 @@ pub fn add_dialog_fn( match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move_with_wget", &repo_file_name, &unofficial_source_add_signed_entry.text().to_string(), &format!("/etc/apt/keyrings/{}.gpg.key", &repo_file_name)).run() { Ok(_) => { reload_action_clone0.activate(None); + apt_retry_signal_action_clone0.activate(None); + } Err(e) => { let apt_src_create_error_dialog = adw::MessageDialog::builder() @@ -338,6 +342,7 @@ pub fn add_dialog_fn( ); apt_src_create_error_dialog.present(); reload_action_clone0.activate(None); + apt_retry_signal_action_clone0.activate(None); } } } @@ -359,6 +364,7 @@ pub fn add_dialog_fn( match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move", repo_file_name).run() { Ok(_) => { reload_action_clone0.activate(None); + apt_retry_signal_action_clone0.activate(None); } Err(e) => { let apt_src_create_error_dialog = adw::MessageDialog::builder() @@ -371,6 +377,7 @@ pub fn add_dialog_fn( ); apt_src_create_error_dialog.present(); reload_action_clone0.activate(None); + apt_retry_signal_action_clone0.activate(None); } } } @@ -385,6 +392,7 @@ pub fn add_dialog_fn( ); apt_src_create_error_dialog.present(); reload_action_clone0.activate(None); + apt_retry_signal_action_clone0.activate(None); } } } diff --git a/src/bin/gui/apt_manage_page/deb822_edit_dialog.rs b/src/bin/gui/apt_manage_page/deb822_edit_dialog.rs index 79eeeae..857aad5 100644 --- a/src/bin/gui/apt_manage_page/deb822_edit_dialog.rs +++ b/src/bin/gui/apt_manage_page/deb822_edit_dialog.rs @@ -22,6 +22,7 @@ pub fn deb822_edit_dialog_fn( window: adw::ApplicationWindow, deb822_repo: &Deb822Repository, reload_action: &gio::SimpleAction, + apt_retry_signal_action: &SimpleAction, ) { let repofile_path = Path::new(&deb822_repo.filepath); let repo_file_name = repofile_path @@ -342,6 +343,8 @@ pub fn deb822_edit_dialog_fn( let deb822_repo_clone0 = deb822_repo.clone(); let reload_action_clone0 = reload_action.clone(); + let apt_retry_signal_action_clone0 = apt_retry_signal_action.clone(); + unofficial_source_add_dialog.clone() .choose(None::<&gio::Cancellable>, move |choice| { @@ -395,6 +398,7 @@ pub fn deb822_edit_dialog_fn( } } reload_action_clone0.activate(None); + apt_retry_signal_action_clone0.activate(None); } Err(e) => { let apt_src_create_error_dialog = adw::MessageDialog::builder() @@ -407,6 +411,7 @@ pub fn deb822_edit_dialog_fn( ); apt_src_create_error_dialog.present(); reload_action_clone0.activate(None); + apt_retry_signal_action_clone0.activate(None); } } } 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 c69a9c3..34a6421 100644 --- a/src/bin/gui/apt_manage_page/legacy_edit_dialog.rs +++ b/src/bin/gui/apt_manage_page/legacy_edit_dialog.rs @@ -22,6 +22,7 @@ pub fn legacy_edit_dialog_fn( window: adw::ApplicationWindow, legacy_repo: &LegacyAptSource, reload_action: &gio::SimpleAction, + apt_retry_signal_action: &SimpleAction, ) { let repofile_path = Path::new(&legacy_repo.filepath); let repo_file_name = repofile_path @@ -217,6 +218,7 @@ pub fn legacy_edit_dialog_fn( let legacy_repo_clone0 = legacy_repo.clone(); let reload_action_clone0 = reload_action.clone(); + let apt_retry_signal_action_clone0 = apt_retry_signal_action.clone(); unofficial_source_add_dialog.clone() .choose(None::<&gio::Cancellable>, move |choice| { @@ -251,6 +253,7 @@ pub fn legacy_edit_dialog_fn( } } reload_action_clone0.activate(None); + apt_retry_signal_action_clone0.activate(None); } Err(e) => { let apt_src_create_error_dialog = adw::MessageDialog::builder() @@ -263,6 +266,7 @@ pub fn legacy_edit_dialog_fn( ); apt_src_create_error_dialog.present(); reload_action_clone0.activate(None); + apt_retry_signal_action_clone0.activate(None); } } } diff --git a/src/bin/gui/apt_manage_page/mod.rs b/src/bin/gui/apt_manage_page/mod.rs index 34b5bce..e21ac9d 100644 --- a/src/bin/gui/apt_manage_page/mod.rs +++ b/src/bin/gui/apt_manage_page/mod.rs @@ -29,8 +29,9 @@ enum AptSourceConfig { pub fn apt_manage_page( window: adw::ApplicationWindow, - retry_signal_action: &SimpleAction, + apt_retry_signal_action: &SimpleAction, ) -> gtk::Box { + let retry_signal_action = gio::SimpleAction::new("apt_manage_retry", None); let deb822_sources = Deb822Repository::get_deb822_sources().unwrap(); @@ -395,12 +396,15 @@ pub fn apt_manage_page( window, #[strong] retry_signal_action, + #[strong] + apt_retry_signal_action, move |_| { add_dialog::add_dialog_fn( window.clone(), - &retry_signal_action + &retry_signal_action, + &apt_retry_signal_action ); } ) @@ -413,6 +417,8 @@ pub fn apt_manage_page( unofficial_sources_selection_model_rc, #[strong] retry_signal_action, + #[strong] + apt_retry_signal_action, move |_| { @@ -422,10 +428,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, &retry_signal_action); + deb822_edit_dialog::deb822_edit_dialog_fn(window.clone(), src, &retry_signal_action, &apt_retry_signal_action); } AptSourceConfig::Legacy(list) => { - legacy_edit_dialog::legacy_edit_dialog_fn(window.clone(), list, &retry_signal_action) + legacy_edit_dialog::legacy_edit_dialog_fn(window.clone(), list, &retry_signal_action, &apt_retry_signal_action) } }; @@ -440,6 +446,8 @@ pub fn apt_manage_page( unofficial_sources_selection_model_rc, #[strong] retry_signal_action, + #[strong] + apt_retry_signal_action, move |_| { @@ -475,6 +483,7 @@ pub fn apt_manage_page( ); apt_src_remove_warning_dialog.set_response_appearance("apt_src_remove_warning_dialog_ok", adw::ResponseAppearance::Destructive); let retry_signal_action_clone0 = retry_signal_action.clone(); + let apt_retry_signal_action_clone0 = apt_retry_signal_action.clone(); apt_src_remove_warning_dialog.clone() .choose(None::<&gio::Cancellable>, move |choice| { match choice.as_str() { @@ -482,6 +491,7 @@ pub fn apt_manage_page( match command.run() { Ok(_) => { retry_signal_action_clone0.activate(None); + apt_retry_signal_action_clone0.activate(None) } Err(e) => { let apt_src_create_error_dialog = adw::MessageDialog::builder() @@ -494,6 +504,7 @@ pub fn apt_manage_page( ); apt_src_create_error_dialog.present(); retry_signal_action_clone0.activate(None); + apt_retry_signal_action_clone0.activate(None) } } }