Fix Warnings and fmt
This commit is contained in:
parent
f5dcfc455a
commit
c2010b7136
@ -1,403 +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::glib::clone;
|
||||
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 regex::Regex;
|
||||
|
||||
pub fn add_dialog_fn(
|
||||
window: adw::ApplicationWindow,
|
||||
reload_action: &gio::SimpleAction,
|
||||
apt_retry_signal_action: &gio::SimpleAction,
|
||||
)
|
||||
{
|
||||
window: adw::ApplicationWindow,
|
||||
reload_action: &gio::SimpleAction,
|
||||
apt_retry_signal_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();
|
||||
.hexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_name_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_name_prefrencesgroup_title"))
|
||||
.build();
|
||||
let unofficial_source_add_name_entry = gtk::Entry::builder()
|
||||
.placeholder_text("WineHQ Debian")
|
||||
.build();
|
||||
|
||||
unofficial_source_add_name_prefrencesgroup.add(&unofficial_source_add_name_entry);
|
||||
let unofficial_source_add_name_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_name_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_uri_entry = gtk::Entry::builder()
|
||||
.placeholder_text("https://dl.winehq.org/wine-builds/debian")
|
||||
.build();
|
||||
unofficial_source_add_name_prefrencesgroup.add(&unofficial_source_add_name_entry);
|
||||
|
||||
let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_uri_prefrencesgroup_title"))
|
||||
.build();
|
||||
let unofficial_source_add_uri_entry = gtk::Entry::builder()
|
||||
.placeholder_text("https://dl.winehq.org/wine-builds/debian")
|
||||
.build();
|
||||
|
||||
unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry);
|
||||
let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_uri_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder()
|
||||
.placeholder_text("trixie bookworm sid")
|
||||
.build();
|
||||
unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry);
|
||||
|
||||
let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_suites_prefrencesgroup_title"))
|
||||
.build();
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder()
|
||||
.placeholder_text("trixie bookworm sid")
|
||||
.build();
|
||||
|
||||
unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry);
|
||||
let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_suites_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder()
|
||||
.placeholder_text("main proprietary")
|
||||
.build();
|
||||
unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry);
|
||||
|
||||
let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_components_prefrencesgroup_title"))
|
||||
.build();
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder()
|
||||
.placeholder_text("main proprietary")
|
||||
.build();
|
||||
|
||||
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
|
||||
let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_components_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_signed_entry = gtk::Entry::builder()
|
||||
.sensitive(false)
|
||||
.build();
|
||||
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
|
||||
|
||||
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_signed_entry = gtk::Entry::builder().sensitive(false).build();
|
||||
|
||||
let unofficial_source_add_archs_entry = gtk::Entry::builder()
|
||||
.placeholder_text("amd64 arm64 i386")
|
||||
.build();
|
||||
let unofficial_source_add_signed_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_signed_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_archs_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_archs_prefrencesgroup_title"))
|
||||
.build();
|
||||
unofficial_source_add_signed_prefrencesgroup.add(&unofficial_source_add_signed_entry);
|
||||
|
||||
unofficial_source_add_archs_prefrencesgroup.add(&unofficial_source_add_archs_entry);
|
||||
let unofficial_source_add_archs_entry = gtk::Entry::builder()
|
||||
.placeholder_text("amd64 arm64 i386")
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
.orientation(Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.spacing(5)
|
||||
.build();
|
||||
let unofficial_source_add_archs_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_archs_prefrencesgroup_title"))
|
||||
.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();
|
||||
unofficial_source_add_archs_prefrencesgroup.add(&unofficial_source_add_archs_entry);
|
||||
|
||||
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_add_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
.orientation(Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.spacing(5)
|
||||
.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_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_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_is_source_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_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_add_viewport = gtk::ScrolledWindow::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.child(&unofficial_source_add_dialog_child_clamp)
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.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 = 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();
|
||||
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();
|
||||
|
||||
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(),
|
||||
);
|
||||
//
|
||||
let unofficial_source_add_dialog_child_clamp = adw::Clamp::builder()
|
||||
.child(&unofficial_source_add_dialog_child_box)
|
||||
.maximum_size(500)
|
||||
.build();
|
||||
|
||||
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,
|
||||
);
|
||||
let unofficial_source_add_viewport = gtk::ScrolledWindow::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.child(&unofficial_source_add_dialog_child_clamp)
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.build();
|
||||
|
||||
unofficial_source_add_dialog.set_response_appearance(
|
||||
"unofficial_source_add_dialog_add",
|
||||
adw::ResponseAppearance::Suggested,
|
||||
);
|
||||
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(),
|
||||
);
|
||||
|
||||
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();
|
||||
unofficial_source_add_dialog.add_response(
|
||||
"unofficial_source_add_dialog_cancel",
|
||||
&t!("unofficial_source_add_dialog_cancel_label").to_string(),
|
||||
);
|
||||
|
||||
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);
|
||||
}
|
||||
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();
|
||||
let apt_retry_signal_action_clone0 = apt_retry_signal_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 {
|
||||
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();
|
||||
let apt_retry_signal_action_clone0 = apt_retry_signal_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);
|
||||
apt_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();
|
||||
reload_action_clone0.activate(None);
|
||||
apt_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();
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
apt_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();
|
||||
reload_action_clone0.activate(None);
|
||||
apt_retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
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);
|
||||
apt_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();
|
||||
reload_action_clone0.activate(None);
|
||||
apt_retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
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);
|
||||
apt_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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} 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);
|
||||
apt_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();
|
||||
reload_action_clone0.activate(None);
|
||||
apt_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();
|
||||
reload_action_clone0.activate(None);
|
||||
apt_retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,21 +1,8 @@
|
||||
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::glib::clone;
|
||||
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(
|
||||
@ -24,398 +11,399 @@ pub fn deb822_edit_dialog_fn(
|
||||
reload_action: &gio::SimpleAction,
|
||||
apt_retry_signal_action: &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 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_name_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_name_prefrencesgroup_title"))
|
||||
.build();
|
||||
let unofficial_source_add_dialog_child_box = Box::builder()
|
||||
.hexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
unofficial_source_add_name_prefrencesgroup.add(&unofficial_source_add_name_entry);
|
||||
let unofficial_source_add_name_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_uri_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_name_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_name_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_uri_prefrencesgroup_title"))
|
||||
.build();
|
||||
unofficial_source_add_name_prefrencesgroup.add(&unofficial_source_add_name_entry);
|
||||
|
||||
unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry);
|
||||
let unofficial_source_add_uri_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_uri_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_suites_prefrencesgroup_title"))
|
||||
.build();
|
||||
unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry);
|
||||
|
||||
unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry);
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_suites_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_components_prefrencesgroup_title"))
|
||||
.build();
|
||||
unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry);
|
||||
|
||||
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_signed_entry = gtk::Entry::builder()
|
||||
.sensitive(false)
|
||||
.build();
|
||||
let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_components_prefrencesgroup_title"))
|
||||
.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);
|
||||
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
|
||||
|
||||
let unofficial_source_add_archs_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_signed_entry = gtk::Entry::builder().sensitive(false).build();
|
||||
|
||||
let unofficial_source_add_archs_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_archs_prefrencesgroup_title"))
|
||||
.build();
|
||||
let unofficial_source_add_signed_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_signed_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_archs_prefrencesgroup.add(&unofficial_source_add_archs_entry);
|
||||
unofficial_source_add_signed_prefrencesgroup.add(&unofficial_source_add_signed_entry);
|
||||
|
||||
let unofficial_source_add_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
.orientation(Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.spacing(5)
|
||||
.build();
|
||||
let unofficial_source_add_archs_entry = gtk::Entry::builder().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_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_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_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
.orientation(Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.spacing(5)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_is_enabled_switch = gtk::Switch::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.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_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_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_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_is_source_switch = gtk::Switch::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.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_is_enabled_switch = gtk::Switch::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.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();
|
||||
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();
|
||||
|
||||
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(),
|
||||
);
|
||||
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();
|
||||
|
||||
unofficial_source_add_dialog.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
let unofficial_source_add_viewport = gtk::ScrolledWindow::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.child(&unofficial_source_add_dialog_child_clamp)
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.build();
|
||||
|
||||
unofficial_source_add_dialog.set_response_appearance(
|
||||
"unofficial_source_add_dialog_cancel",
|
||||
adw::ResponseAppearance::Destructive,
|
||||
);
|
||||
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.set_response_appearance(
|
||||
"unofficial_source_edit_dialog_edit",
|
||||
adw::ResponseAppearance::Suggested,
|
||||
);
|
||||
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(),
|
||||
);
|
||||
|
||||
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();
|
||||
unofficial_source_add_dialog.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
|
||||
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);
|
||||
}
|
||||
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();
|
||||
let apt_retry_signal_action_clone0 = apt_retry_signal_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 {
|
||||
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 |_|
|
||||
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()
|
||||
{
|
||||
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();
|
||||
let apt_retry_signal_action_clone0 = apt_retry_signal_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);
|
||||
apt_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();
|
||||
reload_action_clone0.activate(None);
|
||||
apt_retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
}
|
||||
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);
|
||||
apt_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();
|
||||
reload_action_clone0.activate(None);
|
||||
apt_retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,21 +1,8 @@
|
||||
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::glib::clone;
|
||||
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(
|
||||
@ -24,253 +11,270 @@ pub fn legacy_edit_dialog_fn(
|
||||
reload_action: &gio::SimpleAction,
|
||||
apt_retry_signal_action: &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 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_uri_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_dialog_child_box = Box::builder()
|
||||
.hexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_uri_prefrencesgroup_title"))
|
||||
.build();
|
||||
let unofficial_source_add_uri_entry = gtk::Entry::builder().build();
|
||||
|
||||
unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry);
|
||||
let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_uri_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry);
|
||||
|
||||
let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_suites_prefrencesgroup_title"))
|
||||
.build();
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder().build();
|
||||
|
||||
unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry);
|
||||
let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_suites_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry);
|
||||
|
||||
let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_components_prefrencesgroup_title"))
|
||||
.build();
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder().build();
|
||||
|
||||
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
|
||||
let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_components_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_legacy_options_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
|
||||
|
||||
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_legacy_options_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
.orientation(Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.spacing(5)
|
||||
.build();
|
||||
let unofficial_source_add_legacy_options_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!(
|
||||
"unofficial_source_add_legacy_options_prefrencesgroup_title"
|
||||
))
|
||||
.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();
|
||||
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_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_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_switch = gtk::Switch::builder()
|
||||
.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_dialog_child_clamp = adw::Clamp::builder()
|
||||
.child(&unofficial_source_add_dialog_child_box)
|
||||
.maximum_size(500)
|
||||
.build();
|
||||
let unofficial_source_add_is_source_switch = gtk::Switch::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.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_is_enabled_switch = gtk::Switch::builder()
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.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();
|
||||
//
|
||||
let unofficial_source_add_dialog_child_clamp = adw::Clamp::builder()
|
||||
.child(&unofficial_source_add_dialog_child_box)
|
||||
.maximum_size(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(),
|
||||
);
|
||||
let unofficial_source_add_viewport = gtk::ScrolledWindow::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.child(&unofficial_source_add_dialog_child_clamp)
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.build();
|
||||
|
||||
unofficial_source_add_dialog.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
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.set_response_appearance(
|
||||
"unofficial_source_add_dialog_cancel",
|
||||
adw::ResponseAppearance::Destructive,
|
||||
);
|
||||
unofficial_source_add_dialog.add_response(
|
||||
"unofficial_source_edit_dialog_edit",
|
||||
&t!("unofficial_source_edit_dialog_add_edit").to_string(),
|
||||
);
|
||||
|
||||
unofficial_source_add_dialog.set_response_appearance(
|
||||
"unofficial_source_edit_dialog_edit",
|
||||
adw::ResponseAppearance::Suggested,
|
||||
);
|
||||
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);
|
||||
|
||||
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();
|
||||
unofficial_source_add_dialog.set_response_appearance(
|
||||
"unofficial_source_add_dialog_cancel",
|
||||
adw::ResponseAppearance::Destructive,
|
||||
);
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
unofficial_source_add_dialog.set_response_appearance(
|
||||
"unofficial_source_edit_dialog_edit",
|
||||
adw::ResponseAppearance::Suggested,
|
||||
);
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
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 |_|
|
||||
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();
|
||||
let apt_retry_signal_action_clone0 = apt_retry_signal_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()
|
||||
{
|
||||
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();
|
||||
let apt_retry_signal_action_clone0 = apt_retry_signal_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);
|
||||
apt_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();
|
||||
reload_action_clone0.activate(None);
|
||||
apt_retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
}
|
||||
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);
|
||||
apt_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();
|
||||
reload_action_clone0.activate(None);
|
||||
apt_retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,22 +1,12 @@
|
||||
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::glib::{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::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use std::thread;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
mod add_dialog;
|
||||
mod deb822_edit_dialog;
|
||||
@ -24,7 +14,7 @@ mod legacy_edit_dialog;
|
||||
|
||||
enum AptSourceConfig {
|
||||
Legacy(apt_legacy_tools::LegacyAptSource),
|
||||
DEB822(apt_deb822_tools::Deb822Repository)
|
||||
DEB822(apt_deb822_tools::Deb822Repository),
|
||||
}
|
||||
|
||||
pub fn apt_manage_page(
|
||||
@ -35,16 +25,22 @@ pub fn apt_manage_page(
|
||||
|
||||
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 system_source = deb822_sources
|
||||
.iter()
|
||||
.filter(|x| match &x.repolib_id {
|
||||
Some(t) => t == "system",
|
||||
None => false,
|
||||
})
|
||||
.next()
|
||||
.unwrap();
|
||||
|
||||
let system_mirror_refcell = Rc::new(RefCell::new(system_source.repolib_default_mirror.as_deref().unwrap().to_string()));
|
||||
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)
|
||||
@ -105,7 +101,9 @@ pub fn apt_manage_page(
|
||||
#[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.set_sensitive(
|
||||
!(entry.text().to_string() == system_mirror_refcell.borrow().to_string()),
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
@ -123,12 +121,24 @@ pub fn apt_manage_page(
|
||||
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()) {
|
||||
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() {
|
||||
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();
|
||||
*system_mirror_refcell.borrow_mut() =
|
||||
system_mirror_entry.text().to_string();
|
||||
button.set_sensitive(false);
|
||||
}
|
||||
Err(e) => {
|
||||
@ -139,7 +149,7 @@ pub fn apt_manage_page(
|
||||
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);
|
||||
}
|
||||
@ -153,7 +163,7 @@ pub fn apt_manage_page(
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -182,91 +192,84 @@ pub fn apt_manage_page(
|
||||
.margin_end(15)
|
||||
.build();
|
||||
|
||||
let unofficial_sources_selection_model_rc: Rc<RefCell<gtk::SingleSelection>> = Rc::new(RefCell::default());
|
||||
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_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();
|
||||
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
|
||||
}
|
||||
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>();
|
||||
let legacy_apt_repos = apt_legacy_tools::LegacyAptSource::get_legacy_sources();
|
||||
|
||||
for deb822_source in unofficial_deb822_sources {
|
||||
unofficial_sources_list_store.append(&BoxedAnyObject::new(AptSourceConfig::DEB822(deb822_source)));
|
||||
};
|
||||
let unofficial_sources_list_store = gio::ListStore::new::<BoxedAnyObject>();
|
||||
|
||||
match legacy_apt_repos {
|
||||
Ok(vec) => {
|
||||
for legacy_repo in vec {
|
||||
unofficial_sources_list_store.append(&BoxedAnyObject::new(AptSourceConfig::Legacy(legacy_repo)));
|
||||
};
|
||||
for deb822_source in unofficial_deb822_sources {
|
||||
unofficial_sources_list_store
|
||||
.append(&BoxedAnyObject::new(AptSourceConfig::DEB822(deb822_source)));
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
|
||||
let unofficial_sources_selection_model = SingleSelection::new(Some(unofficial_sources_list_store));
|
||||
match legacy_apt_repos {
|
||||
Ok(vec) => {
|
||||
for legacy_repo in vec {
|
||||
unofficial_sources_list_store
|
||||
.append(&BoxedAnyObject::new(AptSourceConfig::Legacy(legacy_repo)));
|
||||
}
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
|
||||
(*unofficial_sources_selection_model_rc_clone0.borrow_mut() = unofficial_sources_selection_model.clone());
|
||||
let unofficial_sources_selection_model =
|
||||
SingleSelection::new(Some(unofficial_sources_list_store));
|
||||
|
||||
let unofficial_sources_columnview = ColumnView::builder()
|
||||
.vexpand(true)
|
||||
.model(&unofficial_sources_selection_model)
|
||||
.build();
|
||||
(*unofficial_sources_selection_model_rc_clone0.borrow_mut() =
|
||||
unofficial_sources_selection_model.clone());
|
||||
|
||||
//
|
||||
|
||||
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)
|
||||
let unofficial_sources_columnview = ColumnView::builder()
|
||||
.vexpand(true)
|
||||
.model(&unofficial_sources_selection_model)
|
||||
.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 {
|
||||
//
|
||||
|
||||
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)) => {
|
||||
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!("{} {} {} {}",
|
||||
(_, _, _) => &t!("apt_source_parse_error").to_string(),
|
||||
},
|
||||
},
|
||||
AptSourceConfig::Legacy(src) => &format!(
|
||||
"{} {} {} {}",
|
||||
if src.is_source {
|
||||
"(Legacy Src)"
|
||||
} else {
|
||||
@ -275,69 +278,64 @@ pub fn apt_manage_page(
|
||||
&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();
|
||||
),
|
||||
};
|
||||
child.set_label(&repo_name);
|
||||
});
|
||||
|
||||
//
|
||||
|
||||
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)
|
||||
let unofficial_sources_columnview_col0 = gtk::ColumnViewColumn::builder()
|
||||
.title(t!("unofficial_sources_columnview_col0_title"))
|
||||
.factory(&unofficial_sources_columnview_factory0)
|
||||
.expand(true)
|
||||
.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 {
|
||||
//
|
||||
|
||||
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"));
|
||||
}
|
||||
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));
|
||||
}));
|
||||
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);
|
||||
|
||||
@ -398,17 +396,14 @@ pub fn apt_manage_page(
|
||||
retry_signal_action,
|
||||
#[strong]
|
||||
apt_retry_signal_action,
|
||||
move
|
||||
|_|
|
||||
{
|
||||
add_dialog::add_dialog_fn(
|
||||
window.clone(),
|
||||
&retry_signal_action,
|
||||
&apt_retry_signal_action
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
move |_| {
|
||||
add_dialog::add_dialog_fn(
|
||||
window.clone(),
|
||||
&retry_signal_action,
|
||||
&apt_retry_signal_action,
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
unofficial_source_edit_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
@ -419,25 +414,29 @@ pub fn apt_manage_page(
|
||||
retry_signal_action,
|
||||
#[strong]
|
||||
apt_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, &apt_retry_signal_action);
|
||||
}
|
||||
AptSourceConfig::Legacy(list) => {
|
||||
legacy_edit_dialog::legacy_edit_dialog_fn(window.clone(), list, &retry_signal_action, &apt_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,
|
||||
&apt_retry_signal_action,
|
||||
);
|
||||
}
|
||||
AptSourceConfig::Legacy(list) => legacy_edit_dialog::legacy_edit_dialog_fn(
|
||||
window.clone(),
|
||||
list,
|
||||
&retry_signal_action,
|
||||
&apt_retry_signal_action,
|
||||
),
|
||||
};
|
||||
}
|
||||
));
|
||||
|
||||
unofficial_source_remove_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
@ -448,73 +447,90 @@ pub fn apt_manage_page(
|
||||
retry_signal_action,
|
||||
#[strong]
|
||||
apt_retry_signal_action,
|
||||
move
|
||||
|_|
|
||||
move |_| {
|
||||
{
|
||||
let mut _command = duct::cmd!("");
|
||||
{
|
||||
let mut command = duct::cmd!("");
|
||||
{
|
||||
let unofficial_sources_selection_model = unofficial_sources_selection_model_rc.borrow();
|
||||
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 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)}
|
||||
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)}
|
||||
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();
|
||||
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() {
|
||||
"apt_src_remove_warning_dialog_ok" => {
|
||||
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()
|
||||
.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);
|
||||
apt_retry_signal_action_clone0.activate(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
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();
|
||||
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() {
|
||||
"apt_src_remove_warning_dialog_ok" => 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()
|
||||
.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);
|
||||
apt_retry_signal_action_clone0.activate(None)
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
},
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
//
|
||||
|
||||
@ -539,4 +555,4 @@ pub fn apt_manage_page(
|
||||
main_box.append(&unofficial_sources_viewport);
|
||||
|
||||
main_box
|
||||
}
|
||||
}
|
||||
|
@ -66,9 +66,7 @@ pub fn apt_update_page(
|
||||
|
||||
thread::spawn(move || {
|
||||
let apt_update_command = Command::new("pkexec")
|
||||
.args([
|
||||
"/usr/lib/pika/pikman-update-manager/scripts/apt_update",
|
||||
])
|
||||
.args(["/usr/lib/pika/pikman-update-manager/scripts/apt_update"])
|
||||
.status()
|
||||
.unwrap();
|
||||
match apt_update_command.code().unwrap() {
|
||||
@ -134,7 +132,7 @@ pub fn apt_update_page(
|
||||
.title(t!("apt_ignored_viewport_page_title"))
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.build();
|
||||
.build();
|
||||
|
||||
let viewport_bin = adw::Bin::builder()
|
||||
.child(&packages_no_viewport_page)
|
||||
@ -182,8 +180,6 @@ pub fn apt_update_page(
|
||||
apt_update_dialog.set_response_enabled("apt_update_dialog_retry", false);
|
||||
apt_update_dialog.set_response_enabled("apt_update_dialog_ignore", false);
|
||||
|
||||
|
||||
|
||||
if window.is_visible() {
|
||||
let retry_signal_action0 = retry_signal_action.clone();
|
||||
let viewport_bin = viewport_bin.clone();
|
||||
@ -455,7 +451,10 @@ pub fn apt_update_page(
|
||||
(*apt_update_count.borrow_mut() += 1);
|
||||
if state.is_last {
|
||||
packages_boxedlist.set_sensitive(true);
|
||||
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[*apt_update_count.borrow(),*flatpak_update_count.borrow()])));
|
||||
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[
|
||||
*apt_update_count.borrow(),
|
||||
*flatpak_update_count.borrow(),
|
||||
])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -412,9 +412,7 @@ fn apt_full_upgrade_from_socket(
|
||||
|
||||
thread::spawn(move || {
|
||||
let apt_upgrade_command = Command::new("pkexec")
|
||||
.args([
|
||||
"/usr/lib/pika/pikman-update-manager/scripts/apt_full_upgrade",
|
||||
])
|
||||
.args(["/usr/lib/pika/pikman-update-manager/scripts/apt_full_upgrade"])
|
||||
.status()
|
||||
.unwrap();
|
||||
match apt_upgrade_command.code().unwrap() {
|
||||
|
@ -1,22 +1,17 @@
|
||||
use crate::apt_manage_page::apt_manage_page;
|
||||
use crate::flatpak_manage_page::flatpak_manage_page;
|
||||
use crate::apt_update_page;
|
||||
use crate::config::{APP_GITHUB, APP_ICON, APP_ID, VERSION};
|
||||
use crate::flatpak_manage_page::flatpak_manage_page;
|
||||
use crate::flatpak_update_page;
|
||||
use adw::prelude::*;
|
||||
use adw::*;
|
||||
use async_channel::Sender;
|
||||
use futures::task::SpawnExt;
|
||||
use gtk::glib::{clone, MainContext};
|
||||
use gtk::{License, WindowControls};
|
||||
use ksni;
|
||||
use std::cell::RefCell;
|
||||
use std::ops::Index;
|
||||
use std::process::Command;
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::thread;
|
||||
use std::sync::Arc;
|
||||
use ksni;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct PikmanTray {
|
||||
@ -30,11 +25,11 @@ impl ksni::Tray for PikmanTray {
|
||||
fn icon_name(&self) -> String {
|
||||
match &self.icon_name {
|
||||
Some(t) => t.into(),
|
||||
None => "help-about".into()
|
||||
None => "help-about".into(),
|
||||
}
|
||||
}
|
||||
fn title(&self) -> String {
|
||||
t!("application_name").to_string()
|
||||
t!("application_name").to_string()
|
||||
}
|
||||
// NOTE: On some system trays, `id` is a required property to avoid unexpected behaviors
|
||||
fn id(&self) -> String {
|
||||
@ -46,8 +41,9 @@ impl ksni::Tray for PikmanTray {
|
||||
StandardItem {
|
||||
label: match &self.apt_item_label {
|
||||
Some(t) => t,
|
||||
None => "?"
|
||||
}.into(),
|
||||
None => "?",
|
||||
}
|
||||
.into(),
|
||||
icon_name: "application-vnd.debian.binary-package".into(),
|
||||
enabled: false,
|
||||
..Default::default()
|
||||
@ -56,8 +52,9 @@ impl ksni::Tray for PikmanTray {
|
||||
StandardItem {
|
||||
label: match &self.flatpak_item_label {
|
||||
Some(t) => t,
|
||||
None => "?"
|
||||
}.into(),
|
||||
None => "?",
|
||||
}
|
||||
.into(),
|
||||
icon_name: "application-vnd.flatpak".into(),
|
||||
enabled: false,
|
||||
..Default::default()
|
||||
@ -68,7 +65,9 @@ impl ksni::Tray for PikmanTray {
|
||||
label: t!("pikman_indicator_open_item_label").into(),
|
||||
icon_name: "view-paged-symbolic".into(),
|
||||
activate: Box::new(|_| {
|
||||
self.action_sender.send_blocking(String::from("open")).unwrap()
|
||||
self.action_sender
|
||||
.send_blocking(String::from("open"))
|
||||
.unwrap()
|
||||
}),
|
||||
..Default::default()
|
||||
}
|
||||
@ -111,13 +110,13 @@ pub fn build_ui(app: &Application) {
|
||||
flatpak_item_label: None,
|
||||
});
|
||||
let tray_handle = tray_service.handle();
|
||||
|
||||
|
||||
tray_service.spawn();
|
||||
|
||||
update_sys_tray.connect_activate(clone!(
|
||||
#[strong]
|
||||
tray_handle,
|
||||
move |_,param| {
|
||||
move |_, param| {
|
||||
let array: &[i32] = param.unwrap().fixed_array().unwrap();
|
||||
let vec = array.to_vec();
|
||||
let apt_update_count = vec[0];
|
||||
@ -129,35 +128,36 @@ pub fn build_ui(app: &Application) {
|
||||
};
|
||||
tray_handle.update(|tray: &mut PikmanTray| {
|
||||
tray.icon_name = tray_icon;
|
||||
tray.apt_item_label = Some(strfmt::strfmt(
|
||||
&t!("pikman_indicator_apt_count_item_label").to_string(),
|
||||
&std::collections::HashMap::from([
|
||||
(
|
||||
tray.apt_item_label = Some(
|
||||
strfmt::strfmt(
|
||||
&t!("pikman_indicator_apt_count_item_label").to_string(),
|
||||
&std::collections::HashMap::from([(
|
||||
"NUM".to_string(),
|
||||
match apt_update_count {
|
||||
-1 => t!("pikman_indicator_flatpak_item_label_calculating").into(),
|
||||
_ => apt_update_count.to_string(),
|
||||
},
|
||||
),
|
||||
]),
|
||||
)
|
||||
.unwrap());
|
||||
tray.flatpak_item_label = Some(strfmt::strfmt(
|
||||
&t!("pikman_indicator_flatpak_count_item_label").to_string(),
|
||||
&std::collections::HashMap::from([
|
||||
(
|
||||
)]),
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
tray.flatpak_item_label = Some(
|
||||
strfmt::strfmt(
|
||||
&t!("pikman_indicator_flatpak_count_item_label").to_string(),
|
||||
&std::collections::HashMap::from([(
|
||||
"NUM".to_string(),
|
||||
match flatpak_update_count {
|
||||
-1 => t!("pikman_indicator_flatpak_item_label_calculating").into(),
|
||||
_ => flatpak_update_count.to_string(),
|
||||
},
|
||||
),
|
||||
]),
|
||||
)
|
||||
.unwrap());
|
||||
)]),
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
});
|
||||
}));
|
||||
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[-1,-1])));
|
||||
}
|
||||
));
|
||||
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[-1, -1])));
|
||||
|
||||
thread::spawn(move || loop {
|
||||
match Command::new("ping").arg("google.com").arg("-c 1").output() {
|
||||
@ -228,16 +228,27 @@ pub fn build_ui(app: &Application) {
|
||||
.margin_end(5)
|
||||
.hexpand(true)
|
||||
.build();
|
||||
window_adw_view_switcher_sidebar_control_box.append(&WindowControls::builder().halign(gtk::Align::Start).valign(gtk::Align::Center).build());
|
||||
window_adw_view_switcher_sidebar_control_box.append(&WindowTitle::builder().halign(gtk::Align::Center).margin_top(10).margin_bottom(20).valign(gtk::Align::Center).hexpand(true).title(t!("application_name")).build());
|
||||
|
||||
window_adw_view_switcher_sidebar_control_box.append(
|
||||
&WindowControls::builder()
|
||||
.halign(gtk::Align::Start)
|
||||
.valign(gtk::Align::Center)
|
||||
.build(),
|
||||
);
|
||||
window_adw_view_switcher_sidebar_control_box.append(
|
||||
&WindowTitle::builder()
|
||||
.halign(gtk::Align::Center)
|
||||
.margin_top(10)
|
||||
.margin_bottom(20)
|
||||
.valign(gtk::Align::Center)
|
||||
.hexpand(true)
|
||||
.title(t!("application_name"))
|
||||
.build(),
|
||||
);
|
||||
|
||||
let window_adw_view_switcher_sidebar_box = gtk::Box::new(gtk::Orientation::Vertical, 0);
|
||||
window_adw_view_switcher_sidebar_box.append(&window_adw_view_switcher_sidebar_control_box);
|
||||
|
||||
let null_toggle_button: gtk::ToggleButton = gtk::ToggleButton::new();
|
||||
|
||||
let window_adw_stack_clone0 = window_adw_stack.clone();
|
||||
let window_adw_view_switcher_sidebar_box_clone0 = window_adw_view_switcher_sidebar_box.clone();
|
||||
let null_toggle_button: gtk::ToggleButton = gtk::ToggleButton::new();
|
||||
|
||||
let sidebar_toggle_button = gtk::ToggleButton::builder()
|
||||
.icon_name("view-right-pane-symbolic")
|
||||
@ -266,16 +277,8 @@ pub fn build_ui(app: &Application) {
|
||||
"collapsed",
|
||||
Some(&true.to_value()),
|
||||
);
|
||||
window_breakpoint.add_setter(
|
||||
&sidebar_toggle_button,
|
||||
"visible",
|
||||
Some(&true.to_value()),
|
||||
);
|
||||
window_breakpoint.add_setter(
|
||||
&window_headerbar,
|
||||
"show_title",
|
||||
Some(&true.to_value()),
|
||||
);
|
||||
window_breakpoint.add_setter(&sidebar_toggle_button, "visible", Some(&true.to_value()));
|
||||
window_breakpoint.add_setter(&window_headerbar, "show_title", Some(&true.to_value()));
|
||||
|
||||
window_headerbar.pack_end(&sidebar_toggle_button);
|
||||
|
||||
@ -312,12 +315,10 @@ pub fn build_ui(app: &Application) {
|
||||
}
|
||||
|
||||
window.connect_close_request(move |window| {
|
||||
if let Some(application) = window.application() {
|
||||
let size = window.default_size();
|
||||
let _ = glib_settings.set_int("window-width", size.0);
|
||||
let _ = glib_settings.set_int("window-height", size.1);
|
||||
let _ = glib_settings.set_boolean("is-maximized", window.is_maximized());
|
||||
}
|
||||
let size = window.default_size();
|
||||
let _ = glib_settings.set_int("window-width", size.0);
|
||||
let _ = glib_settings.set_int("window-height", size.1);
|
||||
let _ = glib_settings.set_boolean("is-maximized", window.is_maximized());
|
||||
glib::Propagation::Proceed
|
||||
});
|
||||
|
||||
@ -353,8 +354,7 @@ pub fn build_ui(app: &Application) {
|
||||
|
||||
let flatpak_retry_signal_action = gio::SimpleAction::new("retry", None);
|
||||
|
||||
let flatpak_update_view_stack_bin = Bin::builder()
|
||||
.build();
|
||||
let flatpak_update_view_stack_bin = Bin::builder().build();
|
||||
|
||||
flatpak_retry_signal_action.connect_activate(clone!(
|
||||
#[weak]
|
||||
@ -370,13 +370,15 @@ pub fn build_ui(app: &Application) {
|
||||
#[strong]
|
||||
flatpak_update_count,
|
||||
move |_, _| {
|
||||
flatpak_update_view_stack_bin.set_child(Some(&flatpak_update_page::flatpak_update_page(
|
||||
window,
|
||||
&flatpak_retry_signal_action,
|
||||
&update_sys_tray,
|
||||
&apt_update_count,
|
||||
&flatpak_update_count,
|
||||
)));
|
||||
flatpak_update_view_stack_bin.set_child(Some(
|
||||
&flatpak_update_page::flatpak_update_page(
|
||||
window,
|
||||
&flatpak_retry_signal_action,
|
||||
&update_sys_tray,
|
||||
&apt_update_count,
|
||||
&flatpak_update_count,
|
||||
),
|
||||
));
|
||||
}
|
||||
));
|
||||
|
||||
@ -388,34 +390,34 @@ pub fn build_ui(app: &Application) {
|
||||
let apt_update_view_stack_bin = Bin::builder().build();
|
||||
|
||||
apt_retry_signal_action.connect_activate(clone!(
|
||||
#[weak]
|
||||
window,
|
||||
#[strong]
|
||||
apt_retry_signal_action,
|
||||
#[strong]
|
||||
flatpak_retry_signal_action,
|
||||
#[strong]
|
||||
apt_update_view_stack_bin,
|
||||
#[weak]
|
||||
flatpak_ran_once,
|
||||
#[strong]
|
||||
update_sys_tray,
|
||||
#[strong]
|
||||
apt_update_count,
|
||||
#[strong]
|
||||
flatpak_update_count,
|
||||
move |_, _| {
|
||||
apt_update_view_stack_bin.set_child(Some(&apt_update_page::apt_update_page(
|
||||
window,
|
||||
&apt_retry_signal_action,
|
||||
&flatpak_retry_signal_action,
|
||||
flatpak_ran_once,
|
||||
&update_sys_tray,
|
||||
&apt_update_count,
|
||||
&flatpak_update_count,
|
||||
)));
|
||||
}
|
||||
));
|
||||
#[weak]
|
||||
window,
|
||||
#[strong]
|
||||
apt_retry_signal_action,
|
||||
#[strong]
|
||||
flatpak_retry_signal_action,
|
||||
#[strong]
|
||||
apt_update_view_stack_bin,
|
||||
#[weak]
|
||||
flatpak_ran_once,
|
||||
#[strong]
|
||||
update_sys_tray,
|
||||
#[strong]
|
||||
apt_update_count,
|
||||
#[strong]
|
||||
flatpak_update_count,
|
||||
move |_, _| {
|
||||
apt_update_view_stack_bin.set_child(Some(&apt_update_page::apt_update_page(
|
||||
window,
|
||||
&apt_retry_signal_action,
|
||||
&flatpak_retry_signal_action,
|
||||
flatpak_ran_once,
|
||||
&update_sys_tray,
|
||||
&apt_update_count,
|
||||
&flatpak_update_count,
|
||||
)));
|
||||
}
|
||||
));
|
||||
|
||||
apt_update_view_stack_bin.set_child(Some(&apt_update_page::apt_update_page(
|
||||
window.clone(),
|
||||
@ -435,7 +437,13 @@ pub fn build_ui(app: &Application) {
|
||||
&t!("apt_update_page_title"),
|
||||
);
|
||||
|
||||
let apt_update_page_toggle_button = add_content_button(&window_adw_stack, true, "apt_update_page".to_string(), t!("apt_update_page_title").to_string(), &null_toggle_button);
|
||||
let apt_update_page_toggle_button = add_content_button(
|
||||
&window_adw_stack,
|
||||
true,
|
||||
"apt_update_page".to_string(),
|
||||
t!("apt_update_page_title").to_string(),
|
||||
&null_toggle_button,
|
||||
);
|
||||
window_adw_view_switcher_sidebar_box.append(&apt_update_page_toggle_button);
|
||||
|
||||
window_adw_stack.add_titled(
|
||||
@ -444,7 +452,13 @@ pub fn build_ui(app: &Application) {
|
||||
&t!("flatpak_update_page_title"),
|
||||
);
|
||||
|
||||
let flatpak_update_page_toggle_button = add_content_button(&window_adw_stack, false, "flatpak_update_page".to_string(), t!("flatpak_update_page_title").to_string(), &null_toggle_button);
|
||||
let flatpak_update_page_toggle_button = add_content_button(
|
||||
&window_adw_stack,
|
||||
false,
|
||||
"flatpak_update_page".to_string(),
|
||||
t!("flatpak_update_page_title").to_string(),
|
||||
&null_toggle_button,
|
||||
);
|
||||
window_adw_view_switcher_sidebar_box.append(&flatpak_update_page_toggle_button);
|
||||
|
||||
window_adw_stack.add_titled(
|
||||
@ -453,10 +467,17 @@ pub fn build_ui(app: &Application) {
|
||||
&t!("apt_manage_page_title"),
|
||||
);
|
||||
|
||||
let apt_manage_page_toggle_button = add_content_button(&window_adw_stack, false, "apt_manage_page".to_string(), t!("apt_manage_page_title").to_string(), &null_toggle_button);
|
||||
let apt_manage_page_toggle_button = add_content_button(
|
||||
&window_adw_stack,
|
||||
false,
|
||||
"apt_manage_page".to_string(),
|
||||
t!("apt_manage_page_title").to_string(),
|
||||
&null_toggle_button,
|
||||
);
|
||||
window_adw_view_switcher_sidebar_box.append(&apt_manage_page_toggle_button);
|
||||
|
||||
let flatpak_entry_signal_action = gio::SimpleAction::new("entry-change", Some(glib::VariantTy::STRING));
|
||||
let flatpak_entry_signal_action =
|
||||
gio::SimpleAction::new("entry-change", Some(glib::VariantTy::STRING));
|
||||
|
||||
let flatpak_flatref_install_button = gtk::Button::builder()
|
||||
.icon_name("document-open-symbolic")
|
||||
@ -466,12 +487,23 @@ pub fn build_ui(app: &Application) {
|
||||
.build();
|
||||
|
||||
window_adw_stack.add_titled(
|
||||
&flatpak_manage_page(window.clone(), &flatpak_retry_signal_action, &flatpak_entry_signal_action, &flatpak_flatref_install_button),
|
||||
&flatpak_manage_page(
|
||||
window.clone(),
|
||||
&flatpak_retry_signal_action,
|
||||
&flatpak_entry_signal_action,
|
||||
&flatpak_flatref_install_button,
|
||||
),
|
||||
Some("flatpak_manage_page"),
|
||||
&t!("flatpak_manage_page_title"),
|
||||
);
|
||||
|
||||
let flatpak_manage_page_toggle_button = add_content_button(&window_adw_stack, false, "flatpak_manage_page".to_string(), t!("flatpak_manage_page_title").to_string(), &null_toggle_button);
|
||||
let flatpak_manage_page_toggle_button = add_content_button(
|
||||
&window_adw_stack,
|
||||
false,
|
||||
"flatpak_manage_page".to_string(),
|
||||
t!("flatpak_manage_page_title").to_string(),
|
||||
&null_toggle_button,
|
||||
);
|
||||
window_adw_view_switcher_sidebar_box.append(&flatpak_manage_page_toggle_button);
|
||||
|
||||
app.connect_command_line(clone!(
|
||||
@ -486,37 +518,45 @@ pub fn build_ui(app: &Application) {
|
||||
#[strong]
|
||||
flatpak_entry_signal_action,
|
||||
move |_, cmdline| {
|
||||
// Create Vec from cmdline
|
||||
let mut gtk_application_args = Vec::new();
|
||||
for arg in cmdline.arguments() {
|
||||
match arg.to_str() {
|
||||
Some(a) => gtk_application_args.push(a.to_string()),
|
||||
None => {}
|
||||
// Create Vec from cmdline
|
||||
let mut gtk_application_args = Vec::new();
|
||||
for arg in cmdline.arguments() {
|
||||
match arg.to_str() {
|
||||
Some(a) => gtk_application_args.push(a.to_string()),
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for cmd lines
|
||||
if !(gtk_application_args.contains(&"--hidden".to_string())) && !(gtk_application_args.contains(&"--flatpak-installer".to_string())) && !window.is_visible() {
|
||||
window.present();
|
||||
}
|
||||
// Check for cmd lines
|
||||
if !(gtk_application_args.contains(&"--hidden".to_string()))
|
||||
&& !(gtk_application_args.contains(&"--flatpak-installer".to_string()))
|
||||
&& !window.is_visible()
|
||||
{
|
||||
window.present();
|
||||
}
|
||||
|
||||
if gtk_application_args.contains(&"--software-properties".to_string()) {
|
||||
apt_manage_page_toggle_button.set_active(true);
|
||||
apt_manage_page_toggle_button.emit_clicked();
|
||||
}
|
||||
if gtk_application_args.contains(&"--flatpak-settings".to_string()) {
|
||||
flatpak_manage_page_toggle_button.set_active(true);
|
||||
flatpak_manage_page_toggle_button.emit_clicked();
|
||||
}
|
||||
if gtk_application_args.contains(&"--flatpak-installer".to_string()) {
|
||||
flatpak_flatref_install_button.emit_clicked();
|
||||
let index = ((gtk_application_args.iter().position(|r| r == "--flatpak-installer").unwrap() as i32) +1) as usize;
|
||||
flatpak_entry_signal_action.activate(Some(&glib::Variant::from(>k_application_args[index])));
|
||||
}
|
||||
|
||||
0
|
||||
}));
|
||||
if gtk_application_args.contains(&"--software-properties".to_string()) {
|
||||
apt_manage_page_toggle_button.set_active(true);
|
||||
apt_manage_page_toggle_button.emit_clicked();
|
||||
}
|
||||
if gtk_application_args.contains(&"--flatpak-settings".to_string()) {
|
||||
flatpak_manage_page_toggle_button.set_active(true);
|
||||
flatpak_manage_page_toggle_button.emit_clicked();
|
||||
}
|
||||
if gtk_application_args.contains(&"--flatpak-installer".to_string()) {
|
||||
flatpak_flatref_install_button.emit_clicked();
|
||||
let index = ((gtk_application_args
|
||||
.iter()
|
||||
.position(|r| r == "--flatpak-installer")
|
||||
.unwrap() as i32)
|
||||
+ 1) as usize;
|
||||
flatpak_entry_signal_action
|
||||
.activate(Some(&glib::Variant::from(>k_application_args[index])));
|
||||
}
|
||||
|
||||
0
|
||||
}
|
||||
));
|
||||
|
||||
// Refresh button
|
||||
|
||||
@ -551,15 +591,20 @@ pub fn build_ui(app: &Application) {
|
||||
window.present();
|
||||
}
|
||||
}
|
||||
_ => todo!()
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
fn add_content_button(window_adw_stack: >k::Stack, active: bool, name: String, title: String, null_toggle_button: >k::ToggleButton) -> gtk::ToggleButton {
|
||||
fn add_content_button(
|
||||
window_adw_stack: >k::Stack,
|
||||
active: bool,
|
||||
name: String,
|
||||
title: String,
|
||||
null_toggle_button: >k::ToggleButton,
|
||||
) -> gtk::ToggleButton {
|
||||
let toggle_button = gtk::ToggleButton::builder()
|
||||
.group(null_toggle_button)
|
||||
.label(&title)
|
||||
@ -571,10 +616,14 @@ fn add_content_button(window_adw_stack: >k::Stack, active: bool, name: String,
|
||||
.valign(gtk::Align::Start)
|
||||
.build();
|
||||
toggle_button.add_css_class("flat");
|
||||
toggle_button.connect_clicked(clone!(#[weak] window_adw_stack,move |toggle_button| {
|
||||
if toggle_button.is_active() {
|
||||
window_adw_stack.set_visible_child_name(&name);
|
||||
toggle_button.connect_clicked(clone!(
|
||||
#[weak]
|
||||
window_adw_stack,
|
||||
move |toggle_button| {
|
||||
if toggle_button.is_active() {
|
||||
window_adw_stack.set_visible_child_name(&name);
|
||||
}
|
||||
}
|
||||
}));
|
||||
));
|
||||
toggle_button
|
||||
}
|
||||
}
|
||||
|
@ -1,245 +1,234 @@
|
||||
use crate::apt_package_row::AptPackageRow;
|
||||
use adw::gio::SimpleAction;
|
||||
use adw::prelude::*;
|
||||
use apt_deb822_tools::Deb822Repository;
|
||||
use libflatpak::builders::RemoteRefBuilder;
|
||||
use regex::{bytes, Regex};
|
||||
use gtk::glib::{property::PropertyGet, clone, BoxedAnyObject};
|
||||
use gtk::glib::clone;
|
||||
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 libflatpak::prelude::*;
|
||||
use libflatpak::InstalledRef;
|
||||
|
||||
pub fn add_dialog_fn(
|
||||
window: adw::ApplicationWindow,
|
||||
reload_action: &gio::SimpleAction,
|
||||
flatpak_retry_signal_action: &SimpleAction,
|
||||
)
|
||||
{
|
||||
let flatpak_remote_add_dialog_child_box = Box::builder()
|
||||
.hexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let flatpak_remote_add_name_entry = gtk::Entry::builder()
|
||||
.placeholder_text("Flathub")
|
||||
.build();
|
||||
window: adw::ApplicationWindow,
|
||||
reload_action: &gio::SimpleAction,
|
||||
flatpak_retry_signal_action: &SimpleAction,
|
||||
) {
|
||||
let flatpak_remote_add_dialog_child_box = Box::builder()
|
||||
.hexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let flatpak_remote_add_name_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("flatpak_remote_add_name_prefrencesgroup_title"))
|
||||
.build();
|
||||
let flatpak_remote_add_name_entry = gtk::Entry::builder().placeholder_text("Flathub").build();
|
||||
|
||||
flatpak_remote_add_name_prefrencesgroup.add(&flatpak_remote_add_name_entry);
|
||||
let flatpak_remote_add_name_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("flatpak_remote_add_name_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let flatpak_remote_add_url_entry = gtk::Entry::builder()
|
||||
.placeholder_text("https://dl.flathub.org/repo/flathub.flatpakrepo")
|
||||
.build();
|
||||
flatpak_remote_add_name_prefrencesgroup.add(&flatpak_remote_add_name_entry);
|
||||
|
||||
let flatpak_remote_add_url_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("flatpak_remote_add_url_prefrencesgroup_title"))
|
||||
.build();
|
||||
let flatpak_remote_add_url_entry = gtk::Entry::builder()
|
||||
.placeholder_text("https://dl.flathub.org/repo/flathub.flatpakrepo")
|
||||
.build();
|
||||
|
||||
flatpak_remote_add_url_prefrencesgroup.add(&flatpak_remote_add_url_entry);
|
||||
let flatpak_remote_add_url_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("flatpak_remote_add_url_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
let flatpak_remote_add_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
.orientation(Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.spacing(5)
|
||||
.build();
|
||||
flatpak_remote_add_url_prefrencesgroup.add(&flatpak_remote_add_url_entry);
|
||||
|
||||
let flatpak_remote_user_togglebutton = gtk::ToggleButton::builder()
|
||||
.valign(Align::Center)
|
||||
.hexpand(true)
|
||||
.label(t!("flatpak_remotes_columnview_user"))
|
||||
.active(true)
|
||||
.build();
|
||||
let flatpak_remote_add_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
.orientation(Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.spacing(5)
|
||||
.build();
|
||||
|
||||
let flatpak_remote_system_togglebutton = gtk::ToggleButton::builder()
|
||||
.valign(Align::Center)
|
||||
.hexpand(true)
|
||||
.label(t!("flatpak_remotes_columnview_system"))
|
||||
.group(&flatpak_remote_user_togglebutton)
|
||||
.build();
|
||||
let flatpak_remote_user_togglebutton = gtk::ToggleButton::builder()
|
||||
.valign(Align::Center)
|
||||
.hexpand(true)
|
||||
.label(t!("flatpak_remotes_columnview_user"))
|
||||
.active(true)
|
||||
.build();
|
||||
|
||||
//
|
||||
let flatpak_remote_add_dialog_child_clamp = adw::Clamp::builder()
|
||||
.child(&flatpak_remote_add_dialog_child_box)
|
||||
.maximum_size(500)
|
||||
.build();
|
||||
let flatpak_remote_system_togglebutton = gtk::ToggleButton::builder()
|
||||
.valign(Align::Center)
|
||||
.hexpand(true)
|
||||
.label(t!("flatpak_remotes_columnview_system"))
|
||||
.group(&flatpak_remote_user_togglebutton)
|
||||
.build();
|
||||
|
||||
let flatpak_remote_add_viewport = gtk::ScrolledWindow::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.child(&flatpak_remote_add_dialog_child_clamp)
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.build();
|
||||
//
|
||||
let flatpak_remote_add_dialog_child_clamp = adw::Clamp::builder()
|
||||
.child(&flatpak_remote_add_dialog_child_box)
|
||||
.maximum_size(500)
|
||||
.build();
|
||||
|
||||
let flatpak_remote_add_dialog = adw::MessageDialog::builder()
|
||||
.transient_for(&window)
|
||||
.extra_child(&flatpak_remote_add_viewport)
|
||||
.heading(t!("flatpak_remote_add_dialog_heading"))
|
||||
.width_request(700)
|
||||
.height_request(400)
|
||||
.build();
|
||||
let flatpak_remote_add_viewport = gtk::ScrolledWindow::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.child(&flatpak_remote_add_dialog_child_clamp)
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.build();
|
||||
|
||||
flatpak_remote_add_dialog.add_response(
|
||||
"flatpak_remote_add_dialog_add",
|
||||
&t!("flatpak_remote_add_dialog_add_label").to_string(),
|
||||
);
|
||||
|
||||
flatpak_remote_add_dialog.add_response(
|
||||
"flatpak_remote_add_dialog_cancel",
|
||||
&t!("flatpak_remote_add_dialog_cancel_label").to_string(),
|
||||
);
|
||||
let flatpak_remote_add_dialog = adw::MessageDialog::builder()
|
||||
.transient_for(&window)
|
||||
.extra_child(&flatpak_remote_add_viewport)
|
||||
.heading(t!("flatpak_remote_add_dialog_heading"))
|
||||
.width_request(700)
|
||||
.height_request(400)
|
||||
.build();
|
||||
|
||||
flatpak_remote_add_dialog.set_response_enabled("flatpak_remote_add_dialog_add", false);
|
||||
|
||||
flatpak_remote_add_dialog.set_response_appearance(
|
||||
"flatpak_remote_add_dialog_cancel",
|
||||
adw::ResponseAppearance::Destructive,
|
||||
);
|
||||
flatpak_remote_add_dialog.add_response(
|
||||
"flatpak_remote_add_dialog_add",
|
||||
&t!("flatpak_remote_add_dialog_add_label").to_string(),
|
||||
);
|
||||
|
||||
flatpak_remote_add_dialog.set_response_appearance(
|
||||
"flatpak_remote_add_dialog_add",
|
||||
adw::ResponseAppearance::Suggested,
|
||||
);
|
||||
flatpak_remote_add_dialog.add_response(
|
||||
"flatpak_remote_add_dialog_cancel",
|
||||
&t!("flatpak_remote_add_dialog_cancel_label").to_string(),
|
||||
);
|
||||
|
||||
//
|
||||
flatpak_remote_add_dialog.set_response_enabled("flatpak_remote_add_dialog_add", false);
|
||||
|
||||
let flatpak_remote_add_dialog_clone0 = flatpak_remote_add_dialog.clone();
|
||||
let flatpak_remote_add_name_entry_clone0 = flatpak_remote_add_name_entry.clone();
|
||||
let flatpak_remote_add_url_entry_clone0 = flatpak_remote_add_url_entry.clone();
|
||||
flatpak_remote_add_dialog.set_response_appearance(
|
||||
"flatpak_remote_add_dialog_cancel",
|
||||
adw::ResponseAppearance::Destructive,
|
||||
);
|
||||
|
||||
flatpak_remote_add_dialog.set_response_appearance(
|
||||
"flatpak_remote_add_dialog_add",
|
||||
adw::ResponseAppearance::Suggested,
|
||||
);
|
||||
|
||||
let add_button_update_state = move || {
|
||||
if
|
||||
!flatpak_remote_add_name_entry_clone0.text().is_empty() &&
|
||||
!flatpak_remote_add_url_entry_clone0.text().is_empty()
|
||||
{
|
||||
flatpak_remote_add_dialog_clone0.set_response_enabled("flatpak_remote_add_dialog_add", true);
|
||||
} else {
|
||||
flatpak_remote_add_dialog_clone0.set_response_enabled("flatpak_remote_add_dialog_add", false);
|
||||
}
|
||||
};
|
||||
//
|
||||
|
||||
//
|
||||
let flatpak_remote_add_dialog_clone0 = flatpak_remote_add_dialog.clone();
|
||||
let flatpak_remote_add_name_entry_clone0 = flatpak_remote_add_name_entry.clone();
|
||||
let flatpak_remote_add_url_entry_clone0 = flatpak_remote_add_url_entry.clone();
|
||||
|
||||
for entry in [
|
||||
&flatpak_remote_add_name_entry,
|
||||
&flatpak_remote_add_url_entry,
|
||||
] {
|
||||
entry.connect_text_notify(clone!(
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |_|
|
||||
{
|
||||
add_button_update_state();
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
flatpak_remote_add_box2.append(&flatpak_remote_user_togglebutton);
|
||||
flatpak_remote_add_box2.append(&flatpak_remote_system_togglebutton);
|
||||
let add_button_update_state = move || {
|
||||
if !flatpak_remote_add_name_entry_clone0.text().is_empty()
|
||||
&& !flatpak_remote_add_url_entry_clone0.text().is_empty()
|
||||
{
|
||||
flatpak_remote_add_dialog_clone0
|
||||
.set_response_enabled("flatpak_remote_add_dialog_add", true);
|
||||
} else {
|
||||
flatpak_remote_add_dialog_clone0
|
||||
.set_response_enabled("flatpak_remote_add_dialog_add", false);
|
||||
}
|
||||
};
|
||||
|
||||
flatpak_remote_add_dialog_child_box.append(&flatpak_remote_add_name_prefrencesgroup);
|
||||
flatpak_remote_add_dialog_child_box.append(&flatpak_remote_add_url_prefrencesgroup);
|
||||
flatpak_remote_add_dialog_child_box.append(&flatpak_remote_add_box2);
|
||||
//
|
||||
|
||||
let reload_action_clone0 = reload_action.clone();
|
||||
let flatpak_retry_signal_action_clone0 = flatpak_retry_signal_action.clone();
|
||||
for entry in [
|
||||
&flatpak_remote_add_name_entry,
|
||||
&flatpak_remote_add_url_entry,
|
||||
] {
|
||||
entry.connect_text_notify(clone!(
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |_| {
|
||||
add_button_update_state();
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
flatpak_remote_add_dialog.clone()
|
||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||
match choice.as_str() {
|
||||
"flatpak_remote_add_dialog_add" => {
|
||||
let cancellable_no = libflatpak::gio::Cancellable::NONE;
|
||||
//
|
||||
|
||||
/*let flatpak_installation = match flatpak_remote_system_togglebutton.is_active() {
|
||||
true => libflatpak::Installation::new_system(cancellable_no).unwrap(),
|
||||
false => libflatpak::Installation::new_user(cancellable_no).unwrap(),
|
||||
};
|
||||
flatpak_remote_add_box2.append(&flatpak_remote_user_togglebutton);
|
||||
flatpak_remote_add_box2.append(&flatpak_remote_system_togglebutton);
|
||||
|
||||
match libflatpak::Remote::from_file(&flatpak_remote_add_name_entry.text(), &get_data_from_url(&flatpak_remote_add_url_entry.text()).unwrap()) {
|
||||
Ok(remote) => {
|
||||
match libflatpak::Installation::add_remote(&flatpak_installation, &remote, true, cancellable_no) {
|
||||
Ok(_) => {
|
||||
reload_action_clone0.activate(None);
|
||||
}
|
||||
Err(e) => {
|
||||
let flatpak_remote_add_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("flatpak_remote_add_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
flatpak_remote_add_error_dialog.add_response(
|
||||
"flatpak_remote_add_error_dialog_ok",
|
||||
&t!("flatpak_remote_add_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
flatpak_remote_add_error_dialog.present();
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
let flatpak_remote_add_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("flatpak_remote_add_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
flatpak_remote_add_error_dialog.add_response(
|
||||
"flatpak_remote_add_error_dialog_ok",
|
||||
&t!("flatpak_remote_add_error_dialog_ok_label").to_string(),
|
||||
flatpak_remote_add_dialog_child_box.append(&flatpak_remote_add_name_prefrencesgroup);
|
||||
flatpak_remote_add_dialog_child_box.append(&flatpak_remote_add_url_prefrencesgroup);
|
||||
flatpak_remote_add_dialog_child_box.append(&flatpak_remote_add_box2);
|
||||
|
||||
let reload_action_clone0 = reload_action.clone();
|
||||
let flatpak_retry_signal_action_clone0 = flatpak_retry_signal_action.clone();
|
||||
|
||||
flatpak_remote_add_dialog
|
||||
.clone()
|
||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||
match choice.as_str() {
|
||||
"flatpak_remote_add_dialog_add" => {
|
||||
/*let cancellable_no = libflatpak::gio::Cancellable::NONE;
|
||||
|
||||
let flatpak_installation = match flatpak_remote_system_togglebutton.is_active() {
|
||||
true => libflatpak::Installation::new_system(cancellable_no).unwrap(),
|
||||
false => libflatpak::Installation::new_user(cancellable_no).unwrap(),
|
||||
};
|
||||
|
||||
match libflatpak::Remote::from_file(&flatpak_remote_add_name_entry.text(), &get_data_from_url(&flatpak_remote_add_url_entry.text()).unwrap()) {
|
||||
Ok(remote) => {
|
||||
match libflatpak::Installation::add_remote(&flatpak_installation, &remote, true, cancellable_no) {
|
||||
Ok(_) => {
|
||||
reload_action_clone0.activate(None);
|
||||
}
|
||||
Err(e) => {
|
||||
let flatpak_remote_add_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("flatpak_remote_add_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
flatpak_remote_add_error_dialog.add_response(
|
||||
"flatpak_remote_add_error_dialog_ok",
|
||||
&t!("flatpak_remote_add_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
let flatpak_installation = match flatpak_remote_system_togglebutton.is_active() {
|
||||
true => "--system",
|
||||
false => "--user"
|
||||
};
|
||||
|
||||
match duct::cmd!("flatpak", "remote-add", "--if-not-exists", &flatpak_installation, &flatpak_remote_add_name_entry.text(), &flatpak_remote_add_url_entry.text()).run() {
|
||||
Ok(_) => {
|
||||
reload_action_clone0.activate(None);
|
||||
flatpak_retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
Err(e) => {
|
||||
let flatpak_remote_add_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("flatpak_remote_add_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
flatpak_remote_add_error_dialog.add_response(
|
||||
"flatpak_remote_add_error_dialog_ok",
|
||||
&t!("flatpak_remote_add_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
flatpak_remote_add_error_dialog.present();
|
||||
}
|
||||
flatpak_remote_add_error_dialog.present();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
Err(e) => {
|
||||
let flatpak_remote_add_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("flatpak_remote_add_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
flatpak_remote_add_error_dialog.add_response(
|
||||
"flatpak_remote_add_error_dialog_ok",
|
||||
&t!("flatpak_remote_add_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
let flatpak_installation = match flatpak_remote_system_togglebutton.is_active()
|
||||
{
|
||||
true => "--system",
|
||||
false => "--user",
|
||||
};
|
||||
|
||||
match duct::cmd!(
|
||||
"flatpak",
|
||||
"remote-add",
|
||||
"--if-not-exists",
|
||||
&flatpak_installation,
|
||||
&flatpak_remote_add_name_entry.text(),
|
||||
&flatpak_remote_add_url_entry.text()
|
||||
)
|
||||
.run()
|
||||
{
|
||||
Ok(_) => {
|
||||
reload_action_clone0.activate(None);
|
||||
flatpak_retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
Err(e) => {
|
||||
let flatpak_remote_add_error_dialog = adw::MessageDialog::builder()
|
||||
.heading(t!("flatpak_remote_add_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
flatpak_remote_add_error_dialog.add_response(
|
||||
"flatpak_remote_add_error_dialog_ok",
|
||||
&t!("flatpak_remote_add_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
flatpak_remote_add_error_dialog.present();
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
fn get_data_from_url(url: &str) -> Result<libflatpak::glib::Bytes, reqwest::Error> {
|
||||
let data = reqwest::blocking::get(url)?
|
||||
.text()
|
||||
.unwrap();
|
||||
|
||||
|
||||
let bytes = data.as_bytes();
|
||||
|
||||
let glib_bytes = libflatpak::glib::Bytes::from(bytes);
|
||||
Ok(glib_bytes)
|
||||
}*/
|
||||
}*/
|
||||
|
@ -1,318 +1,332 @@
|
||||
use crate::apt_package_row::AptPackageRow;
|
||||
use adw::gio::SimpleAction;
|
||||
use adw::prelude::*;
|
||||
use apt_deb822_tools::Deb822Repository;
|
||||
use libflatpak::builders::RemoteRefBuilder;
|
||||
use regex::{bytes, Regex};
|
||||
use gtk::glib::{property::PropertyGet, clone, BoxedAnyObject, MainContext};
|
||||
use configparser::ini::Ini;
|
||||
use gtk::glib::{clone, MainContext};
|
||||
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 libflatpak::prelude::*;
|
||||
use pretty_bytes::converter::convert;
|
||||
use std::cell::RefCell;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Write;
|
||||
use std::ops::Deref;
|
||||
use std::process::Command;
|
||||
use std::rc::Rc;
|
||||
use std::thread;
|
||||
use tokio::runtime::Runtime;
|
||||
use libflatpak::prelude::*;
|
||||
use std::io::Write;
|
||||
use libflatpak::InstalledRef;
|
||||
use std::fs::OpenOptions;
|
||||
use pretty_bytes::converter::convert;
|
||||
use configparser::ini::Ini;
|
||||
|
||||
|
||||
pub fn install_ref_dialog_fn(
|
||||
window: adw::ApplicationWindow,
|
||||
reload_action: &gio::SimpleAction,
|
||||
flatpak_retry_signal_action: &SimpleAction,
|
||||
flatpak_ref_entry_action: &SimpleAction,
|
||||
)
|
||||
{
|
||||
let flatpak_ref_install_dialog_child_box = Box::builder()
|
||||
.hexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
window: adw::ApplicationWindow,
|
||||
reload_action: &gio::SimpleAction,
|
||||
flatpak_retry_signal_action: &SimpleAction,
|
||||
flatpak_ref_entry_action: &SimpleAction,
|
||||
) {
|
||||
let flatpak_ref_install_dialog_child_box = Box::builder()
|
||||
.hexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let flatpak_ref_install_flatref_path_file_dialog_filter = FileFilter::new();
|
||||
flatpak_ref_install_flatref_path_file_dialog_filter.add_pattern("*.flatpakref");
|
||||
let flatpak_ref_install_flatref_path_file_dialog_filter = FileFilter::new();
|
||||
flatpak_ref_install_flatref_path_file_dialog_filter.add_pattern("*.flatpakref");
|
||||
|
||||
#[allow(deprecated)]
|
||||
let flatpak_ref_install_flatref_path_file_dialog = gtk::FileChooserNative::builder()
|
||||
.title(t!("flatpak_ref_install_flatref_path_file_dialog_title"))
|
||||
.accept_label(t!("flatpak_ref_install_flatref_path_file_dialog_accept_label"))
|
||||
.cancel_label(t!("flatpak_ref_install_flatref_path_file_dialog_cancel_label"))
|
||||
.action(gtk::FileChooserAction::Open)
|
||||
.filter(&flatpak_ref_install_flatref_path_file_dialog_filter)
|
||||
.build();
|
||||
#[allow(deprecated)]
|
||||
let flatpak_ref_install_flatref_path_file_dialog = gtk::FileChooserNative::builder()
|
||||
.title(t!("flatpak_ref_install_flatref_path_file_dialog_title"))
|
||||
.accept_label(t!(
|
||||
"flatpak_ref_install_flatref_path_file_dialog_accept_label"
|
||||
))
|
||||
.cancel_label(t!(
|
||||
"flatpak_ref_install_flatref_path_file_dialog_cancel_label"
|
||||
))
|
||||
.action(gtk::FileChooserAction::Open)
|
||||
.filter(&flatpak_ref_install_flatref_path_file_dialog_filter)
|
||||
.build();
|
||||
|
||||
let flatpak_ref_install_flatref_path_entry = gtk::Entry::builder()
|
||||
.placeholder_text("/home/andy/Downloads/com.visualstudio.code.flatpakref")
|
||||
.hexpand(true)
|
||||
.build();
|
||||
let flatpak_ref_install_flatref_path_entry = gtk::Entry::builder()
|
||||
.placeholder_text("/home/andy/Downloads/com.visualstudio.code.flatpakref")
|
||||
.hexpand(true)
|
||||
.build();
|
||||
|
||||
flatpak_ref_entry_action.connect_activate(clone!(
|
||||
#[strong]
|
||||
flatpak_ref_install_flatref_path_entry,
|
||||
move |_ , param|
|
||||
{
|
||||
flatpak_ref_install_flatref_path_entry.set_text(¶m.unwrap().get::<String>().unwrap());
|
||||
flatpak_ref_entry_action.connect_activate(clone!(
|
||||
#[strong]
|
||||
flatpak_ref_install_flatref_path_entry,
|
||||
move |_, param| {
|
||||
flatpak_ref_install_flatref_path_entry
|
||||
.set_text(¶m.unwrap().get::<String>().unwrap());
|
||||
}
|
||||
));
|
||||
|
||||
let flatpak_ref_install_flatref_path_entry_open_file_dialog = gtk::Button::builder()
|
||||
.tooltip_text(t!(
|
||||
"flatpak_ref_install_flatref_path_entry_open_file_dialog_text"
|
||||
))
|
||||
.halign(gtk::Align::End)
|
||||
.icon_name("document-open-symbolic")
|
||||
.build();
|
||||
|
||||
let flatpak_ref_install_flatref_path_entry_box = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.build();
|
||||
flatpak_ref_install_flatref_path_entry_box.add_css_class("linked");
|
||||
|
||||
flatpak_ref_install_flatref_path_entry_open_file_dialog.connect_clicked(clone!(
|
||||
#[strong]
|
||||
flatpak_ref_install_flatref_path_file_dialog,
|
||||
move |_| {
|
||||
flatpak_ref_install_flatref_path_file_dialog.set_visible(true);
|
||||
}
|
||||
));
|
||||
|
||||
flatpak_ref_install_flatref_path_entry_box.append(&flatpak_ref_install_flatref_path_entry);
|
||||
flatpak_ref_install_flatref_path_entry_box
|
||||
.append(&flatpak_ref_install_flatref_path_entry_open_file_dialog);
|
||||
|
||||
let flatpak_ref_install_flatref_path_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("flatpak_ref_install_flatref_path_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
#[allow(deprecated)]
|
||||
flatpak_ref_install_flatref_path_file_dialog.connect_response(clone!(
|
||||
#[weak]
|
||||
flatpak_ref_install_flatref_path_entry,
|
||||
move |dialog, response| {
|
||||
if response == gtk::ResponseType::Accept {
|
||||
match dialog.file() {
|
||||
Some(f) => match f.path() {
|
||||
Some(p) => {
|
||||
flatpak_ref_install_flatref_path_entry.set_text(p.to_str().unwrap())
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
let flatpak_ref_install_flatref_path_entry_open_file_dialog = gtk::Button::builder()
|
||||
.tooltip_text(t!("flatpak_ref_install_flatref_path_entry_open_file_dialog_text"))
|
||||
.halign(gtk::Align::End)
|
||||
.icon_name("document-open-symbolic")
|
||||
.build();
|
||||
|
||||
let flatpak_ref_install_flatref_path_entry_box = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.build();
|
||||
flatpak_ref_install_flatref_path_entry_box.add_css_class("linked");
|
||||
|
||||
flatpak_ref_install_flatref_path_entry_open_file_dialog.connect_clicked(clone!(
|
||||
#[strong]
|
||||
flatpak_ref_install_flatref_path_file_dialog,
|
||||
move |_| {
|
||||
flatpak_ref_install_flatref_path_file_dialog.set_visible(true);
|
||||
}
|
||||
));
|
||||
|
||||
flatpak_ref_install_flatref_path_entry_box.append(&flatpak_ref_install_flatref_path_entry);
|
||||
flatpak_ref_install_flatref_path_entry_box.append(&flatpak_ref_install_flatref_path_entry_open_file_dialog);
|
||||
|
||||
let flatpak_ref_install_flatref_path_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("flatpak_ref_install_flatref_path_prefrencesgroup_title"))
|
||||
.build();
|
||||
|
||||
#[allow(deprecated)]
|
||||
flatpak_ref_install_flatref_path_file_dialog.connect_response(
|
||||
clone!(
|
||||
#[weak]
|
||||
flatpak_ref_install_flatref_path_entry,
|
||||
move |dialog, response|
|
||||
{
|
||||
if response == gtk::ResponseType::Accept {
|
||||
match dialog.file() {
|
||||
Some(f) => {
|
||||
match f.path() {
|
||||
Some(p) => flatpak_ref_install_flatref_path_entry.set_text(p.to_str().unwrap()),
|
||||
None => {}
|
||||
}
|
||||
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
flatpak_ref_install_flatref_path_prefrencesgroup.add(&flatpak_ref_install_flatref_path_entry_box);
|
||||
|
||||
let flatpak_ref_install_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
.orientation(Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.spacing(5)
|
||||
.build();
|
||||
|
||||
let flatpak_ref_install_label0 = gtk::Label::builder()
|
||||
.margin_top(10)
|
||||
.margin_bottom(10)
|
||||
.build();
|
||||
|
||||
let flatpak_remote_user_togglebutton = gtk::ToggleButton::builder()
|
||||
.valign(Align::Center)
|
||||
.hexpand(true)
|
||||
.label(t!("flatpak_remotes_columnview_user"))
|
||||
.active(true)
|
||||
.build();
|
||||
|
||||
let flatpak_remote_system_togglebutton = gtk::ToggleButton::builder()
|
||||
.valign(Align::Center)
|
||||
.hexpand(true)
|
||||
.label(t!("flatpak_remotes_columnview_system"))
|
||||
.group(&flatpak_remote_user_togglebutton)
|
||||
.build();
|
||||
|
||||
//
|
||||
let flatpak_ref_install_dialog_child_clamp = adw::Clamp::builder()
|
||||
.child(&flatpak_ref_install_dialog_child_box)
|
||||
.maximum_size(500)
|
||||
.build();
|
||||
|
||||
let flatpak_ref_install_viewport = gtk::ScrolledWindow::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.child(&flatpak_ref_install_dialog_child_clamp)
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.build();
|
||||
|
||||
let flatpak_ref_install_dialog = adw::MessageDialog::builder()
|
||||
.transient_for(&window)
|
||||
.extra_child(&flatpak_ref_install_viewport)
|
||||
.heading(t!("flatpak_ref_install_dialog_heading"))
|
||||
.width_request(700)
|
||||
.height_request(400)
|
||||
.build();
|
||||
|
||||
flatpak_ref_install_flatref_path_file_dialog.set_transient_for(Some(&flatpak_ref_install_dialog));
|
||||
|
||||
flatpak_ref_install_dialog.add_response(
|
||||
"flatpak_ref_install_dialog_add",
|
||||
&t!("flatpak_ref_install_dialog_add_label").to_string(),
|
||||
);
|
||||
|
||||
flatpak_ref_install_dialog.add_response(
|
||||
"flatpak_ref_install_dialog_cancel",
|
||||
&t!("flatpak_ref_install_dialog_cancel_label").to_string(),
|
||||
);
|
||||
|
||||
flatpak_ref_install_dialog.set_response_enabled("flatpak_ref_install_dialog_add", false);
|
||||
|
||||
flatpak_ref_install_dialog.set_response_appearance(
|
||||
"flatpak_ref_install_dialog_cancel",
|
||||
adw::ResponseAppearance::Destructive,
|
||||
);
|
||||
|
||||
flatpak_ref_install_dialog.set_response_appearance(
|
||||
"flatpak_ref_install_dialog_add",
|
||||
adw::ResponseAppearance::Suggested,
|
||||
);
|
||||
|
||||
//
|
||||
|
||||
let flatpak_ref_install_dialog_clone0 = flatpak_ref_install_dialog.clone();
|
||||
let flatpak_ref_install_flatref_path_entry_clone0 = flatpak_ref_install_flatref_path_entry.clone();
|
||||
let flatpak_ref_install_label0_clone0 = flatpak_ref_install_label0.clone();
|
||||
|
||||
let tbi_remote_name = Rc::new(RefCell::new(None));
|
||||
let tbi_remote_url = Rc::new(RefCell::new(None));
|
||||
|
||||
let tbi_remote_name_clone0 = tbi_remote_name.clone();
|
||||
let tbi_remote_url_clone0 = tbi_remote_url.clone();
|
||||
|
||||
let add_button_update_state = move || {
|
||||
if
|
||||
!flatpak_ref_install_flatref_path_entry_clone0.text().is_empty()
|
||||
{
|
||||
match std::fs::read_to_string(flatpak_ref_install_flatref_path_entry_clone0.text()) {
|
||||
Ok(t) => {
|
||||
let mut flatref_file = Ini::new();
|
||||
match flatref_file.read(t) {
|
||||
Ok(_) => {
|
||||
let ref_name = flatref_file.get("Flatpak Ref", "Name");
|
||||
let ref_remote_name = flatref_file.get("Flatpak Ref", "SuggestRemoteName");
|
||||
let ref_remote_url = flatref_file.get("Flatpak Ref", "RuntimeRepo");
|
||||
match (ref_name, ref_remote_name.clone()) {
|
||||
(Some(name), Some(remote_name)) => {
|
||||
flatpak_ref_install_label0_clone0.set_label(&strfmt::strfmt(
|
||||
&t!("flatpak_ref_install_label").to_string(),
|
||||
&std::collections::HashMap::from([
|
||||
(
|
||||
"NAME".to_string(),
|
||||
name,
|
||||
),
|
||||
(
|
||||
"REMOTE".to_string(),
|
||||
remote_name,
|
||||
),
|
||||
]),
|
||||
)
|
||||
.unwrap());
|
||||
{
|
||||
*tbi_remote_name_clone0.borrow_mut() = ref_remote_name;
|
||||
*tbi_remote_url_clone0.borrow_mut() = ref_remote_url;
|
||||
}
|
||||
}
|
||||
(_, _) => {
|
||||
flatpak_ref_install_dialog_clone0.set_response_enabled("flatpak_ref_install_dialog_add", false);
|
||||
flatpak_ref_install_label0_clone0.set_label("");
|
||||
}
|
||||
}
|
||||
flatpak_ref_install_dialog_clone0.set_response_enabled("flatpak_ref_install_dialog_add", true);
|
||||
}
|
||||
Err(_) => {
|
||||
flatpak_ref_install_dialog_clone0.set_response_enabled("flatpak_ref_install_dialog_add", false);
|
||||
flatpak_ref_install_label0_clone0.set_label("");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
flatpak_ref_install_dialog_clone0.set_response_enabled("flatpak_ref_install_dialog_add", false);
|
||||
flatpak_ref_install_label0_clone0.set_label("");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
flatpak_ref_install_dialog_clone0.set_response_enabled("flatpak_ref_install_dialog_add", false);
|
||||
flatpak_ref_install_label0_clone0.set_label("");
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
for entry in [
|
||||
&flatpak_ref_install_flatref_path_entry,
|
||||
] {
|
||||
entry.connect_text_notify(clone!(
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |_|
|
||||
{
|
||||
add_button_update_state();
|
||||
}
|
||||
)
|
||||
);
|
||||
None => {}
|
||||
},
|
||||
None => {}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
flatpak_ref_install_box2.append(&flatpak_remote_user_togglebutton);
|
||||
flatpak_ref_install_box2.append(&flatpak_remote_system_togglebutton);
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
flatpak_ref_install_dialog_child_box.append(&flatpak_ref_install_flatref_path_prefrencesgroup);
|
||||
flatpak_ref_install_dialog_child_box.append(&flatpak_ref_install_box2);
|
||||
flatpak_ref_install_dialog_child_box.append(&flatpak_ref_install_label0);
|
||||
flatpak_ref_install_flatref_path_prefrencesgroup
|
||||
.add(&flatpak_ref_install_flatref_path_entry_box);
|
||||
|
||||
let reload_action_clone0 = reload_action.clone();
|
||||
let flatpak_retry_signal_action_clone0 = flatpak_retry_signal_action.clone();
|
||||
let flatpak_ref_install_flatref_path_entry_clone0 = flatpak_ref_install_flatref_path_entry.clone();
|
||||
let tbi_remote_name_clone0 = tbi_remote_name.clone();
|
||||
let tbi_remote_url_clone0 = tbi_remote_url.clone();
|
||||
let flatpak_ref_install_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
.orientation(Orientation::Horizontal)
|
||||
.hexpand(true)
|
||||
.spacing(5)
|
||||
.build();
|
||||
|
||||
flatpak_ref_install_dialog.clone()
|
||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||
match choice.as_str() {
|
||||
"flatpak_ref_install_dialog_add" => {
|
||||
match (tbi_remote_name_clone0.borrow().deref(), tbi_remote_url_clone0.borrow().deref()) {
|
||||
(Some(remote_name), Some(remote_url)) => {
|
||||
add_flatpakref_remote(&reload_action_clone0, &remote_name, &remote_url, flatpak_remote_system_togglebutton.is_active());
|
||||
let flatpak_ref_install_label0 = gtk::Label::builder()
|
||||
.margin_top(10)
|
||||
.margin_bottom(10)
|
||||
.build();
|
||||
|
||||
let flatpak_remote_user_togglebutton = gtk::ToggleButton::builder()
|
||||
.valign(Align::Center)
|
||||
.hexpand(true)
|
||||
.label(t!("flatpak_remotes_columnview_user"))
|
||||
.active(true)
|
||||
.build();
|
||||
|
||||
let flatpak_remote_system_togglebutton = gtk::ToggleButton::builder()
|
||||
.valign(Align::Center)
|
||||
.hexpand(true)
|
||||
.label(t!("flatpak_remotes_columnview_system"))
|
||||
.group(&flatpak_remote_user_togglebutton)
|
||||
.build();
|
||||
|
||||
//
|
||||
let flatpak_ref_install_dialog_child_clamp = adw::Clamp::builder()
|
||||
.child(&flatpak_ref_install_dialog_child_box)
|
||||
.maximum_size(500)
|
||||
.build();
|
||||
|
||||
let flatpak_ref_install_viewport = gtk::ScrolledWindow::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.child(&flatpak_ref_install_dialog_child_clamp)
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.build();
|
||||
|
||||
let flatpak_ref_install_dialog = adw::MessageDialog::builder()
|
||||
.transient_for(&window)
|
||||
.extra_child(&flatpak_ref_install_viewport)
|
||||
.heading(t!("flatpak_ref_install_dialog_heading"))
|
||||
.width_request(700)
|
||||
.height_request(400)
|
||||
.build();
|
||||
|
||||
flatpak_ref_install_flatref_path_file_dialog
|
||||
.set_transient_for(Some(&flatpak_ref_install_dialog));
|
||||
|
||||
flatpak_ref_install_dialog.add_response(
|
||||
"flatpak_ref_install_dialog_add",
|
||||
&t!("flatpak_ref_install_dialog_add_label").to_string(),
|
||||
);
|
||||
|
||||
flatpak_ref_install_dialog.add_response(
|
||||
"flatpak_ref_install_dialog_cancel",
|
||||
&t!("flatpak_ref_install_dialog_cancel_label").to_string(),
|
||||
);
|
||||
|
||||
flatpak_ref_install_dialog.set_response_enabled("flatpak_ref_install_dialog_add", false);
|
||||
|
||||
flatpak_ref_install_dialog.set_response_appearance(
|
||||
"flatpak_ref_install_dialog_cancel",
|
||||
adw::ResponseAppearance::Destructive,
|
||||
);
|
||||
|
||||
flatpak_ref_install_dialog.set_response_appearance(
|
||||
"flatpak_ref_install_dialog_add",
|
||||
adw::ResponseAppearance::Suggested,
|
||||
);
|
||||
|
||||
//
|
||||
|
||||
let flatpak_ref_install_dialog_clone0 = flatpak_ref_install_dialog.clone();
|
||||
let flatpak_ref_install_flatref_path_entry_clone0 =
|
||||
flatpak_ref_install_flatref_path_entry.clone();
|
||||
let flatpak_ref_install_label0_clone0 = flatpak_ref_install_label0.clone();
|
||||
|
||||
let tbi_remote_name = Rc::new(RefCell::new(None));
|
||||
let tbi_remote_url = Rc::new(RefCell::new(None));
|
||||
|
||||
let tbi_remote_name_clone0 = tbi_remote_name.clone();
|
||||
let tbi_remote_url_clone0 = tbi_remote_url.clone();
|
||||
|
||||
let add_button_update_state = move || {
|
||||
if !flatpak_ref_install_flatref_path_entry_clone0
|
||||
.text()
|
||||
.is_empty()
|
||||
{
|
||||
match std::fs::read_to_string(flatpak_ref_install_flatref_path_entry_clone0.text()) {
|
||||
Ok(t) => {
|
||||
let mut flatref_file = Ini::new();
|
||||
match flatref_file.read(t) {
|
||||
Ok(_) => {
|
||||
let ref_name = flatref_file.get("Flatpak Ref", "Name");
|
||||
let ref_remote_name =
|
||||
flatref_file.get("Flatpak Ref", "SuggestRemoteName");
|
||||
let ref_remote_url = flatref_file.get("Flatpak Ref", "RuntimeRepo");
|
||||
match (ref_name, ref_remote_name.clone()) {
|
||||
(Some(name), Some(remote_name)) => {
|
||||
flatpak_ref_install_label0_clone0.set_label(
|
||||
&strfmt::strfmt(
|
||||
&t!("flatpak_ref_install_label").to_string(),
|
||||
&std::collections::HashMap::from([
|
||||
("NAME".to_string(), name),
|
||||
("REMOTE".to_string(), remote_name),
|
||||
]),
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
{
|
||||
*tbi_remote_name_clone0.borrow_mut() = ref_remote_name;
|
||||
*tbi_remote_url_clone0.borrow_mut() = ref_remote_url;
|
||||
}
|
||||
(_,_) => {}
|
||||
}
|
||||
run_flatpak_ref_install_transaction(&flatpak_retry_signal_action_clone0, &reload_action_clone0, flatpak_remote_system_togglebutton.is_active(), window, &flatpak_ref_install_flatref_path_entry_clone0.text());
|
||||
(_, _) => {
|
||||
flatpak_ref_install_dialog_clone0.set_response_enabled(
|
||||
"flatpak_ref_install_dialog_add",
|
||||
false,
|
||||
);
|
||||
flatpak_ref_install_label0_clone0.set_label("");
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
flatpak_ref_install_dialog_clone0
|
||||
.set_response_enabled("flatpak_ref_install_dialog_add", true);
|
||||
}
|
||||
});
|
||||
Err(_) => {
|
||||
flatpak_ref_install_dialog_clone0
|
||||
.set_response_enabled("flatpak_ref_install_dialog_add", false);
|
||||
flatpak_ref_install_label0_clone0.set_label("");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
flatpak_ref_install_dialog_clone0
|
||||
.set_response_enabled("flatpak_ref_install_dialog_add", false);
|
||||
flatpak_ref_install_label0_clone0.set_label("");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
flatpak_ref_install_dialog_clone0
|
||||
.set_response_enabled("flatpak_ref_install_dialog_add", false);
|
||||
flatpak_ref_install_label0_clone0.set_label("");
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
for entry in [&flatpak_ref_install_flatref_path_entry] {
|
||||
entry.connect_text_notify(clone!(
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |_| {
|
||||
add_button_update_state();
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
flatpak_ref_install_box2.append(&flatpak_remote_user_togglebutton);
|
||||
flatpak_ref_install_box2.append(&flatpak_remote_system_togglebutton);
|
||||
|
||||
flatpak_ref_install_dialog_child_box.append(&flatpak_ref_install_flatref_path_prefrencesgroup);
|
||||
flatpak_ref_install_dialog_child_box.append(&flatpak_ref_install_box2);
|
||||
flatpak_ref_install_dialog_child_box.append(&flatpak_ref_install_label0);
|
||||
|
||||
let reload_action_clone0 = reload_action.clone();
|
||||
let flatpak_retry_signal_action_clone0 = flatpak_retry_signal_action.clone();
|
||||
let flatpak_ref_install_flatref_path_entry_clone0 =
|
||||
flatpak_ref_install_flatref_path_entry.clone();
|
||||
let tbi_remote_name_clone0 = tbi_remote_name.clone();
|
||||
let tbi_remote_url_clone0 = tbi_remote_url.clone();
|
||||
|
||||
flatpak_ref_install_dialog.clone().choose(
|
||||
None::<&gio::Cancellable>,
|
||||
move |choice| match choice.as_str() {
|
||||
"flatpak_ref_install_dialog_add" => {
|
||||
match (
|
||||
tbi_remote_name_clone0.borrow().deref(),
|
||||
tbi_remote_url_clone0.borrow().deref(),
|
||||
) {
|
||||
(Some(remote_name), Some(remote_url)) => {
|
||||
add_flatpakref_remote(
|
||||
&reload_action_clone0,
|
||||
&remote_name,
|
||||
&remote_url,
|
||||
flatpak_remote_system_togglebutton.is_active(),
|
||||
);
|
||||
}
|
||||
(_, _) => {}
|
||||
}
|
||||
run_flatpak_ref_install_transaction(
|
||||
&flatpak_retry_signal_action_clone0,
|
||||
&reload_action_clone0,
|
||||
flatpak_remote_system_togglebutton.is_active(),
|
||||
window,
|
||||
&flatpak_ref_install_flatref_path_entry_clone0.text(),
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
pub fn run_flatpak_ref_install_transaction(flatpak_retry_signal_action: &gio::SimpleAction, retry_signal_action: &gio::SimpleAction, is_system: bool, window: adw::ApplicationWindow, flatref_path: &str) {
|
||||
pub fn run_flatpak_ref_install_transaction(
|
||||
flatpak_retry_signal_action: &gio::SimpleAction,
|
||||
retry_signal_action: &gio::SimpleAction,
|
||||
is_system: bool,
|
||||
window: adw::ApplicationWindow,
|
||||
flatref_path: &str,
|
||||
) {
|
||||
let (transaction_percent_sender, transaction_percent_receiver) =
|
||||
async_channel::unbounded::<u32>();
|
||||
async_channel::unbounded::<u32>();
|
||||
let transaction_percent_sender = transaction_percent_sender.clone();
|
||||
let (transaction_status_sender, transaction_status_receiver) =
|
||||
async_channel::unbounded::<String>();
|
||||
let transaction_status_sender = transaction_status_sender.clone();
|
||||
|
||||
let flatref_path_clone0 = flatref_path.clone().to_owned();
|
||||
let flatref_path_clone0 = flatref_path.to_owned();
|
||||
|
||||
thread::spawn(move || {
|
||||
let cancellable_no = libflatpak::gio::Cancellable::NONE;
|
||||
@ -321,30 +335,63 @@ pub fn run_flatpak_ref_install_transaction(flatpak_retry_signal_action: &gio::Si
|
||||
let transaction_percent_sender0 = transaction_percent_sender.clone();
|
||||
|
||||
let transaction_run_closure =
|
||||
move |transaction: &libflatpak::Transaction,
|
||||
transaction_operation: &libflatpak::TransactionOperation,
|
||||
transaction_progress: &libflatpak::TransactionProgress| {
|
||||
move |_: &libflatpak::Transaction,
|
||||
transaction_operation: &libflatpak::TransactionOperation,
|
||||
transaction_progress: &libflatpak::TransactionProgress| {
|
||||
let transaction_status_sender = transaction_status_sender0.clone();
|
||||
let transaction_percent_sender = transaction_percent_sender0.clone();
|
||||
transaction_progress.connect_changed(clone!(@strong transaction_progress, @strong transaction_operation => move |_| {
|
||||
let status_message = format!("{}: {}\n{}: {}\n{}: {}/{}\n{}: {}", t!("flatpak_ref"), transaction_operation.get_ref().unwrap_or(libflatpak::glib::GString::from_string_unchecked("Unknown".to_owned())), t!("flatpak_status") ,transaction_progress.status().unwrap_or(libflatpak::glib::GString::from_string_unchecked("Unknown".to_owned())), t!("flatpak_transaction_bytes_transferred"), convert(transaction_progress.bytes_transferred() as f64), convert(transaction_operation.download_size() as f64), t!("flatpak_transaction_installed_size"), convert(transaction_operation.installed_size() as f64));
|
||||
transaction_status_sender.send_blocking(status_message).expect("transaction_status_receiver closed!");
|
||||
transaction_percent_sender.send_blocking(transaction_progress.progress().try_into().unwrap_or(0)).expect("transaction_percent_receiver closed!");
|
||||
}));
|
||||
transaction_progress.connect_changed(clone!(
|
||||
#[strong]
|
||||
transaction_progress,
|
||||
#[strong]
|
||||
transaction_operation,
|
||||
move |_| {
|
||||
let status_message = format!(
|
||||
"{}: {}\n{}: {}\n{}: {}/{}\n{}: {}",
|
||||
t!("flatpak_ref"),
|
||||
transaction_operation.get_ref().unwrap_or(
|
||||
libflatpak::glib::GString::from_string_unchecked(
|
||||
"Unknown".to_owned()
|
||||
)
|
||||
),
|
||||
t!("flatpak_status"),
|
||||
transaction_progress.status().unwrap_or(
|
||||
libflatpak::glib::GString::from_string_unchecked(
|
||||
"Unknown".to_owned()
|
||||
)
|
||||
),
|
||||
t!("flatpak_transaction_bytes_transferred"),
|
||||
convert(transaction_progress.bytes_transferred() as f64),
|
||||
convert(transaction_operation.download_size() as f64),
|
||||
t!("flatpak_transaction_installed_size"),
|
||||
convert(transaction_operation.installed_size() as f64)
|
||||
);
|
||||
transaction_status_sender
|
||||
.send_blocking(status_message)
|
||||
.expect("transaction_status_receiver closed!");
|
||||
transaction_percent_sender
|
||||
.send_blocking(transaction_progress.progress().try_into().unwrap_or(0))
|
||||
.expect("transaction_percent_receiver closed!");
|
||||
}
|
||||
));
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
let (flatpak_installation, flatpak_transaction) = match is_system {
|
||||
let flatpak_transaction = match is_system {
|
||||
true => {
|
||||
let installation = libflatpak::Installation::new_system(cancellable_no).unwrap();
|
||||
let transaction = libflatpak::Transaction::for_installation(&installation, cancellable_no).unwrap();
|
||||
(installation, transaction)
|
||||
let installation = libflatpak::Installation::new_system(cancellable_no).unwrap();
|
||||
let transaction =
|
||||
libflatpak::Transaction::for_installation(&installation, cancellable_no)
|
||||
.unwrap();
|
||||
transaction
|
||||
}
|
||||
false => {
|
||||
let installation = libflatpak::Installation::new_user(cancellable_no).unwrap();
|
||||
let transaction = libflatpak::Transaction::for_installation(&installation, cancellable_no).unwrap();
|
||||
(installation, transaction)
|
||||
let transaction =
|
||||
libflatpak::Transaction::for_installation(&installation, cancellable_no)
|
||||
.unwrap();
|
||||
transaction
|
||||
}
|
||||
};
|
||||
|
||||
@ -366,7 +413,7 @@ pub fn run_flatpak_ref_install_transaction(flatpak_retry_signal_action: &gio::Si
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
|
||||
match flatpak_transaction.run(cancellable_no) {
|
||||
Ok(_) => {
|
||||
transaction_status_sender
|
||||
@ -419,13 +466,12 @@ pub fn run_flatpak_ref_install_transaction(flatpak_retry_signal_action: &gio::Si
|
||||
flatpak_transaction_dialog_child_box.append(&flatpak_transaction_dialog_spinner);
|
||||
flatpak_transaction_dialog_child_box.append(&flatpak_transaction_dialog_progress_bar);
|
||||
|
||||
let flatpak_transaction_dialog =
|
||||
adw::MessageDialog::builder()
|
||||
.transient_for(&window)
|
||||
.extra_child(&flatpak_transaction_dialog_child_box)
|
||||
.heading(t!("flatpak_transaction_dialog_heading"))
|
||||
.width_request(500)
|
||||
.build();
|
||||
let flatpak_transaction_dialog = adw::MessageDialog::builder()
|
||||
.transient_for(&window)
|
||||
.extra_child(&flatpak_transaction_dialog_child_box)
|
||||
.heading(t!("flatpak_transaction_dialog_heading"))
|
||||
.width_request(500)
|
||||
.build();
|
||||
|
||||
flatpak_transaction_dialog.add_response(
|
||||
"flatpak_transaction_dialog_ok",
|
||||
@ -549,20 +595,34 @@ pub fn run_flatpak_ref_install_transaction(flatpak_retry_signal_action: &gio::Si
|
||||
|
||||
fn get_data_from_filepath(filepath: &str) -> Result<libflatpak::glib::Bytes, std::io::Error> {
|
||||
let data = std::fs::read_to_string(filepath)?;
|
||||
|
||||
|
||||
let bytes = data.as_bytes();
|
||||
|
||||
let glib_bytes = libflatpak::glib::Bytes::from(bytes);
|
||||
Ok(glib_bytes)
|
||||
}
|
||||
|
||||
fn add_flatpakref_remote(reload_action: &gio::SimpleAction, remote_name: &str, remote_url: &str, is_system: bool) {
|
||||
fn add_flatpakref_remote(
|
||||
reload_action: &gio::SimpleAction,
|
||||
remote_name: &str,
|
||||
remote_url: &str,
|
||||
is_system: bool,
|
||||
) {
|
||||
let flatpak_installation = match is_system {
|
||||
true => "--system",
|
||||
false => "--user"
|
||||
};
|
||||
false => "--user",
|
||||
};
|
||||
|
||||
match duct::cmd!("flatpak", "remote-add", "--if-not-exists", &flatpak_installation, remote_name, remote_url).run() {
|
||||
match duct::cmd!(
|
||||
"flatpak",
|
||||
"remote-add",
|
||||
"--if-not-exists",
|
||||
&flatpak_installation,
|
||||
remote_name,
|
||||
remote_url
|
||||
)
|
||||
.run()
|
||||
{
|
||||
Ok(_) => {
|
||||
reload_action.activate(None);
|
||||
}
|
||||
@ -574,8 +634,8 @@ fn add_flatpakref_remote(reload_action: &gio::SimpleAction, remote_name: &str, r
|
||||
flatpak_remote_add_error_dialog.add_response(
|
||||
"flatpak_remote_add_error_dialog_ok",
|
||||
&t!("flatpak_remote_add_error_dialog_ok_label").to_string(),
|
||||
);
|
||||
);
|
||||
flatpak_remote_add_error_dialog.present();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +1,19 @@
|
||||
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 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 crate::flatpak_ref_row::FlatpakRefRow;
|
||||
use adw::prelude::*;
|
||||
use gtk::glib::*;
|
||||
use gtk::glib::{clone, BoxedAnyObject};
|
||||
use gtk::*;
|
||||
use libflatpak::prelude::*;
|
||||
use libflatpak::InstalledRef;
|
||||
use std::cell::Ref;
|
||||
use std::cell::RefCell;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
|
||||
mod add_dialog;
|
||||
mod install_ref_dialog;
|
||||
|
||||
enum FlatpakRemote {
|
||||
System(libflatpak::Remote),
|
||||
User(libflatpak::Remote)
|
||||
User(libflatpak::Remote),
|
||||
}
|
||||
|
||||
pub fn flatpak_manage_page(
|
||||
@ -69,194 +54,185 @@ pub fn flatpak_manage_page(
|
||||
.margin_end(15)
|
||||
.build();
|
||||
|
||||
let flatpak_remotes_selection_model_rc: Rc<RefCell<gtk::SingleSelection>> = Rc::new(RefCell::default());
|
||||
let flatpak_remotes_selection_model_rc: Rc<RefCell<gtk::SingleSelection>> =
|
||||
Rc::new(RefCell::default());
|
||||
|
||||
let flatpak_remotes_selection_model_rc_clone0 = Rc::clone(&flatpak_remotes_selection_model_rc);
|
||||
|
||||
let flatpak_remotes_columnview_bin = adw::Bin::new();
|
||||
|
||||
let flatpak_remotes_columnview_bin_clone0 = flatpak_remotes_columnview_bin.clone();
|
||||
|
||||
|
||||
retry_signal_action.connect_activate(clone!(
|
||||
#[weak]
|
||||
flatpak_remotes_columnview_bin_clone0,
|
||||
#[strong]
|
||||
cancellable_no,
|
||||
move |_, _| {
|
||||
|
||||
let flatpak_system_installation =
|
||||
libflatpak::Installation::new_system(cancellable_no).unwrap();
|
||||
libflatpak::Installation::new_system(cancellable_no).unwrap();
|
||||
let flatpak_user_installation =
|
||||
libflatpak::Installation::new_user(cancellable_no).unwrap();
|
||||
|
||||
let system_remotes = match libflatpak::Installation::list_remotes(&flatpak_system_installation, cancellable_no) {
|
||||
libflatpak::Installation::new_user(cancellable_no).unwrap();
|
||||
|
||||
let system_remotes = match libflatpak::Installation::list_remotes(
|
||||
&flatpak_system_installation,
|
||||
cancellable_no,
|
||||
) {
|
||||
Ok(t) => t,
|
||||
Err(_) => Vec::new()
|
||||
Err(_) => Vec::new(),
|
||||
};
|
||||
|
||||
let user_remotes = match libflatpak::Installation::list_remotes(&flatpak_user_installation, cancellable_no) {
|
||||
|
||||
let user_remotes = match libflatpak::Installation::list_remotes(
|
||||
&flatpak_user_installation,
|
||||
cancellable_no,
|
||||
) {
|
||||
Ok(t) => t,
|
||||
Err(_) => Vec::new()
|
||||
Err(_) => Vec::new(),
|
||||
};
|
||||
|
||||
let flatpak_remotes_list_store = gio::ListStore::new::<BoxedAnyObject>();
|
||||
let flatpak_remotes_list_store = gio::ListStore::new::<BoxedAnyObject>();
|
||||
|
||||
for remote in system_remotes {
|
||||
flatpak_remotes_list_store.append(&BoxedAnyObject::new(FlatpakRemote::System(remote)));
|
||||
};
|
||||
for remote in system_remotes {
|
||||
flatpak_remotes_list_store
|
||||
.append(&BoxedAnyObject::new(FlatpakRemote::System(remote)));
|
||||
}
|
||||
|
||||
for remote in user_remotes {
|
||||
flatpak_remotes_list_store.append(&BoxedAnyObject::new(FlatpakRemote::User(remote)));
|
||||
};
|
||||
for remote in user_remotes {
|
||||
flatpak_remotes_list_store
|
||||
.append(&BoxedAnyObject::new(FlatpakRemote::User(remote)));
|
||||
}
|
||||
|
||||
let flatpak_remotes_selection_model = SingleSelection::new(Some(flatpak_remotes_list_store));
|
||||
let flatpak_remotes_selection_model =
|
||||
SingleSelection::new(Some(flatpak_remotes_list_store));
|
||||
|
||||
(*flatpak_remotes_selection_model_rc_clone0.borrow_mut() = flatpak_remotes_selection_model.clone());
|
||||
(*flatpak_remotes_selection_model_rc_clone0.borrow_mut() =
|
||||
flatpak_remotes_selection_model.clone());
|
||||
|
||||
let flatpak_remotes_columnview = ColumnView::builder()
|
||||
.vexpand(true)
|
||||
.model(&flatpak_remotes_selection_model)
|
||||
.build();
|
||||
|
||||
//
|
||||
|
||||
let flatpak_remotes_columnview_factory0 = gtk::SignalListItemFactory::new();
|
||||
|
||||
flatpak_remotes_columnview_factory0.connect_setup(move |_factory, item| {
|
||||
let item = item.downcast_ref::<gtk::ListItem>().unwrap();
|
||||
let row = Label::builder()
|
||||
.halign(Align::Start)
|
||||
let flatpak_remotes_columnview = ColumnView::builder()
|
||||
.vexpand(true)
|
||||
.model(&flatpak_remotes_selection_model)
|
||||
.build();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
|
||||
flatpak_remotes_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::<FlatpakRemote>();
|
||||
let remote_name = match entry_borrow.deref() {
|
||||
FlatpakRemote::System(remote) => {
|
||||
remote.name().unwrap_or_default()
|
||||
}
|
||||
FlatpakRemote::User(remote) => {
|
||||
remote.name().unwrap_or_default()
|
||||
}
|
||||
};
|
||||
child.set_label(&remote_name);
|
||||
});
|
||||
|
||||
let flatpak_remotes_columnview_col1 = gtk::ColumnViewColumn::builder()
|
||||
.title(t!("flatpak_remotes_columnview_col0_title"))
|
||||
.factory(&flatpak_remotes_columnview_factory0)
|
||||
.build();
|
||||
//
|
||||
|
||||
//
|
||||
let flatpak_remotes_columnview_factory0 = gtk::SignalListItemFactory::new();
|
||||
|
||||
let flatpak_remotes_columnview_factory1 = gtk::SignalListItemFactory::new();
|
||||
|
||||
flatpak_remotes_columnview_factory1.connect_setup(move |_factory, item| {
|
||||
let item = item.downcast_ref::<gtk::ListItem>().unwrap();
|
||||
let row = Label::builder()
|
||||
.halign(Align::Start)
|
||||
flatpak_remotes_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));
|
||||
});
|
||||
|
||||
flatpak_remotes_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::<FlatpakRemote>();
|
||||
let remote_name = match entry_borrow.deref() {
|
||||
FlatpakRemote::System(remote) => remote.name().unwrap_or_default(),
|
||||
FlatpakRemote::User(remote) => remote.name().unwrap_or_default(),
|
||||
};
|
||||
child.set_label(&remote_name);
|
||||
});
|
||||
|
||||
let flatpak_remotes_columnview_col1 = gtk::ColumnViewColumn::builder()
|
||||
.title(t!("flatpak_remotes_columnview_col0_title"))
|
||||
.factory(&flatpak_remotes_columnview_factory0)
|
||||
.build();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
|
||||
flatpak_remotes_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::<FlatpakRemote>();
|
||||
let remote_title = match entry_borrow.deref() {
|
||||
FlatpakRemote::System(remote) => {
|
||||
remote.title().unwrap_or_default()
|
||||
}
|
||||
FlatpakRemote::User(remote) => {
|
||||
remote.title().unwrap_or_default()
|
||||
}
|
||||
};
|
||||
child.set_label(&remote_title);
|
||||
});
|
||||
|
||||
let flatpak_remotes_columnview_col0 = gtk::ColumnViewColumn::builder()
|
||||
.title(t!("flatpak_remotes_columnview_col1_title"))
|
||||
.factory(&flatpak_remotes_columnview_factory1)
|
||||
.build();
|
||||
//
|
||||
|
||||
//
|
||||
let flatpak_remotes_columnview_factory1 = gtk::SignalListItemFactory::new();
|
||||
|
||||
let flatpak_remotes_columnview_factory2 = gtk::SignalListItemFactory::new();
|
||||
|
||||
flatpak_remotes_columnview_factory2.connect_setup(move |_factory, item| {
|
||||
let item = item.downcast_ref::<gtk::ListItem>().unwrap();
|
||||
let row = Label::builder()
|
||||
.halign(Align::Start)
|
||||
flatpak_remotes_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));
|
||||
});
|
||||
|
||||
flatpak_remotes_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::<FlatpakRemote>();
|
||||
let remote_title = match entry_borrow.deref() {
|
||||
FlatpakRemote::System(remote) => remote.title().unwrap_or_default(),
|
||||
FlatpakRemote::User(remote) => remote.title().unwrap_or_default(),
|
||||
};
|
||||
child.set_label(&remote_title);
|
||||
});
|
||||
|
||||
let flatpak_remotes_columnview_col0 = gtk::ColumnViewColumn::builder()
|
||||
.title(t!("flatpak_remotes_columnview_col1_title"))
|
||||
.factory(&flatpak_remotes_columnview_factory1)
|
||||
.build();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
|
||||
flatpak_remotes_columnview_factory2.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::<FlatpakRemote>();
|
||||
let remote_url = match entry_borrow.deref() {
|
||||
FlatpakRemote::System(remote) => {
|
||||
remote.url().unwrap_or_default()
|
||||
}
|
||||
FlatpakRemote::User(remote) => {
|
||||
remote.url().unwrap_or_default()
|
||||
}
|
||||
};
|
||||
child.set_label(&remote_url);
|
||||
});
|
||||
|
||||
let flatpak_remotes_columnview_col2 = gtk::ColumnViewColumn::builder()
|
||||
.title(t!("flatpak_remotes_columnview_col2_title"))
|
||||
.factory(&flatpak_remotes_columnview_factory2)
|
||||
.expand(true)
|
||||
.build();
|
||||
//
|
||||
|
||||
//
|
||||
let flatpak_remotes_columnview_factory2 = gtk::SignalListItemFactory::new();
|
||||
|
||||
let flatpak_remotes_columnview_factory3 = gtk::SignalListItemFactory::new();
|
||||
|
||||
flatpak_remotes_columnview_factory3.connect_setup(move |_factory, item| {
|
||||
let item = item.downcast_ref::<gtk::ListItem>().unwrap();
|
||||
let row = Label::builder()
|
||||
.halign(Align::Start)
|
||||
flatpak_remotes_columnview_factory2.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));
|
||||
});
|
||||
|
||||
flatpak_remotes_columnview_factory2.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::<FlatpakRemote>();
|
||||
let remote_url = match entry_borrow.deref() {
|
||||
FlatpakRemote::System(remote) => remote.url().unwrap_or_default(),
|
||||
FlatpakRemote::User(remote) => remote.url().unwrap_or_default(),
|
||||
};
|
||||
child.set_label(&remote_url);
|
||||
});
|
||||
|
||||
let flatpak_remotes_columnview_col2 = gtk::ColumnViewColumn::builder()
|
||||
.title(t!("flatpak_remotes_columnview_col2_title"))
|
||||
.factory(&flatpak_remotes_columnview_factory2)
|
||||
.expand(true)
|
||||
.build();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
|
||||
flatpak_remotes_columnview_factory3.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::<FlatpakRemote>();
|
||||
match entry_borrow.deref() {
|
||||
FlatpakRemote::System(remote) => {
|
||||
child.set_label(&t!("flatpak_remotes_columnview_system").to_string());
|
||||
}
|
||||
FlatpakRemote::User(remote) => {
|
||||
child.set_label(&t!("flatpak_remotes_columnview_user").to_string());
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
let flatpak_remotes_columnview_col3 = gtk::ColumnViewColumn::builder()
|
||||
.title(t!("flatpak_remotes_columnview_col3_title"))
|
||||
.factory(&flatpak_remotes_columnview_factory3)
|
||||
.build();
|
||||
//
|
||||
|
||||
//
|
||||
flatpak_remotes_columnview.append_column(&flatpak_remotes_columnview_col0);
|
||||
flatpak_remotes_columnview.append_column(&flatpak_remotes_columnview_col1);
|
||||
flatpak_remotes_columnview.append_column(&flatpak_remotes_columnview_col2);
|
||||
flatpak_remotes_columnview.append_column(&flatpak_remotes_columnview_col3);
|
||||
flatpak_remotes_columnview_bin_clone0.set_child(Some(&flatpak_remotes_columnview));
|
||||
}));
|
||||
let flatpak_remotes_columnview_factory3 = gtk::SignalListItemFactory::new();
|
||||
|
||||
flatpak_remotes_columnview_factory3.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));
|
||||
});
|
||||
|
||||
flatpak_remotes_columnview_factory3.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::<FlatpakRemote>();
|
||||
match entry_borrow.deref() {
|
||||
FlatpakRemote::System(_) => {
|
||||
child.set_label(&t!("flatpak_remotes_columnview_system").to_string());
|
||||
}
|
||||
FlatpakRemote::User(_) => {
|
||||
child.set_label(&t!("flatpak_remotes_columnview_user").to_string());
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
let flatpak_remotes_columnview_col3 = gtk::ColumnViewColumn::builder()
|
||||
.title(t!("flatpak_remotes_columnview_col3_title"))
|
||||
.factory(&flatpak_remotes_columnview_factory3)
|
||||
.build();
|
||||
|
||||
//
|
||||
flatpak_remotes_columnview.append_column(&flatpak_remotes_columnview_col0);
|
||||
flatpak_remotes_columnview.append_column(&flatpak_remotes_columnview_col1);
|
||||
flatpak_remotes_columnview.append_column(&flatpak_remotes_columnview_col2);
|
||||
flatpak_remotes_columnview.append_column(&flatpak_remotes_columnview_col3);
|
||||
flatpak_remotes_columnview_bin_clone0.set_child(Some(&flatpak_remotes_columnview));
|
||||
}
|
||||
));
|
||||
|
||||
retry_signal_action.activate(None);
|
||||
|
||||
@ -310,17 +286,14 @@ pub fn flatpak_manage_page(
|
||||
retry_signal_action,
|
||||
#[strong]
|
||||
flatpak_retry_signal_action,
|
||||
move
|
||||
|_|
|
||||
{
|
||||
add_dialog::add_dialog_fn(
|
||||
window.clone(),
|
||||
&retry_signal_action,
|
||||
&flatpak_retry_signal_action,
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
move |_| {
|
||||
add_dialog::add_dialog_fn(
|
||||
window.clone(),
|
||||
&retry_signal_action,
|
||||
&flatpak_retry_signal_action,
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
flatpak_flatref_install_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
@ -331,18 +304,15 @@ pub fn flatpak_manage_page(
|
||||
flatpak_retry_signal_action,
|
||||
#[strong]
|
||||
flatpak_ref_entry_action,
|
||||
move
|
||||
|_|
|
||||
{
|
||||
install_ref_dialog::install_ref_dialog_fn(
|
||||
window.clone(),
|
||||
&retry_signal_action,
|
||||
&flatpak_retry_signal_action,
|
||||
&flatpak_ref_entry_action
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
move |_| {
|
||||
install_ref_dialog::install_ref_dialog_fn(
|
||||
window.clone(),
|
||||
&retry_signal_action,
|
||||
&flatpak_retry_signal_action,
|
||||
&flatpak_ref_entry_action,
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
flatpak_remote_remove_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
@ -357,7 +327,7 @@ pub fn flatpak_manage_page(
|
||||
|_|
|
||||
{
|
||||
{
|
||||
let (mut installation, mut remote_name, mut cmd_installation): (libflatpak::Installation, libflatpak::glib::GString, String);
|
||||
let (installation, remote_name, cmd_installation): (libflatpak::Installation, libflatpak::glib::GString, String);
|
||||
{
|
||||
let flatpak_remotes_selection_model = flatpak_remotes_selection_model_rc.borrow();
|
||||
let selection = flatpak_remotes_selection_model.selected_item().unwrap();
|
||||
@ -459,4 +429,4 @@ pub fn flatpak_manage_page(
|
||||
main_box.append(&flatpak_remotes_viewport);
|
||||
|
||||
main_box
|
||||
}
|
||||
}
|
||||
|
@ -96,12 +96,12 @@ impl ObjectImpl for FlatpakRefRow {
|
||||
let flatref_ref_name = obj.flatref_ref_name();
|
||||
let flatref_summary = obj.flatref_summary();
|
||||
let flatref_remote_name = obj.flatref_remote_name();
|
||||
let flatref_installed_size_installed = obj.flatref_installed_size_installed();
|
||||
//let flatref_installed_size_installed = obj.flatref_installed_size_installed();
|
||||
let flatref_installed_size_remote = obj.flatref_installed_size_remote();
|
||||
let flatref_download_size = obj.flatref_download_size();
|
||||
let flatref_ref_format = obj.flatref_download_size();
|
||||
//let flatref_ref_format = obj.flatref_download_size();
|
||||
let flatref_is_system = obj.flatref_is_system();
|
||||
let flatref_marked = obj.flatref_marked();
|
||||
//let flatref_marked = obj.flatref_marked();
|
||||
//
|
||||
create_prefix_content(
|
||||
&prefix_box,
|
||||
|
@ -1,15 +1,12 @@
|
||||
mod process;
|
||||
|
||||
use crate::apt_package_row::AptPackageRow;
|
||||
use crate::flatpak_ref_row::FlatpakRefRow;
|
||||
use adw::gio::SimpleAction;
|
||||
use adw::prelude::*;
|
||||
use gtk::glib::*;
|
||||
use gtk::*;
|
||||
use libflatpak::prelude::*;
|
||||
use libflatpak::InstalledRef;
|
||||
use std::cell::RefCell;
|
||||
use std::process::Command;
|
||||
use std::rc::Rc;
|
||||
use std::thread;
|
||||
|
||||
@ -42,7 +39,6 @@ pub fn flatpak_update_page(
|
||||
let (appstream_sync_status_sender, appstream_sync_status_receiver) =
|
||||
async_channel::unbounded::<String>();
|
||||
let appstream_sync_status_sender = appstream_sync_status_sender.clone();
|
||||
let appstream_sync_status_sender_clone0 = appstream_sync_status_sender.clone();
|
||||
|
||||
let system_refs_for_upgrade_vec: Rc<RefCell<Vec<FlatpakRefRow>>> =
|
||||
Rc::new(RefCell::new(Vec::new()));
|
||||
@ -201,7 +197,7 @@ pub fn flatpak_update_page(
|
||||
.title(t!("flatpak_ignored_viewport_page_title"))
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.build();
|
||||
.build();
|
||||
|
||||
let viewport_bin = adw::Bin::builder()
|
||||
.child(&packages_no_viewport_page)
|
||||
@ -252,7 +248,7 @@ pub fn flatpak_update_page(
|
||||
if window.is_visible() {
|
||||
let retry_signal_action0 = retry_signal_action.clone();
|
||||
let viewport_bin = viewport_bin.clone();
|
||||
|
||||
|
||||
flatpak_update_dialog
|
||||
.clone()
|
||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||
@ -400,8 +396,8 @@ pub fn flatpak_update_page(
|
||||
let mut user_last_triggered = false;
|
||||
//
|
||||
if !flatpak_system_updates.is_empty() || !flatpak_user_updates.is_empty() {
|
||||
update_button.set_sensitive(true);
|
||||
viewport_bin.set_child(Some(&packages_viewport));
|
||||
update_button.set_sensitive(true);
|
||||
viewport_bin.set_child(Some(&packages_viewport));
|
||||
}
|
||||
//
|
||||
if !flatpak_system_updates.is_empty() {
|
||||
@ -551,8 +547,7 @@ pub fn flatpak_update_page(
|
||||
|
||||
packages_boxedlist.append(&flatpak_row);
|
||||
(*flatpak_update_count.borrow_mut() += 1);
|
||||
if flatref_struct.is_system && flatref_struct.is_last
|
||||
{
|
||||
if flatref_struct.is_system && flatref_struct.is_last {
|
||||
system_last_triggered = true
|
||||
}
|
||||
}
|
||||
@ -705,8 +700,7 @@ pub fn flatpak_update_page(
|
||||
);
|
||||
packages_boxedlist.append(&flatpak_row);
|
||||
(*flatpak_update_count.borrow_mut() += 1);
|
||||
if !flatref_struct.is_system && flatref_struct.is_last
|
||||
{
|
||||
if !flatref_struct.is_system && flatref_struct.is_last {
|
||||
user_last_triggered = true
|
||||
}
|
||||
}
|
||||
@ -715,7 +709,9 @@ pub fn flatpak_update_page(
|
||||
}
|
||||
if user_last_triggered && system_last_triggered {
|
||||
packages_boxedlist.set_sensitive(true);
|
||||
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[*apt_update_count.borrow(),*flatpak_update_count.borrow()])));
|
||||
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(
|
||||
&[*apt_update_count.borrow(), *flatpak_update_count.borrow()],
|
||||
)));
|
||||
}
|
||||
flatpak_update_dialog.close();
|
||||
}
|
||||
@ -733,7 +729,8 @@ pub fn flatpak_update_page(
|
||||
));
|
||||
flatpak_update_dialog
|
||||
.set_response_enabled("flatpak_update_dialog_retry", true);
|
||||
flatpak_update_dialog.set_response_enabled("flatpak_update_dialog_ignore", true);
|
||||
flatpak_update_dialog
|
||||
.set_response_enabled("flatpak_update_dialog_ignore", true);
|
||||
}
|
||||
_ => flatpak_update_dialog.set_body(&state),
|
||||
}
|
||||
|
@ -4,19 +4,12 @@ use adw::prelude::*;
|
||||
use gtk::glib::*;
|
||||
use gtk::*;
|
||||
use libflatpak::prelude::*;
|
||||
use libflatpak::Transaction;
|
||||
use pretty_bytes::converter::convert;
|
||||
use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
use std::cell::RefCell;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{fs, thread};
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
struct FlatpakChangesInfo {
|
||||
system_flatref_count: u64,
|
||||
@ -58,7 +51,6 @@ pub fn flatpak_process_update(
|
||||
window: adw::ApplicationWindow,
|
||||
retry_signal_action: &SimpleAction,
|
||||
) {
|
||||
let cancellable = libflatpak::gio::Cancellable::NONE;
|
||||
// Emulate Flatpak Full Upgrade to get transaction info
|
||||
let mut flatpak_changes_struct = FlatpakChangesInfo {
|
||||
system_flatref_count: 0,
|
||||
@ -248,16 +240,45 @@ fn flatpak_run_transactions(
|
||||
let transaction_percent_sender0 = transaction_percent_sender.clone();
|
||||
|
||||
let transaction_run_closure =
|
||||
move |transaction: &libflatpak::Transaction,
|
||||
move |_: &libflatpak::Transaction,
|
||||
transaction_operation: &libflatpak::TransactionOperation,
|
||||
transaction_progress: &libflatpak::TransactionProgress| {
|
||||
let transaction_status_sender = transaction_status_sender0.clone();
|
||||
let transaction_percent_sender = transaction_percent_sender0.clone();
|
||||
transaction_progress.connect_changed(clone!(@strong transaction_progress, @strong transaction_operation => move |_| {
|
||||
let status_message = format!("{}: {}\n{}: {}\n{}: {}/{}\n{}: {}", t!("flatpak_ref"), transaction_operation.get_ref().unwrap_or(libflatpak::glib::GString::from_string_unchecked("Unknown".to_owned())), t!("flatpak_status") ,transaction_progress.status().unwrap_or(libflatpak::glib::GString::from_string_unchecked("Unknown".to_owned())), t!("flatpak_transaction_bytes_transferred"), convert(transaction_progress.bytes_transferred() as f64), convert(transaction_operation.download_size() as f64), t!("flatpak_transaction_installed_size"), convert(transaction_operation.installed_size() as f64));
|
||||
transaction_status_sender.send_blocking(status_message).expect("transaction_status_receiver closed!");
|
||||
transaction_percent_sender.send_blocking(transaction_progress.progress().try_into().unwrap_or(0)).expect("transaction_percent_receiver closed!");
|
||||
}));
|
||||
transaction_progress.connect_changed(clone!(
|
||||
#[strong]
|
||||
transaction_progress,
|
||||
#[strong]
|
||||
transaction_operation,
|
||||
move |_| {
|
||||
let status_message = format!(
|
||||
"{}: {}\n{}: {}\n{}: {}/{}\n{}: {}",
|
||||
t!("flatpak_ref"),
|
||||
transaction_operation.get_ref().unwrap_or(
|
||||
libflatpak::glib::GString::from_string_unchecked(
|
||||
"Unknown".to_owned()
|
||||
)
|
||||
),
|
||||
t!("flatpak_status"),
|
||||
transaction_progress.status().unwrap_or(
|
||||
libflatpak::glib::GString::from_string_unchecked(
|
||||
"Unknown".to_owned()
|
||||
)
|
||||
),
|
||||
t!("flatpak_transaction_bytes_transferred"),
|
||||
convert(transaction_progress.bytes_transferred() as f64),
|
||||
convert(transaction_operation.download_size() as f64),
|
||||
t!("flatpak_transaction_installed_size"),
|
||||
convert(transaction_operation.installed_size() as f64)
|
||||
);
|
||||
transaction_status_sender
|
||||
.send_blocking(status_message)
|
||||
.expect("transaction_status_receiver closed!");
|
||||
transaction_percent_sender
|
||||
.send_blocking(transaction_progress.progress().try_into().unwrap_or(0))
|
||||
.expect("transaction_percent_receiver closed!");
|
||||
}
|
||||
));
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -1,11 +1,11 @@
|
||||
mod apt_manage_page;
|
||||
mod apt_package_row;
|
||||
mod apt_update_page;
|
||||
mod apt_manage_page;
|
||||
mod build_ui;
|
||||
mod config;
|
||||
mod flatpak_manage_page;
|
||||
mod flatpak_ref_row;
|
||||
mod flatpak_update_page;
|
||||
mod flatpak_manage_page;
|
||||
|
||||
use crate::config::APP_ID;
|
||||
use adw::prelude::*;
|
||||
@ -33,7 +33,8 @@ fn main() {
|
||||
None => panic!("$LANG is not set"),
|
||||
};
|
||||
rust_i18n::set_locale(¤t_locale);
|
||||
let application = adw::Application::new(Some(APP_ID), gio::ApplicationFlags::HANDLES_COMMAND_LINE);
|
||||
let application =
|
||||
adw::Application::new(Some(APP_ID), gio::ApplicationFlags::HANDLES_COMMAND_LINE);
|
||||
application.connect_startup(|app| {
|
||||
// The CSS "magic" happens here.
|
||||
let provider = CssProvider::new();
|
||||
|
Loading…
Reference in New Issue
Block a user