Reload list on add
This commit is contained in:
parent
c0a8767821
commit
bc6838097e
@ -17,7 +17,11 @@ use std::rc::Rc;
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
use tokio::runtime::Runtime;
|
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()
|
let unofficial_source_add_dialog_child_box = Box::builder()
|
||||||
.hexpand(true)
|
.hexpand(true)
|
||||||
.orientation(Orientation::Vertical)
|
.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_box2);
|
||||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_signed_prefrencesgroup);
|
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_signed_prefrencesgroup);
|
||||||
|
|
||||||
|
let reload_action_clone0 = reload_action.clone();
|
||||||
|
|
||||||
unofficial_source_add_dialog.clone()
|
unofficial_source_add_dialog.clone()
|
||||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||||
match choice.as_str() {
|
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()) {
|
match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) {
|
||||||
Ok(_) => {
|
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() {
|
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) => {
|
Err(e) => {
|
||||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
.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(),
|
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||||
);
|
);
|
||||||
apt_src_create_error_dialog.present();
|
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()) {
|
match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move", repo_file_name).run() {
|
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) => {
|
Err(e) => {
|
||||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
.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(),
|
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||||
);
|
);
|
||||||
apt_src_create_error_dialog.present();
|
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(),
|
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||||
);
|
);
|
||||||
apt_src_create_error_dialog.present();
|
apt_src_create_error_dialog.present();
|
||||||
|
reload_action_clone0.activate(None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ pub fn deb822_edit_dialog_fn(
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
.trim_end_matches(".sources")
|
||||||
.to_owned();
|
.to_owned();
|
||||||
|
|
||||||
let unofficial_source_add_dialog_child_box = Box::builder()
|
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();
|
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()),
|
1 => Some(unofficial_source_add_signed_entry.text().to_string()),
|
||||||
_ => None
|
_ => None
|
||||||
},
|
},
|
||||||
|
enabled: match unofficial_source_add_is_enabled_switch.is_active() {
|
||||||
|
true => Some("yes".to_string()),
|
||||||
|
false => Some("no".to_string())
|
||||||
|
},
|
||||||
..deb822_repo_clone0
|
..deb822_repo_clone0
|
||||||
};
|
};
|
||||||
match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) {
|
match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) {
|
||||||
|
@ -112,7 +112,12 @@ pub fn apt_manage_page(
|
|||||||
|
|
||||||
let unofficial_sources_columnview_bin_clone0 = unofficial_sources_columnview_bin.clone();
|
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();
|
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_col0);
|
||||||
unofficial_sources_columnview.append_column(&unofficial_sources_columnview_col1);
|
unofficial_sources_columnview.append_column(&unofficial_sources_columnview_col1);
|
||||||
unofficial_sources_columnview_bin_clone0.set_child(Some(&unofficial_sources_columnview));
|
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()
|
let unofficial_sources_box = Box::builder()
|
||||||
.orientation(Orientation::Vertical)
|
.orientation(Orientation::Vertical)
|
||||||
@ -313,10 +318,15 @@ pub fn apt_manage_page(
|
|||||||
unofficial_source_add_button.connect_clicked(clone!(
|
unofficial_source_add_button.connect_clicked(clone!(
|
||||||
#[strong]
|
#[strong]
|
||||||
window,
|
window,
|
||||||
|
#[strong]
|
||||||
|
reload_unofficial_action,
|
||||||
move
|
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]
|
#[strong]
|
||||||
unofficial_sources_selection_model_rc,
|
unofficial_sources_selection_model_rc,
|
||||||
#[strong]
|
#[strong]
|
||||||
reload_unofficial_source_closure,
|
reload_unofficial_action,
|
||||||
move
|
move
|
||||||
|_|
|
|_|
|
||||||
{
|
{
|
||||||
@ -352,7 +362,7 @@ pub fn apt_manage_page(
|
|||||||
#[strong]
|
#[strong]
|
||||||
unofficial_sources_selection_model_rc,
|
unofficial_sources_selection_model_rc,
|
||||||
#[strong]
|
#[strong]
|
||||||
reload_unofficial_source_closure,
|
reload_unofficial_action,
|
||||||
move
|
move
|
||||||
|_|
|
|_|
|
||||||
{
|
{
|
||||||
@ -387,13 +397,13 @@ pub fn apt_manage_page(
|
|||||||
&t!("apt_src_remove_warning_dialog_ok_label").to_string(),
|
&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);
|
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()
|
apt_src_remove_warning_dialog.clone()
|
||||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||||
match choice.as_str() {
|
match choice.as_str() {
|
||||||
"apt_src_remove_warning_dialog_ok" => {
|
"apt_src_remove_warning_dialog_ok" => {
|
||||||
let _ = command.run().unwrap();
|
let _ = command.run().unwrap();
|
||||||
reload_unofficial_source_closure_clone0();
|
reload_unofficial_action_clone0.activate(None);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user