Fix mirror apply
This commit is contained in:
parent
9ef009be68
commit
56f4ef955e
@ -124,5 +124,6 @@
|
||||
"unofficial_source_add_legacy_options_prefrencesgroup_title": "Options",
|
||||
"unofficial_source_add_is_legacy_source_label_label": "Is A Source Repository",
|
||||
"apt_src_create_error_dialog_heading": "Could Not Save Changes: Error",
|
||||
"apt_src_create_error_dialog_ok_label": "OK"
|
||||
"apt_src_create_error_dialog_ok_label": "OK",
|
||||
"system_mirror_save_button_tooltip_text": "Save Changes"
|
||||
}
|
@ -43,6 +43,8 @@ pub fn apt_manage_page(
|
||||
}
|
||||
}).next().unwrap();
|
||||
|
||||
let system_mirror_refcell = Rc::new(RefCell::new(system_source.repolib_default_mirror.as_deref().unwrap().to_string()));
|
||||
|
||||
let main_box = Box::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
@ -51,6 +53,17 @@ pub fn apt_manage_page(
|
||||
|
||||
//
|
||||
|
||||
let mirror_entry_box = gtk::Box::builder()
|
||||
.orientation(Orientation::Horizontal)
|
||||
.margin_top(15)
|
||||
.margin_bottom(5)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
.hexpand(true)
|
||||
.valign(gtk::Align::Start)
|
||||
.build();
|
||||
mirror_entry_box.add_css_class("linked");
|
||||
|
||||
let system_mirror_label0 = gtk::Label::builder()
|
||||
.label(t!("system_mirror_label0_label"))
|
||||
.halign(gtk::Align::Start)
|
||||
@ -73,15 +86,78 @@ pub fn apt_manage_page(
|
||||
.build();
|
||||
|
||||
let system_mirror_entry = gtk::Entry::builder()
|
||||
.placeholder_text(system_source.repolib_default_mirror.as_deref().unwrap())
|
||||
.placeholder_text(system_mirror_refcell.borrow().to_string())
|
||||
.text(system_source.uris.as_deref().unwrap())
|
||||
.valign(gtk::Align::Start)
|
||||
.margin_top(5)
|
||||
.margin_bottom(5)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
.hexpand(true)
|
||||
.build();
|
||||
|
||||
let system_mirror_save_button = gtk::Button::builder()
|
||||
.tooltip_text(t!("system_mirror_save_button_tooltip_text"))
|
||||
.sensitive(false)
|
||||
.halign(gtk::Align::End)
|
||||
.icon_name("object-select-symbolic")
|
||||
.build();
|
||||
|
||||
system_mirror_entry.connect_changed(clone!(
|
||||
#[weak]
|
||||
system_mirror_save_button,
|
||||
#[strong]
|
||||
system_mirror_refcell,
|
||||
move |entry| {
|
||||
system_mirror_save_button.set_sensitive(!(entry.text().to_string() == system_mirror_refcell.borrow().to_string()));
|
||||
}
|
||||
));
|
||||
|
||||
system_mirror_save_button.connect_clicked(clone!(
|
||||
#[weak]
|
||||
system_mirror_entry,
|
||||
#[strong]
|
||||
system_mirror_refcell,
|
||||
#[strong]
|
||||
system_source,
|
||||
#[strong]
|
||||
retry_signal_action,
|
||||
move |button| {
|
||||
let new_repo = Deb822Repository {
|
||||
uris: (Some(system_mirror_entry.text().to_string())),
|
||||
..system_source.clone()
|
||||
};
|
||||
match Deb822Repository::write_to_file(new_repo.clone(), std::path::Path::new("/tmp/system.sources").to_path_buf()) {
|
||||
Ok(_) => {
|
||||
match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move", "system", "system").run() {
|
||||
Ok(_) => {
|
||||
retry_signal_action.activate(None);
|
||||
*system_mirror_refcell.borrow_mut() = system_mirror_entry.text().to_string();
|
||||
button.set_sensitive(false);
|
||||
}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
apt_src_create_error_dialog.add_response(
|
||||
"apt_src_create_error_dialog_ok",
|
||||
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
apt_src_create_error_dialog.present();
|
||||
retry_signal_action.activate(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
apt_src_create_error_dialog.add_response(
|
||||
"apt_src_create_error_dialog_ok",
|
||||
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
apt_src_create_error_dialog.present();
|
||||
}
|
||||
}
|
||||
}
|
||||
));
|
||||
//
|
||||
|
||||
let unofficial_sources_label0 = gtk::Label::builder()
|
||||
@ -403,9 +479,24 @@ pub fn apt_manage_page(
|
||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||
match choice.as_str() {
|
||||
"apt_src_remove_warning_dialog_ok" => {
|
||||
let _ = command.run().unwrap();
|
||||
match command.run() {
|
||||
Ok(_) => {
|
||||
retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
apt_src_create_error_dialog.add_response(
|
||||
"apt_src_create_error_dialog_ok",
|
||||
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
apt_src_create_error_dialog.present();
|
||||
retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
@ -427,7 +518,10 @@ pub fn apt_manage_page(
|
||||
|
||||
main_box.append(&system_mirror_label0);
|
||||
main_box.append(&system_mirror_label1);
|
||||
main_box.append(&system_mirror_entry);
|
||||
main_box.append(&mirror_entry_box);
|
||||
|
||||
mirror_entry_box.append(&system_mirror_entry);
|
||||
mirror_entry_box.append(&system_mirror_save_button);
|
||||
//
|
||||
main_box.append(&unofficial_sources_label0);
|
||||
main_box.append(&unofficial_sources_label1);
|
||||
|
395
src/bin/gui/flatpak_manage_page/add_dialog.rs
Normal file
395
src/bin/gui/flatpak_manage_page/add_dialog.rs
Normal file
@ -0,0 +1,395 @@
|
||||
use crate::apt_package_row::AptPackageRow;
|
||||
use adw::gio::SimpleAction;
|
||||
use adw::prelude::*;
|
||||
use apt_deb822_tools::Deb822Repository;
|
||||
use regex::Regex;
|
||||
use gtk::glib::{property::PropertyGet, clone, BoxedAnyObject};
|
||||
use gtk::*;
|
||||
use std::cell::Ref;
|
||||
use std::ops::Deref;
|
||||
use pika_unixsocket_tools::pika_unixsocket_tools::*;
|
||||
use rust_apt::cache::*;
|
||||
use rust_apt::new_cache;
|
||||
use rust_apt::records::RecordField;
|
||||
use std::cell::RefCell;
|
||||
use std::process::Command;
|
||||
use std::rc::Rc;
|
||||
use std::thread;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
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)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_name_entry = gtk::Entry::builder()
|
||||
.placeholder_text("WineHQ Debian")
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_name_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_name_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_name_prefrencesgroup.add(&unofficial_source_add_name_entry);
|
||||
|
||||
let unofficial_source_add_uri_entry = gtk::Entry::builder()
|
||||
.placeholder_text("https://dl.winehq.org/wine-builds/debian")
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_uri_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry);
|
||||
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder()
|
||||
.placeholder_text("trixie bookworm sid")
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_suites_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry);
|
||||
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder()
|
||||
.placeholder_text("main proprietary")
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_components_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
|
||||
|
||||
let unofficial_source_add_signed_entry = gtk::Entry::builder()
|
||||
.sensitive(false)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_signed_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_signed_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_signed_prefrencesgroup.add(&unofficial_source_add_signed_entry);
|
||||
|
||||
let unofficial_source_add_archs_entry = gtk::Entry::builder()
|
||||
.placeholder_text("amd64 arm64 i386")
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_archs_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_archs_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_archs_prefrencesgroup.add(&unofficial_source_add_archs_entry);
|
||||
|
||||
let unofficial_source_add_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
.orientation(Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.spacing(5)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_is_source_label = gtk::Label::builder()
|
||||
.label(t!("unofficial_source_add_is_source_label_label"))
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_is_source_switch = gtk::Switch::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
let unofficial_source_signed_keyring_checkbutton = gtk::CheckButton::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.label(t!("unofficial_source_signed_keyring_checkbutton_label"))
|
||||
.active(true)
|
||||
.build();
|
||||
|
||||
let unofficial_source_signed_file_checkbutton = gtk::CheckButton::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.label(t!("unofficial_source_signed_file_checkbutton_label"))
|
||||
.group(&unofficial_source_signed_keyring_checkbutton)
|
||||
.build();
|
||||
|
||||
let unofficial_source_signed_url_checkbutton = gtk::CheckButton::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.label(t!("unofficial_source_signed_url_checkbutton_label"))
|
||||
.group(&unofficial_source_signed_keyring_checkbutton)
|
||||
.build();
|
||||
|
||||
//
|
||||
let unofficial_source_add_dialog_child_clamp = adw::Clamp::builder()
|
||||
.child(&unofficial_source_add_dialog_child_box)
|
||||
.maximum_size(500)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_viewport = gtk::ScrolledWindow::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.child(&unofficial_source_add_dialog_child_clamp)
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_dialog = adw::MessageDialog::builder()
|
||||
.transient_for(&window)
|
||||
.extra_child(&unofficial_source_add_viewport)
|
||||
.heading(t!("unofficial_source_add_dialog_heading"))
|
||||
.width_request(700)
|
||||
.height_request(500)
|
||||
.build();
|
||||
|
||||
unofficial_source_add_dialog.add_response(
|
||||
"unofficial_source_add_dialog_add",
|
||||
&t!("unofficial_source_add_dialog_add_label").to_string(),
|
||||
);
|
||||
|
||||
unofficial_source_add_dialog.add_response(
|
||||
"unofficial_source_add_dialog_cancel",
|
||||
&t!("unofficial_source_add_dialog_cancel_label").to_string(),
|
||||
);
|
||||
|
||||
unofficial_source_add_dialog.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
|
||||
unofficial_source_add_dialog.set_response_appearance(
|
||||
"unofficial_source_add_dialog_cancel",
|
||||
adw::ResponseAppearance::Destructive,
|
||||
);
|
||||
|
||||
unofficial_source_add_dialog.set_response_appearance(
|
||||
"unofficial_source_add_dialog_add",
|
||||
adw::ResponseAppearance::Suggested,
|
||||
);
|
||||
|
||||
//
|
||||
|
||||
let unofficial_source_add_dialog_clone0 = unofficial_source_add_dialog.clone();
|
||||
let unofficial_source_add_name_entry_clone0 = unofficial_source_add_name_entry.clone();
|
||||
let unofficial_source_add_uri_entry_clone0 = unofficial_source_add_uri_entry.clone();
|
||||
let unofficial_source_add_suites_entry_clone0 = unofficial_source_add_suites_entry.clone();
|
||||
let unofficial_source_add_components_entry_clone0 = unofficial_source_add_components_entry.clone();
|
||||
let unofficial_source_add_signed_entry_clone0 = unofficial_source_add_signed_entry.clone();
|
||||
let unofficial_source_signed_keyring_checkbutton_clone0 = unofficial_source_signed_keyring_checkbutton.clone();
|
||||
|
||||
let add_button_update_state = move || {
|
||||
if
|
||||
!unofficial_source_add_name_entry_clone0.text().is_empty() &&
|
||||
!unofficial_source_add_uri_entry_clone0.text().is_empty() &&
|
||||
!unofficial_source_add_suites_entry_clone0.text().is_empty() &&
|
||||
!unofficial_source_add_components_entry_clone0.text().is_empty()
|
||||
{
|
||||
if unofficial_source_signed_keyring_checkbutton_clone0.is_active() {
|
||||
unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", true);
|
||||
} else if !unofficial_source_add_signed_entry_clone0.text().is_empty() {
|
||||
unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", true);
|
||||
} else {
|
||||
unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
}
|
||||
} else {
|
||||
unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
for entry in [
|
||||
&unofficial_source_add_name_entry,
|
||||
&unofficial_source_add_uri_entry,
|
||||
&unofficial_source_add_suites_entry,
|
||||
&unofficial_source_add_components_entry,
|
||||
&unofficial_source_add_signed_entry,
|
||||
] {
|
||||
entry.connect_text_notify(clone!(
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |_|
|
||||
{
|
||||
add_button_update_state();
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
unofficial_source_signed_keyring_checkbutton.connect_toggled(clone!(
|
||||
#[weak]
|
||||
unofficial_source_add_signed_entry,
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |checkbutton|
|
||||
{
|
||||
if checkbutton.is_active() {
|
||||
unofficial_source_add_signed_entry.set_sensitive(false);
|
||||
unofficial_source_add_signed_entry.set_placeholder_text(Some(""));
|
||||
add_button_update_state();
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
unofficial_source_signed_file_checkbutton.connect_toggled(clone!(
|
||||
#[weak]
|
||||
unofficial_source_add_signed_entry,
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |checkbutton|
|
||||
{
|
||||
if checkbutton.is_active() {
|
||||
unofficial_source_add_signed_entry.set_sensitive(true);
|
||||
unofficial_source_add_signed_entry.set_placeholder_text(Some("/etc/apt/keyrings/winehq-archive.key"));
|
||||
add_button_update_state();
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
unofficial_source_signed_url_checkbutton.connect_toggled(clone!(
|
||||
#[weak]
|
||||
unofficial_source_add_signed_entry,
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |checkbutton|
|
||||
{
|
||||
if checkbutton.is_active() {
|
||||
unofficial_source_add_signed_entry.set_sensitive(true);
|
||||
unofficial_source_add_signed_entry.set_placeholder_text(Some("https://dl.winehq.org/wine-builds/winehq.key"));
|
||||
add_button_update_state();
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
unofficial_source_add_box2.append(&unofficial_source_add_is_source_label);
|
||||
unofficial_source_add_box2.append(&unofficial_source_add_is_source_switch);
|
||||
unofficial_source_add_box2.append(&unofficial_source_signed_keyring_checkbutton);
|
||||
unofficial_source_add_box2.append(&unofficial_source_signed_file_checkbutton);
|
||||
unofficial_source_add_box2.append(&unofficial_source_signed_url_checkbutton);
|
||||
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_name_prefrencesgroup);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_uri_prefrencesgroup);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_suites_prefrencesgroup);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_components_prefrencesgroup);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_archs_prefrencesgroup);
|
||||
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() {
|
||||
"unofficial_source_add_dialog_add" => {
|
||||
let non_alphanum_regex = Regex::new(r"[^a-zA-Z0-9]").unwrap();
|
||||
let sign_method = if unofficial_source_signed_file_checkbutton.is_active() {
|
||||
1
|
||||
} else if unofficial_source_signed_url_checkbutton.is_active() {
|
||||
2
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let repo_file_name = non_alphanum_regex.replace_all(unofficial_source_add_name_entry.text().as_str(), "_").to_string().to_lowercase();
|
||||
let new_repo = Deb822Repository {
|
||||
repolib_name: Some(unofficial_source_add_name_entry.text().to_string()),
|
||||
filepath: format!("/etc/apt/sources.list.d/{}.source", repo_file_name),
|
||||
uris: Some(unofficial_source_add_uri_entry.text().to_string()),
|
||||
types: if unofficial_source_add_is_source_switch.is_active() {
|
||||
Some("deb deb-src".to_string())
|
||||
} else {
|
||||
Some("deb".to_string())
|
||||
},
|
||||
suites: Some(unofficial_source_add_suites_entry.text().to_string()),
|
||||
components: Some(unofficial_source_add_components_entry.text().to_string()),
|
||||
architectures: if unofficial_source_add_archs_entry.text().is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(unofficial_source_add_archs_entry.text().to_string())
|
||||
},
|
||||
signed_by: match sign_method {
|
||||
1 => Some(unofficial_source_add_signed_entry.text().to_string()),
|
||||
2 => Some(format!("/etc/apt/keyrings/{}.gpg.key", repo_file_name)),
|
||||
_ => None
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
if sign_method == 2 {
|
||||
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(_) => {
|
||||
reload_action_clone0.activate(None);
|
||||
}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
apt_src_create_error_dialog.add_response(
|
||||
"apt_src_create_error_dialog_ok",
|
||||
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
apt_src_create_error_dialog.present();
|
||||
reload_action_clone0.activate(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
apt_src_create_error_dialog.add_response(
|
||||
"apt_src_create_error_dialog_ok",
|
||||
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
apt_src_create_error_dialog.present();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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(_) => {
|
||||
reload_action_clone0.activate(None);
|
||||
}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
apt_src_create_error_dialog.add_response(
|
||||
"apt_src_create_error_dialog_ok",
|
||||
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
apt_src_create_error_dialog.present();
|
||||
reload_action_clone0.activate(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
apt_src_create_error_dialog.add_response(
|
||||
"apt_src_create_error_dialog_ok",
|
||||
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
apt_src_create_error_dialog.present();
|
||||
reload_action_clone0.activate(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
416
src/bin/gui/flatpak_manage_page/deb822_edit_dialog.rs
Normal file
416
src/bin/gui/flatpak_manage_page/deb822_edit_dialog.rs
Normal file
@ -0,0 +1,416 @@
|
||||
use crate::apt_package_row::AptPackageRow;
|
||||
use adw::gio::SimpleAction;
|
||||
use adw::prelude::*;
|
||||
use apt_deb822_tools::Deb822Repository;
|
||||
use regex::Regex;
|
||||
use gtk::glib::{property::PropertyGet, clone, BoxedAnyObject};
|
||||
use gtk::*;
|
||||
use std::cell::Ref;
|
||||
use std::ops::Deref;
|
||||
use pika_unixsocket_tools::pika_unixsocket_tools::*;
|
||||
use rust_apt::cache::*;
|
||||
use rust_apt::new_cache;
|
||||
use rust_apt::records::RecordField;
|
||||
use std::cell::RefCell;
|
||||
use std::process::Command;
|
||||
use std::rc::Rc;
|
||||
use std::thread;
|
||||
use tokio::runtime::Runtime;
|
||||
use std::path::Path;
|
||||
|
||||
pub fn deb822_edit_dialog_fn(
|
||||
window: adw::ApplicationWindow,
|
||||
deb822_repo: &Deb822Repository,
|
||||
reload_action: &gio::SimpleAction,
|
||||
) {
|
||||
let repofile_path = Path::new(&deb822_repo.filepath);
|
||||
let repo_file_name = repofile_path
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.trim_end_matches(".sources")
|
||||
.to_owned();
|
||||
|
||||
let unofficial_source_add_dialog_child_box = Box::builder()
|
||||
.hexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_name_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_name_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_name_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_name_prefrencesgroup.add(&unofficial_source_add_name_entry);
|
||||
|
||||
let unofficial_source_add_uri_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_uri_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry);
|
||||
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_suites_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry);
|
||||
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_components_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
|
||||
|
||||
let unofficial_source_add_signed_entry = gtk::Entry::builder()
|
||||
.sensitive(false)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_signed_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_signed_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_signed_prefrencesgroup.add(&unofficial_source_add_signed_entry);
|
||||
|
||||
let unofficial_source_add_archs_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_archs_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_archs_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_archs_prefrencesgroup.add(&unofficial_source_add_archs_entry);
|
||||
|
||||
let unofficial_source_add_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
.orientation(Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.spacing(5)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_is_source_label = gtk::Label::builder()
|
||||
.label(t!("unofficial_source_add_is_source_label_label"))
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
|
||||
let unofficial_source_add_is_enabled_label = gtk::Label::builder()
|
||||
.label(t!("unofficial_source_add_is_enabled_label_label"))
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_is_source_switch = gtk::Switch::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_is_enabled_switch = gtk::Switch::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
let unofficial_source_signed_keyring_checkbutton = gtk::CheckButton::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.label(t!("unofficial_source_signed_keyring_checkbutton_label"))
|
||||
.active(true)
|
||||
.build();
|
||||
|
||||
let unofficial_source_signed_file_checkbutton = gtk::CheckButton::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.label(t!("unofficial_source_signed_file_checkbutton_label"))
|
||||
.group(&unofficial_source_signed_keyring_checkbutton)
|
||||
.build();
|
||||
//
|
||||
let unofficial_source_add_dialog_child_clamp = adw::Clamp::builder()
|
||||
.child(&unofficial_source_add_dialog_child_box)
|
||||
.maximum_size(500)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_viewport = gtk::ScrolledWindow::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.child(&unofficial_source_add_dialog_child_clamp)
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_dialog = adw::MessageDialog::builder()
|
||||
.transient_for(&window)
|
||||
.extra_child(&unofficial_source_add_viewport)
|
||||
.heading(t!("unofficial_source_edit_dialog_heading").to_string() + " " + &repo_file_name)
|
||||
.width_request(700)
|
||||
.height_request(500)
|
||||
.build();
|
||||
|
||||
unofficial_source_add_dialog.add_response(
|
||||
"unofficial_source_edit_dialog_edit",
|
||||
&t!("unofficial_source_edit_dialog_add_edit").to_string(),
|
||||
);
|
||||
|
||||
unofficial_source_add_dialog.add_response(
|
||||
"unofficial_source_add_dialog_cancel",
|
||||
&t!("unofficial_source_add_dialog_cancel_label").to_string(),
|
||||
);
|
||||
|
||||
unofficial_source_add_dialog.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
|
||||
unofficial_source_add_dialog.set_response_appearance(
|
||||
"unofficial_source_add_dialog_cancel",
|
||||
adw::ResponseAppearance::Destructive,
|
||||
);
|
||||
|
||||
unofficial_source_add_dialog.set_response_appearance(
|
||||
"unofficial_source_edit_dialog_edit",
|
||||
adw::ResponseAppearance::Suggested,
|
||||
);
|
||||
|
||||
//
|
||||
|
||||
let unofficial_source_add_dialog_clone0 = unofficial_source_add_dialog.clone();
|
||||
let unofficial_source_add_name_entry_clone0 = unofficial_source_add_name_entry.clone();
|
||||
let unofficial_source_add_uri_entry_clone0 = unofficial_source_add_uri_entry.clone();
|
||||
let unofficial_source_add_suites_entry_clone0 = unofficial_source_add_suites_entry.clone();
|
||||
let unofficial_source_add_components_entry_clone0 = unofficial_source_add_components_entry.clone();
|
||||
let unofficial_source_add_signed_entry_clone0 = unofficial_source_add_signed_entry.clone();
|
||||
let unofficial_source_signed_keyring_checkbutton_clone0 = unofficial_source_signed_keyring_checkbutton.clone();
|
||||
|
||||
let add_button_update_state = move || {
|
||||
if
|
||||
!unofficial_source_add_name_entry_clone0.text().is_empty() &&
|
||||
!unofficial_source_add_uri_entry_clone0.text().is_empty() &&
|
||||
!unofficial_source_add_suites_entry_clone0.text().is_empty() &&
|
||||
!unofficial_source_add_components_entry_clone0.text().is_empty()
|
||||
{
|
||||
if unofficial_source_signed_keyring_checkbutton_clone0.is_active() {
|
||||
unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", true);
|
||||
} else if !unofficial_source_add_signed_entry_clone0.text().is_empty() {
|
||||
unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", true);
|
||||
} else {
|
||||
unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
}
|
||||
} else {
|
||||
unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
for entry in [
|
||||
&unofficial_source_add_name_entry,
|
||||
&unofficial_source_add_uri_entry,
|
||||
&unofficial_source_add_suites_entry,
|
||||
&unofficial_source_add_components_entry,
|
||||
&unofficial_source_add_signed_entry,
|
||||
] {
|
||||
entry.connect_text_notify(clone!(
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |_|
|
||||
{
|
||||
add_button_update_state();
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
unofficial_source_signed_keyring_checkbutton.connect_toggled(clone!(
|
||||
#[weak]
|
||||
unofficial_source_add_signed_entry,
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |checkbutton|
|
||||
{
|
||||
if checkbutton.is_active() {
|
||||
unofficial_source_add_signed_entry.set_sensitive(false);
|
||||
add_button_update_state();
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
unofficial_source_signed_file_checkbutton.connect_toggled(clone!(
|
||||
#[weak]
|
||||
unofficial_source_add_signed_entry,
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |checkbutton|
|
||||
{
|
||||
if checkbutton.is_active() {
|
||||
unofficial_source_add_signed_entry.set_sensitive(true);
|
||||
add_button_update_state();
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
unofficial_source_add_box2.append(&unofficial_source_add_is_source_label);
|
||||
unofficial_source_add_box2.append(&unofficial_source_add_is_source_switch);
|
||||
unofficial_source_add_box2.append(&unofficial_source_add_is_enabled_label);
|
||||
unofficial_source_add_box2.append(&unofficial_source_add_is_enabled_switch);
|
||||
unofficial_source_add_box2.append(&unofficial_source_signed_keyring_checkbutton);
|
||||
unofficial_source_add_box2.append(&unofficial_source_signed_file_checkbutton);
|
||||
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_name_prefrencesgroup);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_uri_prefrencesgroup);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_suites_prefrencesgroup);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_components_prefrencesgroup);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_archs_prefrencesgroup);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_box2);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_signed_prefrencesgroup);
|
||||
|
||||
|
||||
//
|
||||
|
||||
match &deb822_repo.repolib_name {
|
||||
Some(t) => {
|
||||
unofficial_source_add_name_entry.set_text(&t);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
match &deb822_repo.uris {
|
||||
Some(t) => {
|
||||
unofficial_source_add_uri_entry.set_text(&t);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
match &deb822_repo.suites {
|
||||
Some(t) => {
|
||||
unofficial_source_add_suites_entry.set_text(&t);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
match &deb822_repo.components {
|
||||
Some(t) => {
|
||||
unofficial_source_add_components_entry.set_text(&t);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
match &deb822_repo.signed_by {
|
||||
Some(t) => {
|
||||
unofficial_source_signed_file_checkbutton.set_active(true);
|
||||
unofficial_source_add_signed_entry.set_text(&t);
|
||||
}
|
||||
None => {
|
||||
unofficial_source_signed_keyring_checkbutton.set_active(true)
|
||||
}
|
||||
}
|
||||
match &deb822_repo.architectures {
|
||||
Some(t) => {
|
||||
unofficial_source_add_archs_entry.set_text(&t);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
match &deb822_repo.enabled {
|
||||
Some(t) => {
|
||||
unofficial_source_add_is_enabled_switch.set_active(match t.to_lowercase().as_str() {
|
||||
"yes" => true,
|
||||
"true" => true,
|
||||
"no" => false,
|
||||
"false" => false,
|
||||
_ => true,
|
||||
});
|
||||
}
|
||||
None => {
|
||||
unofficial_source_add_is_enabled_switch.set_active(true);
|
||||
}
|
||||
}
|
||||
|
||||
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 reload_action_clone0 = reload_action.clone();
|
||||
|
||||
unofficial_source_add_dialog.clone()
|
||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||
match choice.as_str() {
|
||||
"unofficial_source_edit_dialog_edit" => {
|
||||
let sign_method = if unofficial_source_signed_file_checkbutton.is_active() {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let new_repo = Deb822Repository {
|
||||
repolib_name: Some(unofficial_source_add_name_entry.text().to_string()),
|
||||
filepath: format!("/etc/apt/sources.list.d/{}.source", repo_file_name),
|
||||
uris: Some(unofficial_source_add_uri_entry.text().to_string()),
|
||||
types: if unofficial_source_add_is_source_switch.is_active() {
|
||||
Some("deb deb-src".to_string())
|
||||
} else {
|
||||
Some("deb".to_string())
|
||||
},
|
||||
suites: Some(unofficial_source_add_suites_entry.text().to_string()),
|
||||
components: Some(unofficial_source_add_components_entry.text().to_string()),
|
||||
architectures: if unofficial_source_add_archs_entry.text().is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(unofficial_source_add_archs_entry.text().to_string())
|
||||
},
|
||||
signed_by: match sign_method {
|
||||
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()) {
|
||||
Ok(_) => {
|
||||
match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move", repo_file_name).run() {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
apt_src_create_error_dialog.add_response(
|
||||
"apt_src_create_error_dialog_ok",
|
||||
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
apt_src_create_error_dialog.present();
|
||||
}
|
||||
}
|
||||
reload_action_clone0.activate(None);
|
||||
}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
apt_src_create_error_dialog.add_response(
|
||||
"apt_src_create_error_dialog_ok",
|
||||
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
apt_src_create_error_dialog.present();
|
||||
reload_action_clone0.activate(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
272
src/bin/gui/flatpak_manage_page/legacy_edit_dialog.rs
Normal file
272
src/bin/gui/flatpak_manage_page/legacy_edit_dialog.rs
Normal file
@ -0,0 +1,272 @@
|
||||
use crate::apt_package_row::AptPackageRow;
|
||||
use adw::gio::SimpleAction;
|
||||
use adw::prelude::*;
|
||||
use apt_legacy_tools::LegacyAptSource;
|
||||
use regex::Regex;
|
||||
use gtk::glib::{property::PropertyGet, clone, BoxedAnyObject};
|
||||
use gtk::*;
|
||||
use std::cell::Ref;
|
||||
use std::ops::Deref;
|
||||
use pika_unixsocket_tools::pika_unixsocket_tools::*;
|
||||
use rust_apt::cache::*;
|
||||
use rust_apt::new_cache;
|
||||
use rust_apt::records::RecordField;
|
||||
use std::cell::RefCell;
|
||||
use std::process::Command;
|
||||
use std::rc::Rc;
|
||||
use std::thread;
|
||||
use tokio::runtime::Runtime;
|
||||
use std::path::Path;
|
||||
|
||||
pub fn legacy_edit_dialog_fn(
|
||||
window: adw::ApplicationWindow,
|
||||
legacy_repo: &LegacyAptSource,
|
||||
reload_action: &gio::SimpleAction,
|
||||
) {
|
||||
let repofile_path = Path::new(&legacy_repo.filepath);
|
||||
let repo_file_name = repofile_path
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.trim_end_matches(".list")
|
||||
.to_owned();
|
||||
|
||||
let unofficial_source_add_dialog_child_box = Box::builder()
|
||||
.hexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_uri_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_uri_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry);
|
||||
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_suites_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry);
|
||||
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_components_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
|
||||
|
||||
let unofficial_source_add_legacy_options_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_legacy_options_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_legacy_options_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_legacy_options_prefrencesgroup.add(&unofficial_source_add_legacy_options_entry);
|
||||
|
||||
let unofficial_source_add_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
.orientation(Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.spacing(5)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_is_source_label = gtk::Label::builder()
|
||||
.label(t!("unofficial_source_add_is_legacy_source_label_label"))
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
|
||||
let unofficial_source_add_is_enabled_label = gtk::Label::builder()
|
||||
.label(t!("unofficial_source_add_is_enabled_label_label"))
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_is_source_switch = gtk::Switch::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_is_enabled_switch = gtk::Switch::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
//
|
||||
let unofficial_source_add_dialog_child_clamp = adw::Clamp::builder()
|
||||
.child(&unofficial_source_add_dialog_child_box)
|
||||
.maximum_size(500)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_viewport = gtk::ScrolledWindow::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.child(&unofficial_source_add_dialog_child_clamp)
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_dialog = adw::MessageDialog::builder()
|
||||
.transient_for(&window)
|
||||
.extra_child(&unofficial_source_add_viewport)
|
||||
.heading(t!("unofficial_source_edit_dialog_heading").to_string() + " " + &repo_file_name)
|
||||
.width_request(700)
|
||||
.height_request(500)
|
||||
.build();
|
||||
|
||||
unofficial_source_add_dialog.add_response(
|
||||
"unofficial_source_edit_dialog_edit",
|
||||
&t!("unofficial_source_edit_dialog_add_edit").to_string(),
|
||||
);
|
||||
|
||||
unofficial_source_add_dialog.add_response(
|
||||
"unofficial_source_add_dialog_cancel",
|
||||
&t!("unofficial_source_add_dialog_cancel_label").to_string(),
|
||||
);
|
||||
|
||||
unofficial_source_add_dialog.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
|
||||
unofficial_source_add_dialog.set_response_appearance(
|
||||
"unofficial_source_add_dialog_cancel",
|
||||
adw::ResponseAppearance::Destructive,
|
||||
);
|
||||
|
||||
unofficial_source_add_dialog.set_response_appearance(
|
||||
"unofficial_source_edit_dialog_edit",
|
||||
adw::ResponseAppearance::Suggested,
|
||||
);
|
||||
|
||||
//
|
||||
|
||||
let unofficial_source_add_dialog_clone0 = unofficial_source_add_dialog.clone();
|
||||
let unofficial_source_add_uri_entry_clone0 = unofficial_source_add_uri_entry.clone();
|
||||
let unofficial_source_add_suites_entry_clone0 = unofficial_source_add_suites_entry.clone();
|
||||
let unofficial_source_add_components_entry_clone0 = unofficial_source_add_components_entry.clone();
|
||||
|
||||
let add_button_update_state = move || {
|
||||
if
|
||||
!unofficial_source_add_uri_entry_clone0.text().is_empty() &&
|
||||
!unofficial_source_add_suites_entry_clone0.text().is_empty() &&
|
||||
!unofficial_source_add_components_entry_clone0.text().is_empty()
|
||||
{
|
||||
unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", true);
|
||||
} else {
|
||||
unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
for entry in [
|
||||
&unofficial_source_add_uri_entry,
|
||||
&unofficial_source_add_suites_entry,
|
||||
&unofficial_source_add_components_entry,
|
||||
&unofficial_source_add_legacy_options_entry,
|
||||
] {
|
||||
entry.connect_text_notify(clone!(
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |_|
|
||||
{
|
||||
add_button_update_state();
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
unofficial_source_add_box2.append(&unofficial_source_add_is_source_label);
|
||||
unofficial_source_add_box2.append(&unofficial_source_add_is_source_switch);
|
||||
unofficial_source_add_box2.append(&unofficial_source_add_is_enabled_label);
|
||||
unofficial_source_add_box2.append(&unofficial_source_add_is_enabled_switch);
|
||||
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_uri_prefrencesgroup);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_suites_prefrencesgroup);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_components_prefrencesgroup);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_box2);
|
||||
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_legacy_options_prefrencesgroup);
|
||||
|
||||
|
||||
//
|
||||
|
||||
unofficial_source_add_uri_entry.set_text(&legacy_repo.url);
|
||||
unofficial_source_add_suites_entry.set_text(&legacy_repo.suite);
|
||||
unofficial_source_add_components_entry.set_text(&legacy_repo.components);
|
||||
match &legacy_repo.options {
|
||||
Some(t) => {
|
||||
unofficial_source_add_legacy_options_entry.set_text(&t);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
unofficial_source_add_is_enabled_switch.set_active(legacy_repo.enabled);
|
||||
|
||||
unofficial_source_add_is_source_switch.set_active(legacy_repo.is_source);
|
||||
|
||||
//
|
||||
let legacy_repo_clone0 = legacy_repo.clone();
|
||||
|
||||
let reload_action_clone0 = reload_action.clone();
|
||||
|
||||
unofficial_source_add_dialog.clone()
|
||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||
match choice.as_str() {
|
||||
"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(),
|
||||
suite: unofficial_source_add_suites_entry.text().to_string(),
|
||||
components: unofficial_source_add_components_entry.text().to_string(),
|
||||
options: Some(unofficial_source_add_legacy_options_entry.text().to_string()),
|
||||
enabled: unofficial_source_add_is_enabled_switch.is_active(),
|
||||
..legacy_repo_clone0
|
||||
};
|
||||
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(_) => {}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
apt_src_create_error_dialog.add_response(
|
||||
"apt_src_create_error_dialog_ok",
|
||||
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
apt_src_create_error_dialog.present();
|
||||
}
|
||||
}
|
||||
reload_action_clone0.activate(None);
|
||||
}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
apt_src_create_error_dialog.add_response(
|
||||
"apt_src_create_error_dialog_ok",
|
||||
&t!("apt_src_create_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
apt_src_create_error_dialog.present();
|
||||
reload_action_clone0.activate(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
437
src/bin/gui/flatpak_manage_page/mod.rs
Normal file
437
src/bin/gui/flatpak_manage_page/mod.rs
Normal file
@ -0,0 +1,437 @@
|
||||
use crate::apt_package_row::AptPackageRow;
|
||||
use add_dialog::add_dialog_fn;
|
||||
use adw::gio::SimpleAction;
|
||||
use adw::prelude::*;
|
||||
use apt_deb822_tools::Deb822Repository;
|
||||
use regex::Regex;
|
||||
use gtk::glib::{property::PropertyGet, clone, BoxedAnyObject};
|
||||
use gtk::*;
|
||||
use std::cell::Ref;
|
||||
use std::ops::Deref;
|
||||
use pika_unixsocket_tools::pika_unixsocket_tools::*;
|
||||
use rust_apt::cache::*;
|
||||
use rust_apt::new_cache;
|
||||
use rust_apt::records::RecordField;
|
||||
use std::cell::RefCell;
|
||||
use std::process::Command;
|
||||
use std::rc::Rc;
|
||||
use std::thread;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
mod add_dialog;
|
||||
mod deb822_edit_dialog;
|
||||
mod legacy_edit_dialog;
|
||||
|
||||
enum AptSourceConfig {
|
||||
Legacy(apt_legacy_tools::LegacyAptSource),
|
||||
DEB822(apt_deb822_tools::Deb822Repository)
|
||||
}
|
||||
|
||||
pub fn apt_manage_page(
|
||||
window: adw::ApplicationWindow,
|
||||
retry_signal_action: &SimpleAction,
|
||||
) -> gtk::Box {
|
||||
|
||||
let deb822_sources = Deb822Repository::get_deb822_sources().unwrap();
|
||||
|
||||
let system_source = deb822_sources.iter().filter(|x| {
|
||||
match &x.repolib_id {
|
||||
Some(t) => {
|
||||
t == "system"
|
||||
}
|
||||
None => false
|
||||
}
|
||||
}).next().unwrap();
|
||||
|
||||
let main_box = Box::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
//
|
||||
|
||||
let system_mirror_label0 = gtk::Label::builder()
|
||||
.label(t!("system_mirror_label0_label"))
|
||||
.halign(gtk::Align::Start)
|
||||
.valign(gtk::Align::Start)
|
||||
.hexpand(true)
|
||||
.margin_top(15)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
.margin_bottom(5)
|
||||
.build();
|
||||
system_mirror_label0.add_css_class("heading");
|
||||
|
||||
let system_mirror_label1 = gtk::Label::builder()
|
||||
.label(t!("system_mirror_label1_label"))
|
||||
.halign(gtk::Align::Start)
|
||||
.valign(gtk::Align::Start)
|
||||
.hexpand(true)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
.build();
|
||||
|
||||
let system_mirror_entry = gtk::Entry::builder()
|
||||
.placeholder_text(system_source.repolib_default_mirror.as_deref().unwrap())
|
||||
.text(system_source.uris.as_deref().unwrap())
|
||||
.valign(gtk::Align::Start)
|
||||
.margin_top(5)
|
||||
.margin_bottom(5)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
.build();
|
||||
|
||||
//
|
||||
|
||||
let unofficial_sources_label0 = gtk::Label::builder()
|
||||
.label(t!("unofficial_sources_label"))
|
||||
.halign(gtk::Align::Start)
|
||||
.valign(gtk::Align::Start)
|
||||
.hexpand(true)
|
||||
.margin_top(15)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
.margin_bottom(5)
|
||||
.build();
|
||||
unofficial_sources_label0.add_css_class("heading");
|
||||
|
||||
let unofficial_sources_label1 = gtk::Label::builder()
|
||||
.label(t!("unofficial_sources_label1_label"))
|
||||
.halign(gtk::Align::Start)
|
||||
.valign(gtk::Align::Start)
|
||||
.hexpand(true)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
.build();
|
||||
|
||||
let unofficial_sources_selection_model_rc: Rc<RefCell<gtk::SingleSelection>> = Rc::new(RefCell::default());
|
||||
|
||||
let unofficial_sources_selection_model_rc_clone0 = Rc::clone(&unofficial_sources_selection_model_rc);
|
||||
|
||||
let unofficial_sources_columnview_bin = adw::Bin::new();
|
||||
|
||||
let unofficial_sources_columnview_bin_clone0 = unofficial_sources_columnview_bin.clone();
|
||||
|
||||
retry_signal_action.connect_activate(clone!(
|
||||
#[weak]
|
||||
unofficial_sources_columnview_bin_clone0,
|
||||
move |_, _| {
|
||||
|
||||
let mut unofficial_deb822_sources = Deb822Repository::get_deb822_sources().unwrap();
|
||||
|
||||
unofficial_deb822_sources.retain(|x| {
|
||||
match &x.repolib_id {
|
||||
Some(t) => {
|
||||
!(t == "system")
|
||||
}
|
||||
None => true
|
||||
}
|
||||
});
|
||||
|
||||
let legacy_apt_repos = apt_legacy_tools::LegacyAptSource::get_legacy_sources();
|
||||
|
||||
let unofficial_sources_list_store = gio::ListStore::new::<BoxedAnyObject>();
|
||||
|
||||
for deb822_source in unofficial_deb822_sources {
|
||||
unofficial_sources_list_store.append(&BoxedAnyObject::new(AptSourceConfig::DEB822(deb822_source)));
|
||||
};
|
||||
|
||||
match legacy_apt_repos {
|
||||
Ok(vec) => {
|
||||
for legacy_repo in vec {
|
||||
unofficial_sources_list_store.append(&BoxedAnyObject::new(AptSourceConfig::Legacy(legacy_repo)));
|
||||
};
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
|
||||
let unofficial_sources_selection_model = SingleSelection::new(Some(unofficial_sources_list_store));
|
||||
|
||||
(*unofficial_sources_selection_model_rc_clone0.borrow_mut() = unofficial_sources_selection_model.clone());
|
||||
|
||||
let unofficial_sources_columnview = ColumnView::builder()
|
||||
.vexpand(true)
|
||||
.model(&unofficial_sources_selection_model)
|
||||
.build();
|
||||
|
||||
//
|
||||
|
||||
let unofficial_sources_columnview_factory0 = gtk::SignalListItemFactory::new();
|
||||
|
||||
unofficial_sources_columnview_factory0.connect_setup(move |_factory, item| {
|
||||
let item = item.downcast_ref::<gtk::ListItem>().unwrap();
|
||||
let row = Label::builder()
|
||||
.halign(Align::Start)
|
||||
.build();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
|
||||
unofficial_sources_columnview_factory0.connect_bind(move |_factory, item| {
|
||||
let item: &ListItem = item.downcast_ref::<gtk::ListItem>().unwrap();
|
||||
let child = item.child().and_downcast::<Label>().unwrap();
|
||||
let entry: BoxedAnyObject = item.item().and_downcast::<BoxedAnyObject>().unwrap();
|
||||
let entry_borrow = entry.borrow::<AptSourceConfig>();
|
||||
let repo_name = match entry_borrow.deref() {
|
||||
AptSourceConfig::DEB822(src) => {
|
||||
match &src.repolib_name {
|
||||
Some(name) => name,
|
||||
None => match(&src.uris, &src.suites, &src.components) {
|
||||
(Some(uris),Some(suites),Some(components)) => {
|
||||
&format!("{} {} {}", uris, suites, components)
|
||||
}
|
||||
(_,_,_) => {
|
||||
&t!("apt_source_parse_error").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
AptSourceConfig::Legacy(src) => {
|
||||
&format!("{} {} {} {}",
|
||||
if src.is_source {
|
||||
"(Legacy Src)"
|
||||
} else {
|
||||
"(Legacy)"
|
||||
},
|
||||
&src.url,
|
||||
&src.suite,
|
||||
&src.components
|
||||
)
|
||||
}
|
||||
};
|
||||
child.set_label(&repo_name);
|
||||
});
|
||||
|
||||
let unofficial_sources_columnview_col0 = gtk::ColumnViewColumn::builder()
|
||||
.title(t!("unofficial_sources_columnview_col0_title"))
|
||||
.factory(&unofficial_sources_columnview_factory0)
|
||||
.expand(true)
|
||||
.build();
|
||||
|
||||
//
|
||||
|
||||
let unofficial_sources_columnview_factory1 = gtk::SignalListItemFactory::new();
|
||||
|
||||
unofficial_sources_columnview_factory1.connect_setup(move |_factory, item| {
|
||||
let item = item.downcast_ref::<gtk::ListItem>().unwrap();
|
||||
let row = Label::builder()
|
||||
.halign(Align::Start)
|
||||
.build();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
|
||||
unofficial_sources_columnview_factory1.connect_bind(move |_factory, item| {
|
||||
let item: &ListItem = item.downcast_ref::<gtk::ListItem>().unwrap();
|
||||
let child = item.child().and_downcast::<Label>().unwrap();
|
||||
let entry: BoxedAnyObject = item.item().and_downcast::<BoxedAnyObject>().unwrap();
|
||||
let entry_borrow = entry.borrow::<AptSourceConfig>();
|
||||
let repo_enabled = match entry_borrow.deref() {
|
||||
AptSourceConfig::DEB822(src) => {
|
||||
match &src.enabled {
|
||||
Some(t) => match t.to_lowercase().as_str() {
|
||||
"yes" => true,
|
||||
"true" => true,
|
||||
"no" => false,
|
||||
"false" => false,
|
||||
_ => true,
|
||||
}
|
||||
None => true,
|
||||
}
|
||||
}
|
||||
AptSourceConfig::Legacy(src) => {
|
||||
src.enabled
|
||||
}
|
||||
};
|
||||
if repo_enabled {
|
||||
child.set_label(&t!("apt_repo_enabled"));
|
||||
} else {
|
||||
child.set_label(&t!("apt_repo_disabled"));
|
||||
}
|
||||
});
|
||||
|
||||
let unofficial_sources_columnview_col1 = gtk::ColumnViewColumn::builder()
|
||||
.title(t!("unofficial_sources_columnview_col1_title"))
|
||||
.factory(&unofficial_sources_columnview_factory1)
|
||||
.build();
|
||||
|
||||
//
|
||||
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));
|
||||
}));
|
||||
|
||||
retry_signal_action.activate(None);
|
||||
|
||||
let unofficial_sources_box = Box::builder()
|
||||
.orientation(Orientation::Vertical)
|
||||
.margin_bottom(3)
|
||||
.margin_top(3)
|
||||
.margin_end(3)
|
||||
.margin_start(3)
|
||||
.build();
|
||||
|
||||
let unofficial_sources_viewport = ScrolledWindow::builder()
|
||||
.vexpand(true)
|
||||
.hexpand(true)
|
||||
.has_frame(true)
|
||||
.margin_bottom(15)
|
||||
.margin_top(15)
|
||||
.margin_end(15)
|
||||
.margin_start(15)
|
||||
.child(&unofficial_sources_box)
|
||||
.height_request(390)
|
||||
.build();
|
||||
unofficial_sources_viewport.add_css_class("round-all-scroll");
|
||||
|
||||
//
|
||||
|
||||
let unofficial_sources_edit_box = gtk::Box::builder()
|
||||
.orientation(Orientation::Horizontal)
|
||||
.homogeneous(true)
|
||||
.build();
|
||||
unofficial_sources_edit_box.add_css_class("linked");
|
||||
|
||||
let unofficial_source_edit_button = Button::builder()
|
||||
.icon_name("document-edit-symbolic")
|
||||
.tooltip_text(t!("unofficial_source_edit_button_tooltip_text"))
|
||||
//.halign(Align::End)
|
||||
.valign(Align::End)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_button = Button::builder()
|
||||
.icon_name("list-add-symbolic")
|
||||
.tooltip_text(t!("unofficial_source_add_button_tooltip_text"))
|
||||
//.halign(Align::End)
|
||||
.valign(Align::End)
|
||||
.build();
|
||||
|
||||
let unofficial_source_remove_button = Button::builder()
|
||||
.icon_name("edit-delete-symbolic")
|
||||
.tooltip_text(t!("unofficial_source_remove_button_tooltip_text"))
|
||||
//.halign(Align::End)
|
||||
.valign(Align::End)
|
||||
.build();
|
||||
|
||||
unofficial_source_add_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
window,
|
||||
#[strong]
|
||||
retry_signal_action,
|
||||
move
|
||||
|_|
|
||||
{
|
||||
add_dialog::add_dialog_fn(
|
||||
window.clone(),
|
||||
&retry_signal_action
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
unofficial_source_edit_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
window,
|
||||
#[strong]
|
||||
unofficial_sources_selection_model_rc,
|
||||
#[strong]
|
||||
retry_signal_action,
|
||||
move
|
||||
|_|
|
||||
{
|
||||
let unofficial_sources_selection_model = unofficial_sources_selection_model_rc.borrow();
|
||||
let selection = unofficial_sources_selection_model.selected_item().unwrap();
|
||||
let item = selection.downcast_ref::<BoxedAnyObject>().unwrap();
|
||||
let apt_src: Ref<AptSourceConfig> = item.borrow();
|
||||
match apt_src.deref() {
|
||||
AptSourceConfig::DEB822(src) => {
|
||||
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, &retry_signal_action)
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
unofficial_source_remove_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
window,
|
||||
#[strong]
|
||||
unofficial_sources_selection_model_rc,
|
||||
#[strong]
|
||||
retry_signal_action,
|
||||
move
|
||||
|_|
|
||||
{
|
||||
{
|
||||
let mut command = duct::cmd!("");
|
||||
{
|
||||
let unofficial_sources_selection_model = unofficial_sources_selection_model_rc.borrow();
|
||||
let selection = unofficial_sources_selection_model.selected_item().unwrap();
|
||||
let item = selection.downcast_ref::<BoxedAnyObject>().unwrap();
|
||||
let apt_src: Ref<AptSourceConfig> = item.borrow();
|
||||
match apt_src.deref() {
|
||||
AptSourceConfig::DEB822(src) => {
|
||||
match &src.signed_by {
|
||||
Some(t) => {command = duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "delete_deb822", &src.filepath, t)}
|
||||
None => {command = duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "delete_legacy", &src.filepath)}
|
||||
}
|
||||
}
|
||||
AptSourceConfig::Legacy(list) => {command = duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "delete_legacy", &list.filepath)}
|
||||
};
|
||||
}
|
||||
let apt_src_remove_warning_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_remove_warning_dialog_heading"))
|
||||
.body(t!("apt_src_remove_warning_dialog_body"))
|
||||
.transient_for(&window)
|
||||
.build();
|
||||
apt_src_remove_warning_dialog.add_response(
|
||||
"apt_src_remove_warning_dialog_cancel",
|
||||
&t!("apt_src_remove_warning_dialog_cancel_label").to_string(),
|
||||
);
|
||||
apt_src_remove_warning_dialog.add_response(
|
||||
"apt_src_remove_warning_dialog_ok",
|
||||
&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 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();
|
||||
retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
//
|
||||
|
||||
unofficial_sources_edit_box.append(&unofficial_source_add_button);
|
||||
unofficial_sources_edit_box.append(&unofficial_source_edit_button);
|
||||
unofficial_sources_edit_box.append(&unofficial_source_remove_button);
|
||||
|
||||
unofficial_sources_box.append(&unofficial_sources_columnview_bin);
|
||||
unofficial_sources_box.append(&unofficial_sources_edit_box);
|
||||
|
||||
//
|
||||
|
||||
main_box.append(&system_mirror_label0);
|
||||
main_box.append(&system_mirror_label1);
|
||||
main_box.append(&system_mirror_entry);
|
||||
//
|
||||
main_box.append(&unofficial_sources_label0);
|
||||
main_box.append(&unofficial_sources_label1);
|
||||
main_box.append(&unofficial_sources_viewport);
|
||||
|
||||
main_box
|
||||
}
|
Loading…
Reference in New Issue
Block a user