Fix Warnings and fmt
This commit is contained in:
parent
f5dcfc455a
commit
c2010b7136
@ -1,28 +1,14 @@
|
||||
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,
|
||||
)
|
||||
{
|
||||
) {
|
||||
let unofficial_source_add_dialog_child_box = Box::builder()
|
||||
.hexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
@ -68,9 +54,7 @@ pub fn add_dialog_fn(
|
||||
|
||||
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
|
||||
|
||||
let unofficial_source_add_signed_entry = gtk::Entry::builder()
|
||||
.sensitive(false)
|
||||
.build();
|
||||
let unofficial_source_add_signed_entry = gtk::Entry::builder().sensitive(false).build();
|
||||
|
||||
let unofficial_source_add_signed_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_signed_prefrencesgroup_title"))
|
||||
@ -176,26 +160,33 @@ pub fn add_dialog_fn(
|
||||
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_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 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_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);
|
||||
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);
|
||||
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_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);
|
||||
unofficial_source_add_dialog_clone0
|
||||
.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
}
|
||||
};
|
||||
|
||||
@ -211,12 +202,10 @@ pub fn add_dialog_fn(
|
||||
entry.connect_text_notify(clone!(
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |_|
|
||||
{
|
||||
move |_| {
|
||||
add_button_update_state();
|
||||
}
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
//
|
||||
@ -226,48 +215,44 @@ pub fn add_dialog_fn(
|
||||
unofficial_source_add_signed_entry,
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |checkbutton|
|
||||
{
|
||||
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|
|
||||
{
|
||||
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"));
|
||||
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|
|
||||
{
|
||||
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"));
|
||||
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);
|
||||
@ -278,7 +263,8 @@ pub fn add_dialog_fn(
|
||||
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_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);
|
||||
@ -286,7 +272,8 @@ pub fn add_dialog_fn(
|
||||
let reload_action_clone0 = reload_action.clone();
|
||||
let apt_retry_signal_action_clone0 = apt_retry_signal_action.clone();
|
||||
|
||||
unofficial_source_add_dialog.clone()
|
||||
unofficial_source_add_dialog
|
||||
.clone()
|
||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||
match choice.as_str() {
|
||||
"unofficial_source_add_dialog_add" => {
|
||||
@ -298,7 +285,10 @@ pub fn add_dialog_fn(
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let repo_file_name = non_alphanum_regex.replace_all(unofficial_source_add_name_entry.text().as_str(), "_").to_string().to_lowercase();
|
||||
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),
|
||||
@ -318,21 +308,33 @@ pub fn add_dialog_fn(
|
||||
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
|
||||
_ => None,
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
if sign_method == 2 {
|
||||
match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) {
|
||||
match Deb822Repository::write_to_file(
|
||||
new_repo.clone(),
|
||||
format!("/tmp/{}.sources", repo_file_name).into(),
|
||||
) {
|
||||
Ok(_) => {
|
||||
match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move_with_wget", &repo_file_name, &unofficial_source_add_signed_entry.text().to_string(), &format!("/etc/apt/keyrings/{}.gpg.key", &repo_file_name)).run() {
|
||||
match duct::cmd!(
|
||||
"pkexec",
|
||||
"/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh",
|
||||
"deb822_move_with_wget",
|
||||
&repo_file_name,
|
||||
&unofficial_source_add_signed_entry.text().to_string(),
|
||||
&format!("/etc/apt/keyrings/{}.gpg.key", &repo_file_name)
|
||||
)
|
||||
.run()
|
||||
{
|
||||
Ok(_) => {
|
||||
reload_action_clone0.activate(None);
|
||||
apt_retry_signal_action_clone0.activate(None);
|
||||
|
||||
}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
let apt_src_create_error_dialog =
|
||||
adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
@ -359,15 +361,26 @@ pub fn add_dialog_fn(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) {
|
||||
match Deb822Repository::write_to_file(
|
||||
new_repo.clone(),
|
||||
format!("/tmp/{}.sources", repo_file_name).into(),
|
||||
) {
|
||||
Ok(_) => {
|
||||
match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move", repo_file_name).run() {
|
||||
match duct::cmd!(
|
||||
"pkexec",
|
||||
"/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh",
|
||||
"deb822_move",
|
||||
repo_file_name
|
||||
)
|
||||
.run()
|
||||
{
|
||||
Ok(_) => {
|
||||
reload_action_clone0.activate(None);
|
||||
apt_retry_signal_action_clone0.activate(None);
|
||||
}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
let apt_src_create_error_dialog =
|
||||
adw::MessageDialog::builder()
|
||||
.heading(t!("apt_src_create_error_dialog_heading"))
|
||||
.body(e.to_string())
|
||||
.build();
|
||||
|
@ -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(
|
||||
@ -38,8 +25,7 @@ pub fn deb822_edit_dialog_fn(
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_name_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_name_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_name_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_name_prefrencesgroup_title"))
|
||||
@ -47,8 +33,7 @@ pub fn deb822_edit_dialog_fn(
|
||||
|
||||
unofficial_source_add_name_prefrencesgroup.add(&unofficial_source_add_name_entry);
|
||||
|
||||
let unofficial_source_add_uri_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_uri_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_uri_prefrencesgroup_title"))
|
||||
@ -56,8 +41,7 @@ pub fn deb822_edit_dialog_fn(
|
||||
|
||||
unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry);
|
||||
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_suites_prefrencesgroup_title"))
|
||||
@ -65,8 +49,7 @@ pub fn deb822_edit_dialog_fn(
|
||||
|
||||
unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry);
|
||||
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_components_prefrencesgroup_title"))
|
||||
@ -74,9 +57,7 @@ pub fn deb822_edit_dialog_fn(
|
||||
|
||||
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
|
||||
|
||||
let unofficial_source_add_signed_entry = gtk::Entry::builder()
|
||||
.sensitive(false)
|
||||
.build();
|
||||
let unofficial_source_add_signed_entry = gtk::Entry::builder().sensitive(false).build();
|
||||
|
||||
let unofficial_source_add_signed_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_signed_prefrencesgroup_title"))
|
||||
@ -84,8 +65,7 @@ pub fn deb822_edit_dialog_fn(
|
||||
|
||||
unofficial_source_add_signed_prefrencesgroup.add(&unofficial_source_add_signed_entry);
|
||||
|
||||
let unofficial_source_add_archs_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_archs_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_archs_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_archs_prefrencesgroup_title"))
|
||||
@ -106,7 +86,6 @@ pub fn deb822_edit_dialog_fn(
|
||||
.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)
|
||||
@ -185,26 +164,33 @@ pub fn deb822_edit_dialog_fn(
|
||||
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_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 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_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);
|
||||
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);
|
||||
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_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);
|
||||
unofficial_source_add_dialog_clone0
|
||||
.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
}
|
||||
};
|
||||
|
||||
@ -220,12 +206,10 @@ pub fn deb822_edit_dialog_fn(
|
||||
entry.connect_text_notify(clone!(
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |_|
|
||||
{
|
||||
move |_| {
|
||||
add_button_update_state();
|
||||
}
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
//
|
||||
@ -235,30 +219,26 @@ pub fn deb822_edit_dialog_fn(
|
||||
unofficial_source_add_signed_entry,
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |checkbutton|
|
||||
{
|
||||
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|
|
||||
{
|
||||
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);
|
||||
@ -270,12 +250,12 @@ pub fn deb822_edit_dialog_fn(
|
||||
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_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 {
|
||||
@ -307,9 +287,7 @@ pub fn deb822_edit_dialog_fn(
|
||||
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)
|
||||
}
|
||||
None => unofficial_source_signed_keyring_checkbutton.set_active(true),
|
||||
}
|
||||
match &deb822_repo.architectures {
|
||||
Some(t) => {
|
||||
@ -345,8 +323,8 @@ pub fn deb822_edit_dialog_fn(
|
||||
let reload_action_clone0 = reload_action.clone();
|
||||
let apt_retry_signal_action_clone0 = apt_retry_signal_action.clone();
|
||||
|
||||
|
||||
unofficial_source_add_dialog.clone()
|
||||
unofficial_source_add_dialog
|
||||
.clone()
|
||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||
match choice.as_str() {
|
||||
"unofficial_source_edit_dialog_edit" => {
|
||||
@ -373,17 +351,27 @@ pub fn deb822_edit_dialog_fn(
|
||||
},
|
||||
signed_by: match sign_method {
|
||||
1 => Some(unofficial_source_add_signed_entry.text().to_string()),
|
||||
_ => None
|
||||
_ => None,
|
||||
},
|
||||
enabled: match unofficial_source_add_is_enabled_switch.is_active() {
|
||||
true => Some("yes".to_string()),
|
||||
false => Some("no".to_string())
|
||||
false => Some("no".to_string()),
|
||||
},
|
||||
..deb822_repo_clone0
|
||||
};
|
||||
match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) {
|
||||
match Deb822Repository::write_to_file(
|
||||
new_repo.clone(),
|
||||
format!("/tmp/{}.sources", repo_file_name).into(),
|
||||
) {
|
||||
Ok(_) => {
|
||||
match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move", repo_file_name).run() {
|
||||
match duct::cmd!(
|
||||
"pkexec",
|
||||
"/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh",
|
||||
"deb822_move",
|
||||
repo_file_name
|
||||
)
|
||||
.run()
|
||||
{
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
let apt_src_create_error_dialog = adw::MessageDialog::builder()
|
||||
|
@ -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(
|
||||
@ -38,8 +25,7 @@ pub fn legacy_edit_dialog_fn(
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let unofficial_source_add_uri_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_uri_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_uri_prefrencesgroup_title"))
|
||||
@ -47,8 +33,7 @@ pub fn legacy_edit_dialog_fn(
|
||||
|
||||
unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry);
|
||||
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_suites_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_suites_prefrencesgroup_title"))
|
||||
@ -56,8 +41,7 @@ pub fn legacy_edit_dialog_fn(
|
||||
|
||||
unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry);
|
||||
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_components_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_components_prefrencesgroup_title"))
|
||||
@ -65,14 +49,16 @@ pub fn legacy_edit_dialog_fn(
|
||||
|
||||
unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry);
|
||||
|
||||
let unofficial_source_add_legacy_options_entry = gtk::Entry::builder()
|
||||
.build();
|
||||
let unofficial_source_add_legacy_options_entry = gtk::Entry::builder().build();
|
||||
|
||||
let unofficial_source_add_legacy_options_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("unofficial_source_add_legacy_options_prefrencesgroup_title"))
|
||||
.title(t!(
|
||||
"unofficial_source_add_legacy_options_prefrencesgroup_title"
|
||||
))
|
||||
.build();
|
||||
|
||||
unofficial_source_add_legacy_options_prefrencesgroup.add(&unofficial_source_add_legacy_options_entry);
|
||||
unofficial_source_add_legacy_options_prefrencesgroup
|
||||
.add(&unofficial_source_add_legacy_options_entry);
|
||||
|
||||
let unofficial_source_add_box2 = gtk::Box::builder()
|
||||
.margin_top(10)
|
||||
@ -87,7 +73,6 @@ pub fn legacy_edit_dialog_fn(
|
||||
.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)
|
||||
@ -152,17 +137,21 @@ pub fn legacy_edit_dialog_fn(
|
||||
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 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()
|
||||
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);
|
||||
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_clone0
|
||||
.set_response_enabled("unofficial_source_add_dialog_add", false);
|
||||
}
|
||||
};
|
||||
|
||||
@ -177,12 +166,10 @@ pub fn legacy_edit_dialog_fn(
|
||||
entry.connect_text_notify(clone!(
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |_|
|
||||
{
|
||||
move |_| {
|
||||
add_button_update_state();
|
||||
}
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
//
|
||||
@ -194,10 +181,11 @@ pub fn legacy_edit_dialog_fn(
|
||||
|
||||
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_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_dialog_child_box
|
||||
.append(&unofficial_source_add_legacy_options_prefrencesgroup);
|
||||
|
||||
//
|
||||
|
||||
@ -220,7 +208,8 @@ pub fn legacy_edit_dialog_fn(
|
||||
let reload_action_clone0 = reload_action.clone();
|
||||
let apt_retry_signal_action_clone0 = apt_retry_signal_action.clone();
|
||||
|
||||
unofficial_source_add_dialog.clone()
|
||||
unofficial_source_add_dialog
|
||||
.clone()
|
||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||
match choice.as_str() {
|
||||
"unofficial_source_edit_dialog_edit" => {
|
||||
@ -231,14 +220,29 @@ pub fn legacy_edit_dialog_fn(
|
||||
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()),
|
||||
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)) {
|
||||
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() {
|
||||
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()
|
||||
|
@ -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) => {
|
||||
@ -182,9 +192,11 @@ 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();
|
||||
|
||||
@ -194,16 +206,11 @@ pub fn apt_manage_page(
|
||||
#[weak]
|
||||
unofficial_sources_columnview_bin_clone0,
|
||||
move |_, _| {
|
||||
|
||||
let mut unofficial_deb822_sources = Deb822Repository::get_deb822_sources().unwrap();
|
||||
|
||||
unofficial_deb822_sources.retain(|x| {
|
||||
match &x.repolib_id {
|
||||
Some(t) => {
|
||||
!(t == "system")
|
||||
}
|
||||
None => true
|
||||
}
|
||||
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();
|
||||
@ -211,21 +218,25 @@ pub fn apt_manage_page(
|
||||
let unofficial_sources_list_store = gio::ListStore::new::<BoxedAnyObject>();
|
||||
|
||||
for deb822_source in unofficial_deb822_sources {
|
||||
unofficial_sources_list_store.append(&BoxedAnyObject::new(AptSourceConfig::DEB822(deb822_source)));
|
||||
};
|
||||
unofficial_sources_list_store
|
||||
.append(&BoxedAnyObject::new(AptSourceConfig::DEB822(deb822_source)));
|
||||
}
|
||||
|
||||
match legacy_apt_repos {
|
||||
Ok(vec) => {
|
||||
for legacy_repo in vec {
|
||||
unofficial_sources_list_store.append(&BoxedAnyObject::new(AptSourceConfig::Legacy(legacy_repo)));
|
||||
};
|
||||
unofficial_sources_list_store
|
||||
.append(&BoxedAnyObject::new(AptSourceConfig::Legacy(legacy_repo)));
|
||||
}
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
|
||||
let unofficial_sources_selection_model = SingleSelection::new(Some(unofficial_sources_list_store));
|
||||
let unofficial_sources_selection_model =
|
||||
SingleSelection::new(Some(unofficial_sources_list_store));
|
||||
|
||||
(*unofficial_sources_selection_model_rc_clone0.borrow_mut() = unofficial_sources_selection_model.clone());
|
||||
(*unofficial_sources_selection_model_rc_clone0.borrow_mut() =
|
||||
unofficial_sources_selection_model.clone());
|
||||
|
||||
let unofficial_sources_columnview = ColumnView::builder()
|
||||
.vexpand(true)
|
||||
@ -238,9 +249,7 @@ pub fn apt_manage_page(
|
||||
|
||||
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();
|
||||
let row = Label::builder().halign(Align::Start).build();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
|
||||
@ -250,23 +259,17 @@ pub fn apt_manage_page(
|
||||
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 {
|
||||
AptSourceConfig::DEB822(src) => match &src.repolib_name {
|
||||
Some(name) => name,
|
||||
None => match (&src.uris, &src.suites, &src.components) {
|
||||
(Some(uris), Some(suites), Some(components)) => {
|
||||
&format!("{} {} {}", uris, suites, components)
|
||||
}
|
||||
(_,_,_) => {
|
||||
&t!("apt_source_parse_error").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
AptSourceConfig::Legacy(src) => {
|
||||
&format!("{} {} {} {}",
|
||||
(_, _, _) => &t!("apt_source_parse_error").to_string(),
|
||||
},
|
||||
},
|
||||
AptSourceConfig::Legacy(src) => &format!(
|
||||
"{} {} {} {}",
|
||||
if src.is_source {
|
||||
"(Legacy Src)"
|
||||
} else {
|
||||
@ -275,8 +278,7 @@ pub fn apt_manage_page(
|
||||
&src.url,
|
||||
&src.suite,
|
||||
&src.components
|
||||
)
|
||||
}
|
||||
),
|
||||
};
|
||||
child.set_label(&repo_name);
|
||||
});
|
||||
@ -293,9 +295,7 @@ pub fn apt_manage_page(
|
||||
|
||||
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();
|
||||
let row = Label::builder().halign(Align::Start).build();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
|
||||
@ -305,21 +305,17 @@ pub fn apt_manage_page(
|
||||
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 {
|
||||
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
|
||||
}
|
||||
},
|
||||
AptSourceConfig::Legacy(src) => src.enabled,
|
||||
};
|
||||
if repo_enabled {
|
||||
child.set_label(&t!("apt_repo_enabled"));
|
||||
@ -336,8 +332,10 @@ pub fn apt_manage_page(
|
||||
//
|
||||
unofficial_sources_columnview.append_column(&unofficial_sources_columnview_col0);
|
||||
unofficial_sources_columnview.append_column(&unofficial_sources_columnview_col1);
|
||||
unofficial_sources_columnview_bin_clone0.set_child(Some(&unofficial_sources_columnview));
|
||||
}));
|
||||
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
|
||||
|_|
|
||||
{
|
||||
move |_| {
|
||||
add_dialog::add_dialog_fn(
|
||||
window.clone(),
|
||||
&retry_signal_action,
|
||||
&apt_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
|
||||
|_|
|
||||
{
|
||||
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)
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
)
|
||||
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,24 +447,41 @@ 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 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()
|
||||
@ -481,14 +497,16 @@ pub fn apt_manage_page(
|
||||
"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);
|
||||
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() {
|
||||
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)
|
||||
@ -506,15 +524,13 @@ pub fn apt_manage_page(
|
||||
retry_signal_action_clone0.activate(None);
|
||||
apt_retry_signal_action_clone0.activate(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
//
|
||||
|
||||
|
@ -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() {
|
||||
@ -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,7 +25,7 @@ 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 {
|
||||
@ -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()
|
||||
}
|
||||
@ -129,34 +128,35 @@ pub fn build_ui(app: &Application) {
|
||||
};
|
||||
tray_handle.update(|tray: &mut PikmanTray| {
|
||||
tray.icon_name = tray_icon;
|
||||
tray.apt_item_label = Some(strfmt::strfmt(
|
||||
tray.apt_item_label = Some(
|
||||
strfmt::strfmt(
|
||||
&t!("pikman_indicator_apt_count_item_label").to_string(),
|
||||
&std::collections::HashMap::from([
|
||||
(
|
||||
&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(
|
||||
.unwrap(),
|
||||
);
|
||||
tray.flatpak_item_label = Some(
|
||||
strfmt::strfmt(
|
||||
&t!("pikman_indicator_flatpak_count_item_label").to_string(),
|
||||
&std::collections::HashMap::from([
|
||||
(
|
||||
&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])));
|
||||
|
||||
thread::spawn(move || loop {
|
||||
@ -228,17 +228,28 @@ 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 sidebar_toggle_button = gtk::ToggleButton::builder()
|
||||
.icon_name("view-right-pane-symbolic")
|
||||
.visible(false)
|
||||
@ -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());
|
||||
}
|
||||
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(
|
||||
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,
|
||||
)));
|
||||
),
|
||||
));
|
||||
}
|
||||
));
|
||||
|
||||
@ -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!(
|
||||
@ -496,7 +528,10 @@ pub fn build_ui(app: &Application) {
|
||||
}
|
||||
|
||||
// Check for cmd lines
|
||||
if !(gtk_application_args.contains(&"--hidden".to_string())) && !(gtk_application_args.contains(&"--flatpak-installer".to_string())) && !window.is_visible() {
|
||||
if !(gtk_application_args.contains(&"--hidden".to_string()))
|
||||
&& !(gtk_application_args.contains(&"--flatpak-installer".to_string()))
|
||||
&& !window.is_visible()
|
||||
{
|
||||
window.present();
|
||||
}
|
||||
|
||||
@ -510,13 +545,18 @@ pub fn build_ui(app: &Application) {
|
||||
}
|
||||
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])));
|
||||
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| {
|
||||
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,39 +1,19 @@
|
||||
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();
|
||||
let flatpak_remote_add_name_entry = gtk::Entry::builder().placeholder_text("Flathub").build();
|
||||
|
||||
let flatpak_remote_add_name_prefrencesgroup = adw::PreferencesGroup::builder()
|
||||
.title(t!("flatpak_remote_add_name_prefrencesgroup_title"))
|
||||
@ -121,15 +101,15 @@ pub fn add_dialog_fn(
|
||||
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();
|
||||
|
||||
|
||||
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()
|
||||
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);
|
||||
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_clone0
|
||||
.set_response_enabled("flatpak_remote_add_dialog_add", false);
|
||||
}
|
||||
};
|
||||
|
||||
@ -142,12 +122,10 @@ pub fn add_dialog_fn(
|
||||
entry.connect_text_notify(clone!(
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |_|
|
||||
{
|
||||
move |_| {
|
||||
add_button_update_state();
|
||||
}
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
//
|
||||
@ -162,13 +140,14 @@ pub fn add_dialog_fn(
|
||||
let reload_action_clone0 = reload_action.clone();
|
||||
let flatpak_retry_signal_action_clone0 = flatpak_retry_signal_action.clone();
|
||||
|
||||
flatpak_remote_add_dialog.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 cancellable_no = libflatpak::gio::Cancellable::NONE;
|
||||
|
||||
/*let flatpak_installation = match flatpak_remote_system_togglebutton.is_active() {
|
||||
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(),
|
||||
};
|
||||
@ -204,12 +183,22 @@ pub fn add_dialog_fn(
|
||||
}
|
||||
}*/
|
||||
|
||||
let flatpak_installation = match flatpak_remote_system_togglebutton.is_active() {
|
||||
let flatpak_installation = match flatpak_remote_system_togglebutton.is_active()
|
||||
{
|
||||
true => "--system",
|
||||
false => "--user"
|
||||
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() {
|
||||
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);
|
||||
|
@ -1,37 +1,24 @@
|
||||
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)
|
||||
@ -43,8 +30,12 @@ pub fn install_ref_dialog_fn(
|
||||
#[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"))
|
||||
.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();
|
||||
@ -57,15 +48,16 @@ pub fn install_ref_dialog_fn(
|
||||
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());
|
||||
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"))
|
||||
.tooltip_text(t!(
|
||||
"flatpak_ref_install_flatref_path_entry_open_file_dialog_text"
|
||||
))
|
||||
.halign(gtk::Align::End)
|
||||
.icon_name("document-open-symbolic")
|
||||
.build();
|
||||
@ -85,36 +77,34 @@ pub fn install_ref_dialog_fn(
|
||||
));
|
||||
|
||||
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);
|
||||
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!(
|
||||
flatpak_ref_install_flatref_path_file_dialog.connect_response(clone!(
|
||||
#[weak]
|
||||
flatpak_ref_install_flatref_path_entry,
|
||||
move |dialog, response|
|
||||
{
|
||||
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()),
|
||||
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);
|
||||
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)
|
||||
@ -163,7 +153,8 @@ pub fn install_ref_dialog_fn(
|
||||
.height_request(400)
|
||||
.build();
|
||||
|
||||
flatpak_ref_install_flatref_path_file_dialog.set_transient_for(Some(&flatpak_ref_install_dialog));
|
||||
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",
|
||||
@ -190,7 +181,8 @@ pub fn install_ref_dialog_fn(
|
||||
//
|
||||
|
||||
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_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));
|
||||
@ -200,8 +192,9 @@ pub fn install_ref_dialog_fn(
|
||||
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()
|
||||
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) => {
|
||||
@ -209,67 +202,67 @@ pub fn install_ref_dialog_fn(
|
||||
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_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(
|
||||
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,
|
||||
),
|
||||
("NAME".to_string(), name),
|
||||
("REMOTE".to_string(), remote_name),
|
||||
]),
|
||||
)
|
||||
.unwrap());
|
||||
.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_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);
|
||||
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_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_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_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,
|
||||
] {
|
||||
for entry in [&flatpak_ref_install_flatref_path_entry] {
|
||||
entry.connect_text_notify(clone!(
|
||||
#[strong]
|
||||
add_button_update_state,
|
||||
move |_|
|
||||
{
|
||||
move |_| {
|
||||
add_button_update_state();
|
||||
}
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
//
|
||||
@ -283,28 +276,49 @@ pub fn install_ref_dialog_fn(
|
||||
|
||||
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 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.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()) {
|
||||
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());
|
||||
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());
|
||||
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>();
|
||||
let transaction_percent_sender = transaction_percent_sender.clone();
|
||||
@ -312,7 +326,7 @@ pub fn run_flatpak_ref_install_transaction(flatpak_retry_signal_action: &gio::Si
|
||||
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,
|
||||
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 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
|
||||
}
|
||||
};
|
||||
|
||||
@ -419,8 +466,7 @@ 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()
|
||||
let flatpak_transaction_dialog = adw::MessageDialog::builder()
|
||||
.transient_for(&window)
|
||||
.extra_child(&flatpak_transaction_dialog_child_box)
|
||||
.heading(t!("flatpak_transaction_dialog_heading"))
|
||||
@ -556,13 +602,27 @@ fn get_data_from_filepath(filepath: &str) -> Result<libflatpak::glib::Bytes, std
|
||||
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);
|
||||
}
|
||||
|
@ -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,7 +54,8 @@ 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);
|
||||
|
||||
@ -83,35 +69,44 @@ pub fn flatpak_manage_page(
|
||||
#[strong]
|
||||
cancellable_no,
|
||||
move |_, _| {
|
||||
|
||||
let flatpak_system_installation =
|
||||
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) {
|
||||
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>();
|
||||
|
||||
for remote in system_remotes {
|
||||
flatpak_remotes_list_store.append(&BoxedAnyObject::new(FlatpakRemote::System(remote)));
|
||||
};
|
||||
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)));
|
||||
};
|
||||
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)
|
||||
@ -124,9 +119,7 @@ pub fn flatpak_manage_page(
|
||||
|
||||
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();
|
||||
let row = Label::builder().halign(Align::Start).build();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
|
||||
@ -136,12 +129,8 @@ pub fn flatpak_manage_page(
|
||||
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()
|
||||
}
|
||||
FlatpakRemote::System(remote) => remote.name().unwrap_or_default(),
|
||||
FlatpakRemote::User(remote) => remote.name().unwrap_or_default(),
|
||||
};
|
||||
child.set_label(&remote_name);
|
||||
});
|
||||
@ -157,9 +146,7 @@ pub fn flatpak_manage_page(
|
||||
|
||||
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();
|
||||
let row = Label::builder().halign(Align::Start).build();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
|
||||
@ -169,12 +156,8 @@ pub fn flatpak_manage_page(
|
||||
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()
|
||||
}
|
||||
FlatpakRemote::System(remote) => remote.title().unwrap_or_default(),
|
||||
FlatpakRemote::User(remote) => remote.title().unwrap_or_default(),
|
||||
};
|
||||
child.set_label(&remote_title);
|
||||
});
|
||||
@ -190,9 +173,7 @@ pub fn flatpak_manage_page(
|
||||
|
||||
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();
|
||||
let row = Label::builder().halign(Align::Start).build();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
|
||||
@ -202,12 +183,8 @@ pub fn flatpak_manage_page(
|
||||
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()
|
||||
}
|
||||
FlatpakRemote::System(remote) => remote.url().unwrap_or_default(),
|
||||
FlatpakRemote::User(remote) => remote.url().unwrap_or_default(),
|
||||
};
|
||||
child.set_label(&remote_url);
|
||||
});
|
||||
@ -224,9 +201,7 @@ pub fn flatpak_manage_page(
|
||||
|
||||
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();
|
||||
let row = Label::builder().halign(Align::Start).build();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
|
||||
@ -236,10 +211,10 @@ pub fn flatpak_manage_page(
|
||||
let entry: BoxedAnyObject = item.item().and_downcast::<BoxedAnyObject>().unwrap();
|
||||
let entry_borrow = entry.borrow::<FlatpakRemote>();
|
||||
match entry_borrow.deref() {
|
||||
FlatpakRemote::System(remote) => {
|
||||
FlatpakRemote::System(_) => {
|
||||
child.set_label(&t!("flatpak_remotes_columnview_system").to_string());
|
||||
}
|
||||
FlatpakRemote::User(remote) => {
|
||||
FlatpakRemote::User(_) => {
|
||||
child.set_label(&t!("flatpak_remotes_columnview_user").to_string());
|
||||
}
|
||||
};
|
||||
@ -256,7 +231,8 @@ pub fn flatpak_manage_page(
|
||||
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
|
||||
|_|
|
||||
{
|
||||
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
|
||||
|_|
|
||||
{
|
||||
move |_| {
|
||||
install_ref_dialog::install_ref_dialog_fn(
|
||||
window.clone(),
|
||||
&retry_signal_action,
|
||||
&flatpak_retry_signal_action,
|
||||
&flatpak_ref_entry_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();
|
||||
|
@ -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()));
|
||||
@ -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