fix break points

This commit is contained in:
Ward from fusion-voyager-3 2024-10-06 22:36:48 +03:00
parent 650093da67
commit e33e800131
9 changed files with 360 additions and 393 deletions

View File

@ -1 +1 @@
11 12

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
pikman-update-manager (1.0.1-100pika2) pikauwu; urgency=medium pikman-update-manager (1.0.1-100pika3) pikauwu; urgency=medium
* initial release * initial release

View File

@ -4,8 +4,8 @@ use pika_unixsocket_tools::pika_unixsocket_tools::*;
use rust_apt::cache::Upgrade; 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 std::env; use std::env;
use tokio::runtime::Runtime;
// Init translations for current crate. // Init translations for current crate.
#[macro_use] #[macro_use]
@ -82,7 +82,7 @@ fn main() {
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, error_strfmt_trans_str,
)); ));
apt_upgrade_cache.resolve(true).unwrap(); apt_upgrade_cache.resolve(true).unwrap();

View File

@ -2,8 +2,8 @@ use pika_unixsocket_tools::apt_update_progress_socket::AptUpdateProgressSocket;
use pika_unixsocket_tools::pika_unixsocket_tools::*; 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 std::env; use std::env;
use tokio::runtime::Runtime;
// Init translations for current crate. // Init translations for current crate.
#[macro_use] #[macro_use]

View File

