part 0 add trans and fix tray and allow ignore error and fix autostart
This commit is contained in:
parent
40c0a64c85
commit
650093da67
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -1941,8 +1941,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-apt"
|
name = "rust-apt"
|
||||||
version = "0.7.0"
|
version = "0.8.0"
|
||||||
source = "git+https://gitlab.com/volian/rust-apt#89f7f127b3af5595bec61ab520a813d8bf9fc502"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "89d78ef02335b0d12dff96f742b2124f371922d3efbedbcba5703025bb0e37a6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cxx",
|
"cxx",
|
||||||
"cxx-build",
|
"cxx-build",
|
||||||
|
@ -25,7 +25,7 @@ adw = { version = "0.7.0", package = "libadwaita", features = ["v1_4"] }
|
|||||||
gtk = { version = "0.9.0", package = "gtk4", features = ["v4_12"] }
|
gtk = { version = "0.9.0", package = "gtk4", features = ["v4_12"] }
|
||||||
async-channel = "2.1.1"
|
async-channel = "2.1.1"
|
||||||
rust-i18n = "3.0.1"
|
rust-i18n = "3.0.1"
|
||||||
rust-apt = { git = "https://gitlab.com/volian/rust-apt" }
|
rust-apt = "0.8.0"
|
||||||
apt-deb822-tools = { package = "deb822-tools", git = "https://github.com/CosmicFusion/deb822-tools" }
|
apt-deb822-tools = { package = "deb822-tools", git = "https://github.com/CosmicFusion/deb822-tools" }
|
||||||
apt-legacy-tools = { version = "0.1.3", package = "legacy-apt-list-tools-rs", git = "https://github.com/CosmicFusion/legacy-apt-list-tools-rs" }
|
apt-legacy-tools = { version = "0.1.3", package = "legacy-apt-list-tools-rs", git = "https://github.com/CosmicFusion/legacy-apt-list-tools-rs" }
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
@ -2,5 +2,6 @@
|
|||||||
DISPLAY_CHECK=$(echo $DISPLAY)
|
DISPLAY_CHECK=$(echo $DISPLAY)
|
||||||
WHO=$(whoami)
|
WHO=$(whoami)
|
||||||
if [[ $DISPLAY_CHECK ]] && [[ $WHO != "pikaos" ]] && [[ $WHO != "gnome-initial-setup" ]] ; then
|
if [[ $DISPLAY_CHECK ]] && [[ $WHO != "pikaos" ]] && [[ $WHO != "gnome-initial-setup" ]] ; then
|
||||||
|
sleep 30
|
||||||
pikman-update-manager --hidden
|
pikman-update-manager --hidden
|
||||||
fi
|
fi
|
@ -159,5 +159,10 @@
|
|||||||
"pikman_indicator_flatpak_count_item_label": "Flatpak Updates: {NUM}",
|
"pikman_indicator_flatpak_count_item_label": "Flatpak Updates: {NUM}",
|
||||||
"pikman_indicator_flatpak_item_label_calculating": "calculating...",
|
"pikman_indicator_flatpak_item_label_calculating": "calculating...",
|
||||||
"pikman_indicator_open_item_label": "Open",
|
"pikman_indicator_open_item_label": "Open",
|
||||||
"pikman_indicator_exit_item_label": "Exit"
|
"pikman_indicator_exit_item_label": "Exit",
|
||||||
|
"apt_install_str_error": "DPKG error in {PKGNAME}: {ERROR}",
|
||||||
|
"apt_update_str_hit": "Up-to-date: {DESC} {SHORT_DESC}",
|
||||||
|
"apt_update_str_fetch": "Fetching: {DESC} {SHORT_DESC}",
|
||||||
|
"apt_update_str_done": "Downloading: {DESC} {SHORT_DESC}",
|
||||||
|
"apt_update_str_fail": "Download Failed: {DESC} {SHORT_DESC}"
|
||||||
}
|
}
|
@ -5,8 +5,17 @@ use rust_apt::cache::Upgrade;
|
|||||||
use rust_apt::new_cache;
|
use rust_apt::new_cache;
|
||||||
use rust_apt::progress::{AcquireProgress, InstallProgress};
|
use rust_apt::progress::{AcquireProgress, InstallProgress};
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
// Init translations for current crate.
|
||||||
|
#[macro_use]
|
||||||
|
extern crate rust_i18n;
|
||||||
|
i18n!("locales", fallback = "en_US");
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
rust_i18n::set_locale(&args[1]);
|
||||||
|
|
||||||
let percent_socket_path = "/tmp/pika_apt_upgrade_percent.sock";
|
let percent_socket_path = "/tmp/pika_apt_upgrade_percent.sock";
|
||||||
let status_socket_path = "/tmp/pika_apt_upgrade_status.sock";
|
let status_socket_path = "/tmp/pika_apt_upgrade_status.sock";
|
||||||
let json_file_path = "/tmp/pika-apt-exclusions.json";
|
let json_file_path = "/tmp/pika-apt-exclusions.json";
|
||||||
@ -56,13 +65,24 @@ fn main() {
|
|||||||
|
|
||||||
apt_upgrade_cache.resolve(true).unwrap();
|
apt_upgrade_cache.resolve(true).unwrap();
|
||||||
|
|
||||||
|
let hit_strfmt_trans_str = t!("apt_update_str_hit").to_string();
|
||||||
|
let fetch_strfmt_trans_str = t!("apt_update_str_fetch").to_string();
|
||||||
|
let done_strfmt_trans_str = t!("apt_update_str_done").to_string();
|
||||||
|
let fail_strfmt_trans_str = t!("apt_update_str_fail").to_string();
|
||||||
|
let error_strfmt_trans_str = t!("apt_install_str_error").to_string();
|
||||||
|
|
||||||
let mut acquire_progress = AcquireProgress::new(AptUpdateProgressSocket::new(
|
let mut acquire_progress = AcquireProgress::new(AptUpdateProgressSocket::new(
|
||||||
percent_socket_path,
|
percent_socket_path,
|
||||||
status_socket_path,
|
status_socket_path,
|
||||||
|
&hit_strfmt_trans_str,
|
||||||
|
&fetch_strfmt_trans_str,
|
||||||
|
&done_strfmt_trans_str,
|
||||||
|
&fail_strfmt_trans_str,
|
||||||
));
|
));
|
||||||
let mut install_progress = InstallProgress::new(AptInstallProgressSocket::new(
|
let mut install_progress = InstallProgress::new(AptInstallProgressSocket::new(
|
||||||
percent_socket_path,
|
percent_socket_path,
|
||||||
status_socket_path,
|
status_socket_path,
|
||||||
|
&error_strfmt_trans_str,
|
||||||
));
|
));
|
||||||
|
|
||||||
apt_upgrade_cache.resolve(true).unwrap();
|
apt_upgrade_cache.resolve(true).unwrap();
|
||||||
|
@ -3,14 +3,32 @@ use pika_unixsocket_tools::pika_unixsocket_tools::*;
|
|||||||
use rust_apt::new_cache;
|
use rust_apt::new_cache;
|
||||||
use rust_apt::progress::AcquireProgress;
|
use rust_apt::progress::AcquireProgress;
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
// Init translations for current crate.
|
||||||
|
#[macro_use]
|
||||||
|
extern crate rust_i18n;
|
||||||
|
i18n!("locales", fallback = "en_US");
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
rust_i18n::set_locale(&args[1]);
|
||||||
|
|
||||||
|
let hit_strfmt_trans_str = t!("apt_update_str_hit").to_string();
|
||||||
|
let fetch_strfmt_trans_str = t!("apt_update_str_fetch").to_string();
|
||||||
|
let done_strfmt_trans_str = t!("apt_update_str_done").to_string();
|
||||||
|
let fail_strfmt_trans_str = t!("apt_update_str_fail").to_string();
|
||||||
|
|
||||||
let update_cache = new_cache!().unwrap();
|
let update_cache = new_cache!().unwrap();
|
||||||
let percent_socket_path = "/tmp/pika_apt_update_percent.sock";
|
let percent_socket_path = "/tmp/pika_apt_update_percent.sock";
|
||||||
let status_socket_path = "/tmp/pika_apt_update_status.sock";
|
let status_socket_path = "/tmp/pika_apt_update_status.sock";
|
||||||
match update_cache.update(&mut AcquireProgress::new(AptUpdateProgressSocket::new(
|
match update_cache.update(&mut AcquireProgress::new(AptUpdateProgressSocket::new(
|
||||||
percent_socket_path,
|
percent_socket_path,
|
||||||
status_socket_path,
|
status_socket_path,
|
||||||
|
&hit_strfmt_trans_str,
|
||||||
|
&fetch_strfmt_trans_str,
|
||||||
|
&done_strfmt_trans_str,
|
||||||
|
&fail_strfmt_trans_str,
|
||||||
))) {
|
))) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -66,7 +66,7 @@ pub fn apt_update_page(
|
|||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let apt_update_command = Command::new("pkexec")
|
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", "fr_FR"])
|
||||||
.status()
|
.status()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
match apt_update_command.code().unwrap() {
|
match apt_update_command.code().unwrap() {
|
||||||
@ -127,12 +127,12 @@ pub fn apt_update_page(
|
|||||||
.vexpand(true)
|
.vexpand(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let packages_ignored_viewport_page = adw::StatusPage::builder()
|
/*let packages_ignored_viewport_page = adw::StatusPage::builder()
|
||||||
.icon_name("dialog-warning-symbolic")
|
.icon_name("dialog-warning-symbolic")
|
||||||
.title(t!("apt_ignored_viewport_page_title"))
|
.title(t!("apt_ignored_viewport_page_title"))
|
||||||
.hexpand(true)
|
.hexpand(true)
|
||||||
.vexpand(true)
|
.vexpand(true)
|
||||||
.build();
|
.build();*/
|
||||||
|
|
||||||
let viewport_bin = adw::Bin::builder()
|
let viewport_bin = adw::Bin::builder()
|
||||||
.child(&packages_no_viewport_page)
|
.child(&packages_no_viewport_page)
|
||||||
@ -182,7 +182,6 @@ pub fn apt_update_page(
|
|||||||
|
|
||||||
if window.is_visible() {
|
if window.is_visible() {
|
||||||
let retry_signal_action0 = retry_signal_action.clone();
|
let retry_signal_action0 = retry_signal_action.clone();
|
||||||
let viewport_bin = viewport_bin.clone();
|
|
||||||
let flatpak_retry_signal_action = flatpak_retry_signal_action.clone();
|
let flatpak_retry_signal_action = flatpak_retry_signal_action.clone();
|
||||||
let flatpak_ran_once = flatpak_ran_once.clone();
|
let flatpak_ran_once = flatpak_ran_once.clone();
|
||||||
|
|
||||||
@ -194,7 +193,7 @@ pub fn apt_update_page(
|
|||||||
retry_signal_action0.activate(None);
|
retry_signal_action0.activate(None);
|
||||||
}
|
}
|
||||||
"apt_update_dialog_ignore" => {
|
"apt_update_dialog_ignore" => {
|
||||||
viewport_bin.set_child(Some(&packages_ignored_viewport_page));
|
//viewport_bin.set_child(Some(&packages_ignored_viewport_page));
|
||||||
let mut flatpak_ran_once_borrow = flatpak_ran_once.borrow_mut();
|
let mut flatpak_ran_once_borrow = flatpak_ran_once.borrow_mut();
|
||||||
if *flatpak_ran_once_borrow != true {
|
if *flatpak_ran_once_borrow != true {
|
||||||
flatpak_retry_signal_action.activate(None);
|
flatpak_retry_signal_action.activate(None);
|
||||||
@ -292,66 +291,30 @@ pub fn apt_update_page(
|
|||||||
apt_update_dialog_child_box,
|
apt_update_dialog_child_box,
|
||||||
#[weak]
|
#[weak]
|
||||||
flatpak_retry_signal_action,
|
flatpak_retry_signal_action,
|
||||||
|
#[strong]
|
||||||
|
apt_update_count,
|
||||||
|
#[strong]
|
||||||
|
flatpak_update_count,
|
||||||
|
#[strong]
|
||||||
|
update_sys_tray,
|
||||||
async move {
|
async move {
|
||||||
while let Ok(state) = update_status_receiver.recv().await {
|
while let Ok(state) = update_status_receiver.recv().await {
|
||||||
match state.as_ref() {
|
match state.as_ref() {
|
||||||
"FN_OVERRIDE_SUCCESSFUL" => {
|
"FN_OVERRIDE_SUCCESSFUL" => {
|
||||||
let get_upgradable_sender = get_upgradable_sender.clone();
|
get_apt_upgrades(&get_upgradable_sender);
|
||||||
thread::spawn(move || {
|
|
||||||
// Create upgradable list cache
|
|
||||||
let upgradable_cache = new_cache!().unwrap();
|
|
||||||
//
|
|
||||||
upgradable_cache.upgrade(Upgrade::FullUpgrade).unwrap();
|
|
||||||
|
|
||||||
upgradable_cache.resolve(true).unwrap();
|
|
||||||
|
|
||||||
let mut upgradeable_iter =
|
|
||||||
upgradable_cache.get_changes(false).peekable();
|
|
||||||
while let Some(pkg) = upgradeable_iter.next() {
|
|
||||||
if !pkg.marked_delete() {
|
|
||||||
let candidate_version_pkg = pkg.candidate().unwrap();
|
|
||||||
let package_struct = AptPackageSocket {
|
|
||||||
name: pkg.name().to_string(),
|
|
||||||
arch: pkg.arch().to_string(),
|
|
||||||
installed_version: match pkg.installed() {
|
|
||||||
Some(t) => t.version().to_string(),
|
|
||||||
_ => {
|
|
||||||
t!("installed_version_to_be_installed").to_string()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
candidate_version: candidate_version_pkg
|
|
||||||
.version()
|
|
||||||
.to_string(),
|
|
||||||
description: match candidate_version_pkg.description() {
|
|
||||||
Some(s) => s,
|
|
||||||
_ => t!("apt_pkg_property_unknown").to_string(),
|
|
||||||
},
|
|
||||||
source_uri: candidate_version_pkg
|
|
||||||
.uris()
|
|
||||||
.collect::<Vec<String>>()
|
|
||||||
.join("\n"),
|
|
||||||
maintainer: match candidate_version_pkg
|
|
||||||
.get_record(RecordField::Maintainer)
|
|
||||||
{
|
|
||||||
Some(s) => s,
|
|
||||||
_ => t!("apt_pkg_property_unknown").to_string(),
|
|
||||||
},
|
|
||||||
size: candidate_version_pkg.size(),
|
|
||||||
installed_size: candidate_version_pkg.installed_size(),
|
|
||||||
is_last: upgradeable_iter.peek().is_none(),
|
|
||||||
};
|
|
||||||
get_upgradable_sender.send_blocking(package_struct).unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
apt_update_dialog.close();
|
apt_update_dialog.close();
|
||||||
let mut flatpak_ran_once_borrow = flatpak_ran_once.borrow_mut();
|
let mut flatpak_ran_once_borrow = flatpak_ran_once.borrow_mut();
|
||||||
if *flatpak_ran_once_borrow != true {
|
if *flatpak_ran_once_borrow != true {
|
||||||
flatpak_retry_signal_action.activate(None);
|
flatpak_retry_signal_action.activate(None);
|
||||||
*flatpak_ran_once_borrow = true;
|
*flatpak_ran_once_borrow = true;
|
||||||
}
|
}
|
||||||
|
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[
|
||||||
|
*apt_update_count.borrow(),
|
||||||
|
*flatpak_update_count.borrow(),
|
||||||
|
])));
|
||||||
}
|
}
|
||||||
"FN_OVERRIDE_FAILED" => {
|
"FN_OVERRIDE_FAILED" => {
|
||||||
|
get_apt_upgrades(&get_upgradable_sender);
|
||||||
apt_update_dialog_child_box.set_visible(false);
|
apt_update_dialog_child_box.set_visible(false);
|
||||||
apt_update_dialog.set_extra_child(Some(
|
apt_update_dialog.set_extra_child(Some(
|
||||||
&Image::builder()
|
&Image::builder()
|
||||||
@ -364,6 +327,15 @@ pub fn apt_update_page(
|
|||||||
.set_title(Some(&t!("apt_update_dialog_status_failed").to_string()));
|
.set_title(Some(&t!("apt_update_dialog_status_failed").to_string()));
|
||||||
apt_update_dialog.set_response_enabled("apt_update_dialog_retry", true);
|
apt_update_dialog.set_response_enabled("apt_update_dialog_retry", true);
|
||||||
apt_update_dialog.set_response_enabled("apt_update_dialog_ignore", true);
|
apt_update_dialog.set_response_enabled("apt_update_dialog_ignore", true);
|
||||||
|
let mut flatpak_ran_once_borrow = flatpak_ran_once.borrow_mut();
|
||||||
|
if *flatpak_ran_once_borrow != true {
|
||||||
|
flatpak_retry_signal_action.activate(None);
|
||||||
|
*flatpak_ran_once_borrow = true;
|
||||||
|
}
|
||||||
|
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[
|
||||||
|
*apt_update_count.borrow(),
|
||||||
|
*flatpak_update_count.borrow(),
|
||||||
|
])));
|
||||||
}
|
}
|
||||||
_ => apt_update_dialog.set_body(&state),
|
_ => apt_update_dialog.set_body(&state),
|
||||||
}
|
}
|
||||||
@ -535,3 +507,54 @@ fn set_all_apt_row_marks_to(parent_listbox: &impl IsA<ListBox>, value: bool) {
|
|||||||
child_counter = next_child
|
child_counter = next_child
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_apt_upgrades(get_upgradable_sender: &async_channel::Sender<AptPackageSocket>) {
|
||||||
|
let get_upgradable_sender = get_upgradable_sender.clone();
|
||||||
|
thread::spawn(move || {
|
||||||
|
// Create upgradable list cache
|
||||||
|
let upgradable_cache = new_cache!().unwrap();
|
||||||
|
//
|
||||||
|
upgradable_cache.upgrade(Upgrade::FullUpgrade).unwrap();
|
||||||
|
|
||||||
|
upgradable_cache.resolve(true).unwrap();
|
||||||
|
|
||||||
|
let mut upgradeable_iter =
|
||||||
|
upgradable_cache.get_changes(false).peekable();
|
||||||
|
while let Some(pkg) = upgradeable_iter.next() {
|
||||||
|
if !pkg.marked_delete() {
|
||||||
|
let candidate_version_pkg = pkg.candidate().unwrap();
|
||||||
|
let package_struct = AptPackageSocket {
|
||||||
|
name: pkg.name().to_string(),
|
||||||
|
arch: pkg.arch().to_string(),
|
||||||
|
installed_version: match pkg.installed() {
|
||||||
|
Some(t) => t.version().to_string(),
|
||||||
|
_ => {
|
||||||
|
t!("installed_version_to_be_installed").to_string()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
candidate_version: candidate_version_pkg
|
||||||
|
.version()
|
||||||
|
.to_string(),
|
||||||
|
description: match candidate_version_pkg.description() {
|
||||||
|
Some(s) => s,
|
||||||
|
_ => t!("apt_pkg_property_unknown").to_string(),
|
||||||
|
},
|
||||||
|
source_uri: candidate_version_pkg
|
||||||
|
.uris()
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join("\n"),
|
||||||
|
maintainer: match candidate_version_pkg
|
||||||
|
.get_record(RecordField::Maintainer)
|
||||||
|
{
|
||||||
|
Some(s) => s,
|
||||||
|
_ => t!("apt_pkg_property_unknown").to_string(),
|
||||||
|
},
|
||||||
|
size: candidate_version_pkg.size(),
|
||||||
|
installed_size: candidate_version_pkg.installed_size(),
|
||||||
|
is_last: upgradeable_iter.peek().is_none(),
|
||||||
|
};
|
||||||
|
get_upgradable_sender.send_blocking(package_struct).unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
@ -244,7 +244,7 @@ pub fn build_ui(app: &Application) {
|
|||||||
|
|
||||||
let window_breakpoint = adw::Breakpoint::new(BreakpointCondition::new_length(
|
let window_breakpoint = adw::Breakpoint::new(BreakpointCondition::new_length(
|
||||||
BreakpointConditionLengthType::MaxWidth,
|
BreakpointConditionLengthType::MaxWidth,
|
||||||
1140.0,
|
1000.0,
|
||||||
LengthUnit::Sp,
|
LengthUnit::Sp,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -192,12 +192,12 @@ pub fn flatpak_update_page(
|
|||||||
.vexpand(true)
|
.vexpand(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let packages_ignored_viewport_page = adw::StatusPage::builder()
|
/*let packages_ignored_viewport_page = adw::StatusPage::builder()
|
||||||
.icon_name("dialog-warning-symbolic")
|
.icon_name("dialog-warning-symbolic")
|
||||||
.title(t!("flatpak_ignored_viewport_page_title"))
|
.title(t!("flatpak_ignored_viewport_page_title"))
|
||||||
.hexpand(true)
|
.hexpand(true)
|
||||||
.vexpand(true)
|
.vexpand(true)
|
||||||
.build();
|
.build();*/
|
||||||
|
|
||||||
let viewport_bin = adw::Bin::builder()
|
let viewport_bin = adw::Bin::builder()
|
||||||
.child(&packages_no_viewport_page)
|
.child(&packages_no_viewport_page)
|
||||||
@ -247,7 +247,7 @@ pub fn flatpak_update_page(
|
|||||||
|
|
||||||
if window.is_visible() {
|
if window.is_visible() {
|
||||||
let retry_signal_action0 = retry_signal_action.clone();
|
let retry_signal_action0 = retry_signal_action.clone();
|
||||||
let viewport_bin = viewport_bin.clone();
|
//let viewport_bin = viewport_bin.clone();
|
||||||
|
|
||||||
flatpak_update_dialog
|
flatpak_update_dialog
|
||||||
.clone()
|
.clone()
|
||||||
@ -256,9 +256,9 @@ pub fn flatpak_update_page(
|
|||||||
"flatpak_update_dialog_retry" => {
|
"flatpak_update_dialog_retry" => {
|
||||||
retry_signal_action0.activate(None);
|
retry_signal_action0.activate(None);
|
||||||
}
|
}
|
||||||
"flatpak_update_dialog_ignore" => {
|
//"flatpak_update_dialog_ignore" => {
|
||||||
viewport_bin.set_child(Some(&packages_ignored_viewport_page));
|
// viewport_bin.set_child(Some(&packages_ignored_viewport_page));
|
||||||
}
|
//}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -380,7 +380,156 @@ pub fn flatpak_update_page(
|
|||||||
while let Ok(state) = appstream_sync_status_receiver.recv().await {
|
while let Ok(state) = appstream_sync_status_receiver.recv().await {
|
||||||
match state.as_ref() {
|
match state.as_ref() {
|
||||||
"FN_OVERRIDE_SUCCESSFUL" => {
|
"FN_OVERRIDE_SUCCESSFUL" => {
|
||||||
let flatpak_system_installation =
|
get_flatpak_updates(
|
||||||
|
cancellable_no,
|
||||||
|
&viewport_bin,
|
||||||
|
&update_button,
|
||||||
|
&select_button,
|
||||||
|
&packages_viewport,
|
||||||
|
&packages_boxedlist,
|
||||||
|
&system_refs_for_upgrade_vec,
|
||||||
|
&system_refs_for_upgrade_vec_all,
|
||||||
|
&user_refs_for_upgrade_vec,
|
||||||
|
&user_refs_for_upgrade_vec_all,
|
||||||
|
&update_sys_tray,
|
||||||
|
&apt_update_count,
|
||||||
|
&flatpak_update_count,
|
||||||
|
);
|
||||||
|
flatpak_update_dialog.close();
|
||||||
|
}
|
||||||
|
"FN_OVERRIDE_FAILED" => {
|
||||||
|
get_flatpak_updates(
|
||||||
|
cancellable_no,
|
||||||
|
&viewport_bin,
|
||||||
|
&update_button,
|
||||||
|
&select_button,
|
||||||
|
&packages_viewport,
|
||||||
|
&packages_boxedlist,
|
||||||
|
&system_refs_for_upgrade_vec,
|
||||||
|
&system_refs_for_upgrade_vec_all,
|
||||||
|
&user_refs_for_upgrade_vec,
|
||||||
|
&user_refs_for_upgrade_vec_all,
|
||||||
|
&update_sys_tray,
|
||||||
|
&apt_update_count,
|
||||||
|
&flatpak_update_count,
|
||||||
|
);
|
||||||
|
flatpak_update_dialog_child_box.set_visible(false);
|
||||||
|
flatpak_update_dialog.set_extra_child(Some(
|
||||||
|
&Image::builder()
|
||||||
|
.pixel_size(128)
|
||||||
|
.icon_name("dialog-error-symbolic")
|
||||||
|
.halign(Align::Center)
|
||||||
|
.build(),
|
||||||
|
));
|
||||||
|
flatpak_update_dialog.set_title(Some(
|
||||||
|
&t!("flatpak_update_dialog_status_failed").to_string(),
|
||||||
|
));
|
||||||
|
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_body(&state),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
searchbar.connect_search_changed(clone!(
|
||||||
|
#[weak]
|
||||||
|
searchbar,
|
||||||
|
#[weak]
|
||||||
|
packages_boxedlist,
|
||||||
|
move |_| {
|
||||||
|
let mut counter = packages_boxedlist.first_child();
|
||||||
|
while let Some(row) = counter {
|
||||||
|
if row.widget_name() == "FlatpakRefRow" {
|
||||||
|
if !searchbar.text().is_empty() {
|
||||||
|
if row
|
||||||
|
.property::<String>("flatref-name")
|
||||||
|
.to_lowercase()
|
||||||
|
.contains(&searchbar.text().to_string().to_lowercase())
|
||||||
|
|| row
|
||||||
|
.property::<String>("flatref-ref-name")
|
||||||
|
.to_lowercase()
|
||||||
|
.contains(&searchbar.text().to_string().to_lowercase())
|
||||||
|
{
|
||||||
|
row.set_property("visible", true);
|
||||||
|
searchbar.grab_focus();
|
||||||
|
} else {
|
||||||
|
row.set_property("visible", false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row.set_property("visible", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
counter = row.next_sibling();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
main_box.append(&searchbar);
|
||||||
|
main_box.append(&viewport_bin);
|
||||||
|
main_box.append(&bottom_bar);
|
||||||
|
|
||||||
|
main_box
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_widget_select_all_ready(parent_listbox: &impl adw::prelude::IsA<ListBox>) -> bool {
|
||||||
|
let mut is_ready = false;
|
||||||
|
let mut child_counter = parent_listbox.borrow().first_child();
|
||||||
|
while let Some(child) = child_counter {
|
||||||
|
let next_child = child.next_sibling();
|
||||||
|
let downcast = child.downcast::<FlatpakRefRow>().unwrap();
|
||||||
|
if !downcast.flatref_marked() {
|
||||||
|
is_ready = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
child_counter = next_child
|
||||||
|
}
|
||||||
|
is_ready
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_all_children_unmarked(parent_listbox: &impl adw::prelude::IsA<ListBox>) -> bool {
|
||||||
|
let mut is_all_unmarked = true;
|
||||||
|
let mut child_counter = parent_listbox.borrow().first_child();
|
||||||
|
while let Some(child) = child_counter {
|
||||||
|
let next_child = child.next_sibling();
|
||||||
|
let downcast = child.downcast::<FlatpakRefRow>().unwrap();
|
||||||
|
if downcast.flatref_marked() {
|
||||||
|
is_all_unmarked = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
child_counter = next_child
|
||||||
|
}
|
||||||
|
is_all_unmarked
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_all_flatpak_row_marks_to(parent_listbox: &impl adw::prelude::IsA<ListBox>, value: bool) {
|
||||||
|
let mut child_counter = parent_listbox.borrow().first_child();
|
||||||
|
while let Some(child) = child_counter {
|
||||||
|
let next_child = child.next_sibling();
|
||||||
|
let downcast = child.downcast::<FlatpakRefRow>().unwrap();
|
||||||
|
downcast.set_flatref_marked(value);
|
||||||
|
child_counter = next_child
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn get_flatpak_updates(
|
||||||
|
cancellable_no: Option<&libflatpak::gio::Cancellable>,
|
||||||
|
viewport_bin: &adw::Bin,
|
||||||
|
update_button: >k::Button,
|
||||||
|
select_button: >k::Button,
|
||||||
|
packages_viewport: >k::ScrolledWindow,
|
||||||
|
packages_boxedlist: >k::ListBox,
|
||||||
|
system_refs_for_upgrade_vec: &Rc<RefCell<Vec<FlatpakRefRow>>>,
|
||||||
|
system_refs_for_upgrade_vec_all: &Rc<RefCell<Vec<FlatpakRefRow>>>,
|
||||||
|
user_refs_for_upgrade_vec: &Rc<RefCell<Vec<FlatpakRefRow>>>,
|
||||||
|
user_refs_for_upgrade_vec_all: &Rc<RefCell<Vec<FlatpakRefRow>>>,
|
||||||
|
update_sys_tray: &SimpleAction,
|
||||||
|
apt_update_count: &Rc<RefCell<i32>>,
|
||||||
|
flatpak_update_count: &Rc<RefCell<i32>>,
|
||||||
|
) {
|
||||||
|
let flatpak_system_installation =
|
||||||
libflatpak::Installation::new_system(cancellable_no).unwrap();
|
libflatpak::Installation::new_system(cancellable_no).unwrap();
|
||||||
let flatpak_system_updates = flatpak_system_installation
|
let flatpak_system_updates = flatpak_system_installation
|
||||||
.list_installed_refs_for_update(cancellable_no)
|
.list_installed_refs_for_update(cancellable_no)
|
||||||
@ -397,7 +546,7 @@ pub fn flatpak_update_page(
|
|||||||
//
|
//
|
||||||
if !flatpak_system_updates.is_empty() || !flatpak_user_updates.is_empty() {
|
if !flatpak_system_updates.is_empty() || !flatpak_user_updates.is_empty() {
|
||||||
update_button.set_sensitive(true);
|
update_button.set_sensitive(true);
|
||||||
viewport_bin.set_child(Some(&packages_viewport));
|
viewport_bin.set_child(Some(packages_viewport));
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if !flatpak_system_updates.is_empty() {
|
if !flatpak_system_updates.is_empty() {
|
||||||
@ -713,107 +862,4 @@ pub fn flatpak_update_page(
|
|||||||
&[*apt_update_count.borrow(), *flatpak_update_count.borrow()],
|
&[*apt_update_count.borrow(), *flatpak_update_count.borrow()],
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
flatpak_update_dialog.close();
|
|
||||||
}
|
|
||||||
"FN_OVERRIDE_FAILED" => {
|
|
||||||
flatpak_update_dialog_child_box.set_visible(false);
|
|
||||||
flatpak_update_dialog.set_extra_child(Some(
|
|
||||||
&Image::builder()
|
|
||||||
.pixel_size(128)
|
|
||||||
.icon_name("dialog-error-symbolic")
|
|
||||||
.halign(Align::Center)
|
|
||||||
.build(),
|
|
||||||
));
|
|
||||||
flatpak_update_dialog.set_title(Some(
|
|
||||||
&t!("flatpak_update_dialog_status_failed").to_string(),
|
|
||||||
));
|
|
||||||
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_body(&state),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
));
|
|
||||||
|
|
||||||
searchbar.connect_search_changed(clone!(
|
|
||||||
#[weak]
|
|
||||||
searchbar,
|
|
||||||
#[weak]
|
|
||||||
packages_boxedlist,
|
|
||||||
move |_| {
|
|
||||||
let mut counter = packages_boxedlist.first_child();
|
|
||||||
while let Some(row) = counter {
|
|
||||||
if row.widget_name() == "FlatpakRefRow" {
|
|
||||||
if !searchbar.text().is_empty() {
|
|
||||||
if row
|
|
||||||
.property::<String>("flatref-name")
|
|
||||||
.to_lowercase()
|
|
||||||
.contains(&searchbar.text().to_string().to_lowercase())
|
|
||||||
|| row
|
|
||||||
.property::<String>("flatref-ref-name")
|
|
||||||
.to_lowercase()
|
|
||||||
.contains(&searchbar.text().to_string().to_lowercase())
|
|
||||||
{
|
|
||||||
row.set_property("visible", true);
|
|
||||||
searchbar.grab_focus();
|
|
||||||
} else {
|
|
||||||
row.set_property("visible", false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
row.set_property("visible", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
counter = row.next_sibling();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
));
|
|
||||||
|
|
||||||
main_box.append(&searchbar);
|
|
||||||
main_box.append(&viewport_bin);
|
|
||||||
main_box.append(&bottom_bar);
|
|
||||||
|
|
||||||
main_box
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_widget_select_all_ready(parent_listbox: &impl adw::prelude::IsA<ListBox>) -> bool {
|
|
||||||
let mut is_ready = false;
|
|
||||||
let mut child_counter = parent_listbox.borrow().first_child();
|
|
||||||
while let Some(child) = child_counter {
|
|
||||||
let next_child = child.next_sibling();
|
|
||||||
let downcast = child.downcast::<FlatpakRefRow>().unwrap();
|
|
||||||
if !downcast.flatref_marked() {
|
|
||||||
is_ready = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
child_counter = next_child
|
|
||||||
}
|
|
||||||
is_ready
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_all_children_unmarked(parent_listbox: &impl adw::prelude::IsA<ListBox>) -> bool {
|
|
||||||
let mut is_all_unmarked = true;
|
|
||||||
let mut child_counter = parent_listbox.borrow().first_child();
|
|
||||||
while let Some(child) = child_counter {
|
|
||||||
let next_child = child.next_sibling();
|
|
||||||
let downcast = child.downcast::<FlatpakRefRow>().unwrap();
|
|
||||||
if downcast.flatref_marked() {
|
|
||||||
is_all_unmarked = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
child_counter = next_child
|
|
||||||
}
|
|
||||||
is_all_unmarked
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_all_flatpak_row_marks_to(parent_listbox: &impl adw::prelude::IsA<ListBox>, value: bool) {
|
|
||||||
let mut child_counter = parent_listbox.borrow().first_child();
|
|
||||||
while let Some(child) = child_counter {
|
|
||||||
let next_child = child.next_sibling();
|
|
||||||
let downcast = child.downcast::<FlatpakRefRow>().unwrap();
|
|
||||||
downcast.set_flatref_marked(value);
|
|
||||||
child_counter = next_child
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,14 +8,16 @@ use tokio::runtime::Runtime;
|
|||||||
pub struct AptInstallProgressSocket<'a> {
|
pub struct AptInstallProgressSocket<'a> {
|
||||||
percent_socket_path: &'a str,
|
percent_socket_path: &'a str,
|
||||||
status_socket_path: &'a str,
|
status_socket_path: &'a str,
|
||||||
|
error_strfmt_trans_str: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AptInstallProgressSocket<'a> {
|
impl<'a> AptInstallProgressSocket<'a> {
|
||||||
/// Returns a new default progress instance.
|
/// Returns a new default progress instance.
|
||||||
pub fn new(percent_socket_path: &'a str, status_socket_path: &'a str) -> Self {
|
pub fn new(percent_socket_path: &'a str, status_socket_path: &'a str, error_strfmt_trans_str: &'a str) -> Self {
|
||||||
let progress = Self {
|
let progress = Self {
|
||||||
percent_socket_path: percent_socket_path,
|
percent_socket_path: percent_socket_path,
|
||||||
status_socket_path: status_socket_path,
|
status_socket_path: status_socket_path,
|
||||||
|
error_strfmt_trans_str: error_strfmt_trans_str,
|
||||||
};
|
};
|
||||||
progress
|
progress
|
||||||
}
|
}
|
||||||
@ -40,7 +42,14 @@ impl<'a> DynInstallProgress for AptInstallProgressSocket<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn error(&mut self, pkgname: String, _steps_done: u64, _total_steps: u64, error: String) {
|
fn error(&mut self, pkgname: String, _steps_done: u64, _total_steps: u64, error: String) {
|
||||||
let message = format!("dpkg failure on {}: {}", pkgname, error);
|
let message = &strfmt::strfmt(
|
||||||
|
&self.error_strfmt_trans_str,
|
||||||
|
&std::collections::HashMap::from([
|
||||||
|
("PKGNAME".to_string(), pkgname),
|
||||||
|
("ERROR".to_string(), error),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
eprintln!("{}", &message);
|
eprintln!("{}", &message);
|
||||||
Runtime::new()
|
Runtime::new()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -10,15 +10,23 @@ pub struct AptUpdateProgressSocket<'a> {
|
|||||||
pulse_interval: usize,
|
pulse_interval: usize,
|
||||||
percent_socket_path: &'a str,
|
percent_socket_path: &'a str,
|
||||||
status_socket_path: &'a str,
|
status_socket_path: &'a str,
|
||||||
|
hit_strfmt_trans_str: &'a str,
|
||||||
|
fetch_strfmt_trans_str: &'a str,
|
||||||
|
done_strfmt_trans_str: &'a str,
|
||||||
|
fail_strfmt_trans_str: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AptUpdateProgressSocket<'a> {
|
impl<'a> AptUpdateProgressSocket<'a> {
|
||||||
/// Returns a new default progress instance.
|
/// Returns a new default progress instance.
|
||||||
pub fn new(percent_socket_path: &'a str, status_socket_path: &'a str) -> Self {
|
pub fn new(percent_socket_path: &'a str, status_socket_path: &'a str, hit_strfmt_trans_str: &'a str, fetch_strfmt_trans_str: &'a str, done_strfmt_trans_str: &'a str, fail_strfmt_trans_str: &'a str) -> Self {
|
||||||
let progress = Self {
|
let progress = Self {
|
||||||
pulse_interval: 0,
|
pulse_interval: 0,
|
||||||
percent_socket_path: percent_socket_path,
|
percent_socket_path: percent_socket_path,
|
||||||
status_socket_path: status_socket_path,
|
status_socket_path: status_socket_path,
|
||||||
|
hit_strfmt_trans_str: hit_strfmt_trans_str,
|
||||||
|
fetch_strfmt_trans_str: fetch_strfmt_trans_str,
|
||||||
|
done_strfmt_trans_str: done_strfmt_trans_str,
|
||||||
|
fail_strfmt_trans_str: fail_strfmt_trans_str,
|
||||||
};
|
};
|
||||||
progress
|
progress
|
||||||
}
|
}
|
||||||
@ -44,7 +52,14 @@ impl<'a> DynAcquireProgress for AptUpdateProgressSocket<'a> {
|
|||||||
///
|
///
|
||||||
/// Prints out the short description and the expected size.
|
/// Prints out the short description and the expected size.
|
||||||
fn hit(&mut self, item: &ItemDesc) {
|
fn hit(&mut self, item: &ItemDesc) {
|
||||||
let message = format!("Up-to-date: {} {}", item.description(), item.short_desc());
|
let message = &strfmt::strfmt(
|
||||||
|
&self.hit_strfmt_trans_str,
|
||||||
|
&std::collections::HashMap::from([
|
||||||
|
("DESC".to_string(), item.description()),
|
||||||
|
("SHORT_DESC".to_string(), item.short_desc()),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
println!("{}", message);
|
println!("{}", message);
|
||||||
Runtime::new()
|
Runtime::new()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -55,7 +70,14 @@ impl<'a> DynAcquireProgress for AptUpdateProgressSocket<'a> {
|
|||||||
///
|
///
|
||||||
/// Prints out the short description and the expected size.
|
/// Prints out the short description and the expected size.
|
||||||
fn fetch(&mut self, item: &ItemDesc) {
|
fn fetch(&mut self, item: &ItemDesc) {
|
||||||
let message = format!("Fetching: {} {}", item.description(), item.short_desc());
|
let message = &strfmt::strfmt(
|
||||||
|
&self.fetch_strfmt_trans_str,
|
||||||
|
&std::collections::HashMap::from([
|
||||||
|
("DESC".to_string(), item.description()),
|
||||||
|
("SHORT_DESC".to_string(), item.short_desc()),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
println!("{}", message);
|
println!("{}", message);
|
||||||
Runtime::new()
|
Runtime::new()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -66,7 +88,14 @@ impl<'a> DynAcquireProgress for AptUpdateProgressSocket<'a> {
|
|||||||
///
|
///
|
||||||
/// We don't print anything here to remain consistent with apt.
|
/// We don't print anything here to remain consistent with apt.
|
||||||
fn done(&mut self, item: &ItemDesc) {
|
fn done(&mut self, item: &ItemDesc) {
|
||||||
let message = format!("Downloading: {} {}", item.description(), item.short_desc());
|
let message = &strfmt::strfmt(
|
||||||
|
&self.done_strfmt_trans_str,
|
||||||
|
&std::collections::HashMap::from([
|
||||||
|
("DESC".to_string(), item.description()),
|
||||||
|
("SHORT_DESC".to_string(), item.short_desc()),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
println!("{}", message);
|
println!("{}", message);
|
||||||
Runtime::new()
|
Runtime::new()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -91,11 +120,14 @@ impl<'a> DynAcquireProgress for AptUpdateProgressSocket<'a> {
|
|||||||
///
|
///
|
||||||
/// Print out the ErrorText for the Item.
|
/// Print out the ErrorText for the Item.
|
||||||
fn fail(&mut self, item: &ItemDesc) {
|
fn fail(&mut self, item: &ItemDesc) {
|
||||||
let message = format!(
|
let message = &strfmt::strfmt(
|
||||||
"Download Failed: {} {}",
|
&self.fail_strfmt_trans_str,
|
||||||
item.description(),
|
&std::collections::HashMap::from([
|
||||||
item.short_desc()
|
("DESC".to_string(), item.description()),
|
||||||
);
|
("SHORT_DESC".to_string(), item.short_desc()),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
eprintln!("{}", &message);
|
eprintln!("{}", &message);
|
||||||
Runtime::new()
|
Runtime::new()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
Loading…
Reference in New Issue
Block a user