diff --git a/src/bin/gui/apt_manage_page/add_dialog.rs b/src/bin/gui/apt_manage_page/add_dialog.rs index 173a6c1..fd236d1 100644 --- a/src/bin/gui/apt_manage_page/add_dialog.rs +++ b/src/bin/gui/apt_manage_page/add_dialog.rs @@ -17,7 +17,11 @@ use std::rc::Rc; use std::thread; use tokio::runtime::Runtime; -pub fn add_dialog_fn(window: adw::ApplicationWindow) { +pub fn add_dialog_fn( + window: adw::ApplicationWindow, + reload_action: &gio::SimpleAction + ) + { let unofficial_source_add_dialog_child_box = Box::builder() .hexpand(true) .orientation(Orientation::Vertical) @@ -278,6 +282,8 @@ pub fn add_dialog_fn(window: adw::ApplicationWindow) { unofficial_source_add_dialog_child_box.append(&unofficial_source_add_box2); unofficial_source_add_dialog_child_box.append(&unofficial_source_add_signed_prefrencesgroup); + let reload_action_clone0 = reload_action.clone(); + unofficial_source_add_dialog.clone() .choose(None::<&gio::Cancellable>, move |choice| { match choice.as_str() { @@ -318,7 +324,9 @@ pub fn add_dialog_fn(window: adw::ApplicationWindow) { match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) { Ok(_) => { 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(_) => {} + Ok(_) => { + reload_action_clone0.activate(None); + } Err(e) => { let apt_src_create_error_dialog = adw::MessageDialog::builder() .heading(t!("apt_src_create_error_dialog_heading")) @@ -329,6 +337,7 @@ pub fn add_dialog_fn(window: adw::ApplicationWindow) { &t!("apt_src_create_error_dialog_ok_label").to_string(), ); apt_src_create_error_dialog.present(); + reload_action_clone0.activate(None); } } } @@ -348,7 +357,9 @@ pub fn add_dialog_fn(window: adw::ApplicationWindow) { match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) { Ok(_) => { match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move", repo_file_name).run() { - Ok(_) => {} + Ok(_) => { + reload_action_clone0.activate(None); + } Err(e) => { let apt_src_create_error_dialog = adw::MessageDialog::builder() .heading(t!("apt_src_create_error_dialog_heading")) @@ -359,6 +370,7 @@ pub fn add_dialog_fn(window: adw::ApplicationWindow) { &t!("apt_src_create_error_dialog_ok_label").to_string(), ); apt_src_create_error_dialog.present(); + reload_action_clone0.activate(None); } } } @@ -372,6 +384,7 @@ pub fn add_dialog_fn(window: adw::ApplicationWindow) { &t!("apt_src_create_error_dialog_ok_label").to_string(), ); apt_src_create_error_dialog.present(); + reload_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 2acc9a8..9381b52 100644 --- a/src/bin/gui/apt_manage_page/deb822_edit_dialog.rs +++ b/src/bin/gui/apt_manage_page/deb822_edit_dialog.rs @@ -28,6 +28,7 @@ pub fn deb822_edit_dialog_fn( .unwrap() .to_str() .unwrap() + .trim_end_matches(".sources") .to_owned(); let unofficial_source_add_dialog_child_box = Box::builder() @@ -329,6 +330,13 @@ pub fn deb822_edit_dialog_fn( } } + match &deb822_repo.types { + Some(t) => { + unofficial_source_add_is_source_switch.set_active(t.contains("deb-src")); + } + None => {} + } + // let deb822_repo_clone0 = deb822_repo.clone(); @@ -361,6 +369,10 @@ pub fn deb822_edit_dialog_fn( 1 => Some(unofficial_source_add_signed_entry.text().to_string()), _ => None }, + enabled: match unofficial_source_add_is_enabled_switch.is_active() { + true => Some("yes".to_string()), + false => Some("no".to_string()) + }, ..deb822_repo_clone0 }; match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) { diff --git a/src/bin/gui/apt_manage_page/mod.rs b/src/bin/gui/apt_manage_page/mod.rs index cb59cf0..ddfb325 100644 --- a/src/bin/gui/apt_manage_page/mod.rs +++ b/src/bin/gui/apt_manage_page/mod.rs @@ -112,7 +112,12 @@ pub fn apt_manage_page( let unofficial_sources_columnview_bin_clone0 = unofficial_sources_columnview_bin.clone(); - let reload_unofficial_source_closure = move || { + let reload_unofficial_action = gio::SimpleAction::new("reload_unofficial_action", None); + + reload_unofficial_action.connect_activate(clone!( + #[weak] + unofficial_sources_columnview_bin_clone0, + move |_, _| { let mut unofficial_deb822_sources = Deb822Repository::get_deb822_sources().unwrap(); @@ -256,9 +261,9 @@ pub fn apt_manage_page( unofficial_sources_columnview.append_column(&unofficial_sources_columnview_col0); unofficial_sources_columnview.append_column(&unofficial_sources_columnview_col1); unofficial_sources_columnview_bin_clone0.set_child(Some(&unofficial_sources_columnview)); - }; + })); - reload_unofficial_source_closure(); + reload_unofficial_action.activate(None); let unofficial_sources_box = Box::builder() .orientation(Orientation::Vertical) @@ -313,10 +318,15 @@ pub fn apt_manage_page( unofficial_source_add_button.connect_clicked(clone!( #[strong] window, + #[strong] + reload_unofficial_action, move |_| { - add_dialog::add_dialog_fn(window.clone()); + add_dialog::add_dialog_fn( + window.clone(), + &reload_unofficial_action + ); } ) ); @@ -327,7 +337,7 @@ pub fn apt_manage_page( #[strong] unofficial_sources_selection_model_rc, #[strong] - reload_unofficial_source_closure, + reload_unofficial_action, move |_| { @@ -352,7 +362,7 @@ pub fn apt_manage_page( #[strong] unofficial_sources_selection_model_rc, #[strong] - reload_unofficial_source_closure, + reload_unofficial_action, move |_| { @@ -387,13 +397,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_source_closure_clone0 = reload_unofficial_source_closure.clone(); + let reload_unofficial_action_clone0 = reload_unofficial_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_source_closure_clone0(); + reload_unofficial_action_clone0.activate(None); } _ => {} }