@ -66,7 +66,10 @@ 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", "fr_FR"]) .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() {
@ -518,8 +521,7 @@ fn get_apt_upgrades(get_upgradable_sender: &async_channel::Sender<AptPackageSock
upgradable_cache.resolve(true).unwrap(); upgradable_cache.resolve(true).unwrap();
let mut upgradeable_iter = let mut upgradeable_iter = upgradable_cache.get_changes(false).peekable();
upgradable_cache.get_changes(false).peekable();
while let Some(pkg) = upgradeable_iter.next() { while let Some(pkg) = upgradeable_iter.next() {
if !pkg.marked_delete() { if !pkg.marked_delete() {
let candidate_version_pkg = pkg.candidate().unwrap(); let candidate_version_pkg = pkg.candidate().unwrap();
@ -528,13 +530,9 @@ fn get_apt_upgrades(get_upgradable_sender: &async_channel::Sender<AptPackageSock
arch: pkg.arch().to_string(), arch: pkg.arch().to_string(),
installed_version: match pkg.installed() { installed_version: match pkg.installed() {
Some(t) => t.version().to_string(), Some(t) => t.version().to_string(),
_ => { _ => t!("installed_version_to_be_installed").to_string(),
t!("installed_version_to_be_installed").to_string()
}
}, },
candidate_version: candidate_version_pkg candidate_version: candidate_version_pkg.version().to_string(),
.version()
.to_string(),
description: match candidate_version_pkg.description() { description: match candidate_version_pkg.description() {
Some(s) => s, Some(s) => s,
_ => t!("apt_pkg_property_unknown").to_string(), _ => t!("apt_pkg_property_unknown").to_string(),
@ -543,9 +541,7 @@ fn get_apt_upgrades(get_upgradable_sender: &async_channel::Sender<AptPackageSock
.uris() .uris()
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join("\n"), .join("\n"),
maintainer: match candidate_version_pkg maintainer: match candidate_version_pkg.get_record(RecordField::Maintainer) {
.get_record(RecordField::Maintainer)
{
Some(s) => s, Some(s) => s,
_ => t!("apt_pkg_property_unknown").to_string(), _ => t!("apt_pkg_property_unknown").to_string(),
}, },

View File

@ -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,
1000.0, 1200.0,
LengthUnit::Sp, LengthUnit::Sp,
)); ));
@ -296,12 +296,12 @@ pub fn build_ui(app: &Application) {
.build(); .build();
let window_content_page_split_view = adw::OverlaySplitView::builder() let window_content_page_split_view = adw::OverlaySplitView::builder()
.vexpand(true)
.hexpand(true)
.content(&window_toolbar) .content(&window_toolbar)
.sidebar(&window_adw_view_switcher_sidebar_box) .sidebar(&window_adw_view_switcher_sidebar_box)
.max_sidebar_width(300.0) .max_sidebar_width(300.0)
.min_sidebar_width(300.0) .min_sidebar_width(290.0)
.sidebar_width_unit(adw::LengthUnit::Px)
.sidebar_width_fraction(0.2)
.enable_hide_gesture(true) .enable_hide_gesture(true)
.enable_show_gesture(true) .enable_show_gesture(true)
.build(); .build();
@ -338,7 +338,7 @@ pub fn build_ui(app: &Application) {
.default_width(glib_settings.int("window-width")) .default_width(glib_settings.int("window-width"))
.default_height(glib_settings.int("window-height")) .default_height(glib_settings.int("window-height"))
// //
.width_request(900) .width_request(1000)
.height_request(700) .height_request(700)
.content(&window_content_page_split_view) .content(&window_content_page_split_view)
// Startup // Startup
@ -664,7 +664,8 @@ pub fn build_ui(app: &Application) {
} }
} }
ConstantLoopMessage::RefreshRequest => { ConstantLoopMessage::RefreshRequest => {
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[-1, -1]))); update_sys_tray
.activate(Some(&glib::Variant::array_from_fixed_array(&[-1, -1])));
apt_retry_signal_action.activate(None); apt_retry_signal_action.activate(None);
flatpak_retry_signal_action.activate(None); flatpak_retry_signal_action.activate(None);
} }

View File

@ -529,14 +529,12 @@ fn get_flatpak_updates(
apt_update_count: &Rc<RefCell<i32>>, apt_update_count: &Rc<RefCell<i32>>,
flatpak_update_count: &Rc<RefCell<i32>>, flatpak_update_count: &Rc<RefCell<i32>>,
) { ) {
let flatpak_system_installation = 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)
.unwrap(); .unwrap();
// //
let flatpak_user_installation = let flatpak_user_installation = libflatpak::Installation::new_user(cancellable_no).unwrap();
libflatpak::Installation::new_user(cancellable_no).unwrap();
let flatpak_user_updates = flatpak_user_installation let flatpak_user_updates = flatpak_user_installation
.list_installed_refs_for_update(cancellable_no) .list_installed_refs_for_update(cancellable_no)
.unwrap(); .unwrap();
@ -550,15 +548,13 @@ fn get_flatpak_updates(
} }
// //
if !flatpak_system_updates.is_empty() { if !flatpak_system_updates.is_empty() {
let flatpak_system_updates_iter = let flatpak_system_updates_iter = &mut flatpak_system_updates.iter().peekable();
&mut flatpak_system_updates.iter().peekable();
// //
while let Some(flatpak_ref) = flatpak_system_updates_iter.next() { while let Some(flatpak_ref) = flatpak_system_updates_iter.next() {
let mut remote_flatpak_ref: Option<libflatpak::RemoteRef> = None; let mut remote_flatpak_ref: Option<libflatpak::RemoteRef> = None;
while let Ok(remotes) = libflatpak::Installation::list_remotes( while let Ok(remotes) =
&flatpak_system_installation, libflatpak::Installation::list_remotes(&flatpak_system_installation, cancellable_no)
cancellable_no, {
) {
for remote in remotes { for remote in remotes {
if remote.is_disabled() { if remote.is_disabled() {
continue; continue;
@ -590,10 +586,7 @@ fn get_flatpak_updates(
} }
} }
let flatref_struct = FlatpakRefStruct { let flatref_struct = FlatpakRefStruct {
ref_name: flatpak_ref ref_name: flatpak_ref.name().unwrap_or("Unknown".into()).to_string(),
.name()
.unwrap_or("Unknown".into())
.to_string(),
name: flatpak_ref name: flatpak_ref
.appdata_name() .appdata_name()
.unwrap_or(flatpak_ref.name().unwrap_or("Unknown".into())) .unwrap_or(flatpak_ref.name().unwrap_or("Unknown".into()))
@ -607,9 +600,7 @@ fn get_flatpak_updates(
.unwrap_or("No Summary".into()) .unwrap_or("No Summary".into())
.to_string(), .to_string(),
remote_name: match remote_flatpak_ref { remote_name: match remote_flatpak_ref {
Some(ref t) => { Some(ref t) => t.remote_name().unwrap_or("Unknown".into()).to_string(),
t.remote_name().unwrap_or("Unknown".into()).to_string()
}
None => "Unknown".into(), None => "Unknown".into(),
}, },
installed_size_installed: flatpak_ref.installed_size(), installed_size_installed: flatpak_ref.installed_size(),
@ -650,20 +641,12 @@ fn get_flatpak_updates(
system_refs_for_upgrade_vec, system_refs_for_upgrade_vec,
move |flatpak_row: FlatpakRefRow| { move |flatpak_row: FlatpakRefRow| {
if is_widget_select_all_ready(&packages_boxedlist) { if is_widget_select_all_ready(&packages_boxedlist) {
select_button.set_label( select_button.set_label(&t!("select_button_select_all").to_string());
&t!("select_button_select_all").to_string(),
);
} else { } else {
select_button.set_label( select_button.set_label(&t!("select_button_deselect_all").to_string());
&t!("select_button_deselect_all").to_string(),
);
} }
update_button.set_sensitive(!is_all_children_unmarked( update_button.set_sensitive(!is_all_children_unmarked(&packages_boxedlist));
&packages_boxedlist, system_refs_for_upgrade_vec.borrow_mut().push(flatpak_row);
));
system_refs_for_upgrade_vec
.borrow_mut()
.push(flatpak_row);
} }
), ),
); );
@ -680,16 +663,11 @@ fn get_flatpak_updates(
#[strong] #[strong]
system_refs_for_upgrade_vec, system_refs_for_upgrade_vec,
move |flatpak_row: FlatpakRefRow| { move |flatpak_row: FlatpakRefRow| {
select_button.set_label( select_button.set_label(&t!("select_button_select_all").to_string());
&t!("select_button_select_all").to_string(), update_button.set_sensitive(!is_all_children_unmarked(&packages_boxedlist));
); system_refs_for_upgrade_vec
update_button.set_sensitive(!is_all_children_unmarked( .borrow_mut()
&packages_boxedlist, .retain(|x| x.flatref_ref_format() != flatpak_row.flatref_ref_format());
));
system_refs_for_upgrade_vec.borrow_mut().retain(|x| {
x.flatref_ref_format()
!= flatpak_row.flatref_ref_format()
});
} }
), ),
); );
@ -704,15 +682,13 @@ fn get_flatpak_updates(
system_last_triggered = true system_last_triggered = true
} }
if !flatpak_user_updates.is_empty() { if !flatpak_user_updates.is_empty() {
let flatpak_user_updates_iter = let flatpak_user_updates_iter = &mut flatpak_user_updates.iter().peekable();
&mut flatpak_user_updates.iter().peekable();
// //
while let Some(flatpak_ref) = flatpak_user_updates_iter.next() { while let Some(flatpak_ref) = flatpak_user_updates_iter.next() {
let mut remote_flatpak_ref: Option<libflatpak::RemoteRef> = None; let mut remote_flatpak_ref: Option<libflatpak::RemoteRef> = None;
while let Ok(remotes) = libflatpak::Installation::list_remotes( while let Ok(remotes) =
&flatpak_user_installation, libflatpak::Installation::list_remotes(&flatpak_user_installation, cancellable_no)
cancellable_no, {
) {
for remote in remotes { for remote in remotes {
if remote.is_disabled() { if remote.is_disabled() {
continue; continue;
@ -744,10 +720,7 @@ fn get_flatpak_updates(
} }
} }
let flatref_struct = FlatpakRefStruct { let flatref_struct = FlatpakRefStruct {
ref_name: flatpak_ref ref_name: flatpak_ref.name().unwrap_or("Unknown".into()).to_string(),
.name()
.unwrap_or("Unknown".into())
.to_string(),
name: flatpak_ref name: flatpak_ref
.appdata_name() .appdata_name()
.unwrap_or(flatpak_ref.name().unwrap_or("Unknown".into())) .unwrap_or(flatpak_ref.name().unwrap_or("Unknown".into()))
@ -761,9 +734,7 @@ fn get_flatpak_updates(
.unwrap_or("No Summary".into()) .unwrap_or("No Summary".into())
.to_string(), .to_string(),
remote_name: match remote_flatpak_ref { remote_name: match remote_flatpak_ref {
Some(ref t) => { Some(ref t) => t.remote_name().unwrap_or("Unknown".into()).to_string(),
t.remote_name().unwrap_or("Unknown".into()).to_string()
}
None => "Unknown".into(), None => "Unknown".into(),
}, },
installed_size_installed: flatpak_ref.installed_size(), installed_size_installed: flatpak_ref.installed_size(),
@ -804,20 +775,12 @@ fn get_flatpak_updates(
user_refs_for_upgrade_vec, user_refs_for_upgrade_vec,
move |flatpak_row: FlatpakRefRow| { move |flatpak_row: FlatpakRefRow| {
if is_widget_select_all_ready(&packages_boxedlist) { if is_widget_select_all_ready(&packages_boxedlist) {
select_button.set_label( select_button.set_label(&t!("select_button_select_all").to_string());
&t!("select_button_select_all").to_string(),
);
} else { } else {
select_button.set_label( select_button.set_label(&t!("select_button_deselect_all").to_string());
&t!("select_button_deselect_all").to_string(),
);
} }
update_button.set_sensitive(!is_all_children_unmarked( update_button.set_sensitive(!is_all_children_unmarked(&packages_boxedlist));
&packages_boxedlist, user_refs_for_upgrade_vec.borrow_mut().push(flatpak_row);
));
user_refs_for_upgrade_vec
.borrow_mut()
.push(flatpak_row);
} }
), ),
); );
@ -834,16 +797,11 @@ fn get_flatpak_updates(
#[strong] #[strong]
user_refs_for_upgrade_vec, user_refs_for_upgrade_vec,
move |flatpak_row: FlatpakRefRow| { move |flatpak_row: FlatpakRefRow| {
select_button.set_label( select_button.set_label(&t!("select_button_select_all").to_string());
&t!("select_button_select_all").to_string(), update_button.set_sensitive(!is_all_children_unmarked(&packages_boxedlist));
); user_refs_for_upgrade_vec
update_button.set_sensitive(!is_all_children_unmarked( .borrow_mut()
&packages_boxedlist, .retain(|x| x.flatref_ref_format() != flatpak_row.flatref_ref_format());
));
user_refs_for_upgrade_vec.borrow_mut().retain(|x| {
x.flatref_ref_format()
!= flatpak_row.flatref_ref_format()
});
} }
), ),
); );
@ -858,8 +816,9 @@ fn get_flatpak_updates(
} }
if user_last_triggered && system_last_triggered { if user_last_triggered && system_last_triggered {
packages_boxedlist.set_sensitive(true); packages_boxedlist.set_sensitive(true);
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array( update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[
&[*apt_update_count.borrow(), *flatpak_update_count.borrow()], *apt_update_count.borrow(),
))); *flatpak_update_count.borrow(),
])));
} }
} }

View File

@ -8,12 +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, error_strfmt_trans_str: String,
} }
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, error_strfmt_trans_str: &'a str) -> Self { pub fn new(
percent_socket_path: &'a str,
status_socket_path: &'a str,
error_strfmt_trans_str: String,
) -> 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,

View File

@ -18,7 +18,14 @@ pub struct AptUpdateProgressSocket<'a> {
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, 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 { 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,