Compare commits

..

No commits in common. "f33d2254f0c9429d454987b87994c03318c3237f" and "650093da6721edb5b54938296a9d484931f9ae49" have entirely different histories.

12 changed files with 414 additions and 457 deletions

View File

@ -1 +1 @@
13
11

44
Cargo.lock generated
View File

@ -526,7 +526,7 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
dependencies = [
"memoffset 0.9.1",
"memoffset",
"rustc_version 0.4.0",
]
@ -1441,15 +1441,6 @@ version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "memoffset"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
dependencies = [
"autocfg",
]
[[package]]
name = "memoffset"
version = "0.9.1"
@ -1555,19 +1546,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "nix"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c"
dependencies = [
"bitflags 1.3.2",
"cc",
"cfg-if 1.0.0",
"libc",
"memoffset 0.6.5",
]
[[package]]
name = "normpath"
version = "1.2.0"
@ -1781,7 +1759,6 @@ dependencies = [
"rust-i18n",
"serde",
"serde_json",
"single-instance",
"strfmt",
"tokio",
"tokio-uds",
@ -2246,19 +2223,6 @@ dependencies = [
"libc",
]
[[package]]
name = "single-instance"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4637485391f8545c9d3dbf60f9d9aab27a90c789a700999677583bcb17c8795d"
dependencies = [
"libc",
"nix",
"thiserror",
"widestring",
"winapi 0.3.9",
]
[[package]]
name = "slab"
version = "0.4.9"
@ -2899,12 +2863,6 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "widestring"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
[[package]]
name = "winapi"
version = "0.2.8"

View File

@ -45,5 +45,4 @@ reqwest = { version = "0.11", features = ["blocking"] }
strfmt = "0.2.4"
configparser = "3.1.0"
ksni = "0.2.2"
single-instance = "0.3.3"

2
debian/changelog vendored
View File

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

View File

@ -4,8 +4,8 @@ use pika_unixsocket_tools::pika_unixsocket_tools::*;
use rust_apt::cache::Upgrade;
use rust_apt::new_cache;
use rust_apt::progress::{AcquireProgress, InstallProgress};
use std::env;
use tokio::runtime::Runtime;
use std::env;
// Init translations for current crate.
#[macro_use]
@ -82,7 +82,7 @@ fn main() {
let mut install_progress = InstallProgress::new(AptInstallProgressSocket::new(
percent_socket_path,
status_socket_path,
error_strfmt_trans_str,
&error_strfmt_trans_str,
));
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 rust_apt::new_cache;
use rust_apt::progress::AcquireProgress;
use std::env;
use tokio::runtime::Runtime;
use std::env;
// Init translations for current crate.
#[macro_use]
@ -13,10 +13,6 @@ i18n!("locales", fallback = "en_US");
fn main() {
let args: Vec<String> = env::args().collect();
rust_i18n::set_locale(&args[1]);
let instance = single_instance::SingleInstance::new(
"com.github.pikaos-linux.pikmanupdatemanager.update.manager",
)
.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();
@ -45,6 +41,4 @@ fn main() {
panic!("{}", e.to_string())
}
};
assert!(!instance.is_single());
}

View File

@ -65,25 +65,8 @@ pub fn apt_update_page(
});
thread::spawn(move || {
let instance = single_instance::SingleInstance::new(
"com.github.pikaos-linux.pikmanupdatemanager.update.manager",
)
.unwrap();
if instance.is_single() {
let current_locale = match std::env::var_os("LANG") {
Some(v) => v
.into_string()
.unwrap()
.chars()
.take_while(|&ch| ch != '.')
.collect::<String>(),
None => panic!("$LANG is not set"),
};
let apt_update_command = Command::new("pkexec")
.args([
"/usr/lib/pika/pikman-update-manager/scripts/apt_update",
&current_locale,
])
.args(["/usr/lib/pika/pikman-update-manager/scripts/apt_update", "fr_FR"])
.status()
.unwrap();
match apt_update_command.code().unwrap() {
@ -100,7 +83,6 @@ pub fn apt_update_page(
.unwrap()
}
}
};
});
let main_box = Box::builder()
@ -536,7 +518,8 @@ fn get_apt_upgrades(get_upgradable_sender: &async_channel::Sender<AptPackageSock
upgradable_cache.resolve(true).unwrap();
let mut upgradeable_iter = upgradable_cache.get_changes(false).peekable();
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();
@ -545,9 +528,13 @@ fn get_apt_upgrades(get_upgradable_sender: &async_channel::Sender<AptPackageSock
arch: pkg.arch().to_string(),
installed_version: match pkg.installed() {
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.version().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(),
@ -556,7 +543,9 @@ fn get_apt_upgrades(get_upgradable_sender: &async_channel::Sender<AptPackageSock
.uris()
.collect::<Vec<String>>()
.join("\n"),
maintainer: match candidate_version_pkg.get_record(RecordField::Maintainer) {
maintainer: match candidate_version_pkg
.get_record(RecordField::Maintainer)
{
Some(s) => s,
_ => t!("apt_pkg_property_unknown").to_string(),
},

View File

@ -411,20 +411,8 @@ fn apt_full_upgrade_from_socket(
});
thread::spawn(move || {
let current_locale = match std::env::var_os("LANG") {
Some(v) => v
.into_string()
.unwrap()
.chars()
.take_while(|&ch| ch != '.')
.collect::<String>(),
None => panic!("$LANG is not set"),
};
let apt_upgrade_command = Command::new("pkexec")
.args([
"/usr/lib/pika/pikman-update-manager/scripts/apt_full_upgrade",
&current_locale,
])
.args(["/usr/lib/pika/pikman-update-manager/scripts/apt_full_upgrade"])
.status()
.unwrap();
match apt_upgrade_command.code().unwrap() {

View File

@ -134,8 +134,8 @@ pub fn build_ui(app: &Application) {
update_sys_tray.connect_activate(clone!(
#[strong]
tray_handle,
/*#[strong]
refresh_button,*/
#[strong]
refresh_button,
move |_, param| {
let array: &[i32] = param.unwrap().fixed_array().unwrap();
let vec = array.to_vec();
@ -175,7 +175,7 @@ pub fn build_ui(app: &Application) {
.unwrap(),
);
});
/*if apt_update_count == -1 || flatpak_update_count == -1 {
if apt_update_count == -1 || flatpak_update_count == -1 {
refresh_button.set_sensitive(false);
refresh_button.set_tooltip_text(Some(
&t!("pikman_indicator_flatpak_item_label_calculating").to_string(),
@ -184,7 +184,7 @@ pub fn build_ui(app: &Application) {
refresh_button.set_sensitive(true);
refresh_button
.set_tooltip_text(Some(&t!("refresh_button_tooltip_text").to_string()));
}*/
}
}
));
update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[-1, -1])));
@ -244,7 +244,7 @@ pub fn build_ui(app: &Application) {
let window_breakpoint = adw::Breakpoint::new(BreakpointCondition::new_length(
BreakpointConditionLengthType::MaxWidth,
1200.0,
1000.0,
LengthUnit::Sp,
));
@ -296,12 +296,12 @@ pub fn build_ui(app: &Application) {
.build();
let window_content_page_split_view = adw::OverlaySplitView::builder()
.vexpand(true)
.hexpand(true)
.content(&window_toolbar)
.sidebar(&window_adw_view_switcher_sidebar_box)
.max_sidebar_width(300.0)
.min_sidebar_width(290.0)
.sidebar_width_unit(adw::LengthUnit::Px)
.sidebar_width_fraction(0.2)
.min_sidebar_width(300.0)
.enable_hide_gesture(true)
.enable_show_gesture(true)
.build();
@ -338,7 +338,7 @@ pub fn build_ui(app: &Application) {
.default_width(glib_settings.int("window-width"))
.default_height(glib_settings.int("window-height"))
//
.width_request(1000)
.width_request(900)
.height_request(700)
.content(&window_content_page_split_view)
// Startup
@ -664,8 +664,7 @@ pub fn build_ui(app: &Application) {
}
}
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);
flatpak_retry_signal_action.activate(None);
}

View File

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

View File

@ -8,16 +8,12 @@ use tokio::runtime::Runtime;
pub struct AptInstallProgressSocket<'a> {
percent_socket_path: &'a str,
status_socket_path: &'a str,
error_strfmt_trans_str: String,
error_strfmt_trans_str: &'a str,
}
impl<'a> AptInstallProgressSocket<'a> {
/// Returns a new default progress instance.
pub fn new(
percent_socket_path: &'a str,
status_socket_path: &'a str,
error_strfmt_trans_str: String,
) -> Self {
pub fn new(percent_socket_path: &'a str, status_socket_path: &'a str, error_strfmt_trans_str: &'a str) -> Self {
let progress = Self {
percent_socket_path: percent_socket_path,
status_socket_path: status_socket_path,

View File

@ -18,14 +18,7 @@ pub struct AptUpdateProgressSocket<'a> {
impl<'a> AptUpdateProgressSocket<'a> {
/// 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 {
pulse_interval: 0,
percent_socket_path: percent_socket_path,