Compare commits

..

No commits in common. "40c0a64c85861c9b3544c79b5ed173ab7689a82a" and "51cceb495577f76f9bff64eecc86f76ac20770aa" have entirely different histories.

8 changed files with 62 additions and 136 deletions

View File

@ -1 +1 @@
11 9

2
Cargo.lock generated
View File

@ -1736,7 +1736,7 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]] [[package]]
name = "pikman-update-manager" name = "pikman-update-manager"
version = "1.0.1" version = "1.0.0"
dependencies = [ dependencies = [
"async-channel", "async-channel",
"async-trait", "async-trait",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "pikman-update-manager" name = "pikman-update-manager"
version = "1.0.1" version = "1.0.0"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -13,13 +13,12 @@
<default>false</default> <default>false</default>
<summary>Default window maximized behaviour</summary> <summary>Default window maximized behaviour</summary>
</key> </key>
<key name="check-for-updates" type="b"> <key type="b" name="startup-show">
<default>true</default> <default>true</default>
<summary>Default window maximized behaviour</summary> <summary>Show PikaOS Welcome on startup.</summary>
</key> <description>
<key name="update-interval" type="i"> Show PikaOS Welcome on startup.
<default>22000000</default> </description>
<summary>Update intervals in ms</summary>
</key> </key>
</schema> </schema>
</schemalist> </schemalist>

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.0-100pika4) pikauwu; urgency=medium
* initial release * initial release

View File

@ -2,7 +2,7 @@
set -e set -e
VERSION="1.0.1" VERSION="1.0.0"
source ./pika-build-config.sh source ./pika-build-config.sh

View File

@ -457,25 +457,23 @@ pub fn apt_manage_page(
let item = selection.downcast_ref::<BoxedAnyObject>().unwrap(); let item = selection.downcast_ref::<BoxedAnyObject>().unwrap();
let apt_src: Ref<AptSourceConfig> = item.borrow(); let apt_src: Ref<AptSourceConfig> = item.borrow();
match apt_src.deref() { match apt_src.deref() {
AptSourceConfig::DEB822(src) => match &src.signed_by { AptSourceConfig::DEB822(src) => {
Some(t) => { match &src.signed_by {
_command = duct::cmd!( Some(t) => _command = duct::cmd!(
"pkexec", "pkexec",
"/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh",
"delete_deb822", "delete_deb822",
&src.filepath, &src.filepath,
t t
) ),
} None => _command = duct::cmd!(
None => {
_command = duct::cmd!(
"pkexec", "pkexec",
"/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh",
"delete_legacy", "delete_legacy",
&src.filepath &src.filepath
) ),
}
} }
},
AptSourceConfig::Legacy(list) => { AptSourceConfig::Legacy(list) => {
_command = duct::cmd!( _command = duct::cmd!(
"pkexec", "pkexec",

View File

@ -11,9 +11,6 @@ use ksni;
use std::cell::RefCell; use std::cell::RefCell;
use std::process::Command; use std::process::Command;
use std::rc::Rc; use std::rc::Rc;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::sync::Mutex;
use std::thread; use std::thread;
#[derive(Debug)] #[derive(Debug)]
@ -86,30 +83,15 @@ impl ksni::Tray for PikmanTray {
} }
} }
enum ConstantLoopMessage {
InternetStatus(bool),
RefreshRequest,
}
pub fn build_ui(app: &Application) { pub fn build_ui(app: &Application) {
// setup glib // setup glib
glib::set_prgname(Some(t!("application_name").to_string())); glib::set_prgname(Some(t!("application_name").to_string()));
glib::set_application_name(&t!("application_name").to_string()); glib::set_application_name(&t!("application_name").to_string());
let glib_settings = gio::Settings::new(APP_ID); let glib_settings = gio::Settings::new(APP_ID);
let automatically_check_for_updates_arc =
Arc::new(AtomicBool::new(glib_settings.boolean("check-for-updates")));
let update_interval_arc = Arc::new(Mutex::new(glib_settings.int("update-interval")));
let internet_connected = Rc::new(RefCell::new(false)); let internet_connected = Rc::new(RefCell::new(false));
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
let (constant_loop_sender, constant_loop_receiver) = async_channel::unbounded(); let internet_loop_sender = internet_loop_sender.clone();
let constant_loop_sender_clone0 = constant_loop_sender.clone();
let constant_loop_sender_clone1 = constant_loop_sender.clone();
let refresh_button = gtk::Button::builder()
.icon_name("view-refresh-symbolic")
.tooltip_text(t!("refresh_button_tooltip_text"))
.build();
// Systray // Systray
@ -134,8 +116,6 @@ pub fn build_ui(app: &Application) {
update_sys_tray.connect_activate(clone!( update_sys_tray.connect_activate(clone!(
#[strong] #[strong]
tray_handle, tray_handle,
#[strong]
refresh_button,
move |_, param| { move |_, param| {
let array: &[i32] = param.unwrap().fixed_array().unwrap(); let array: &[i32] = param.unwrap().fixed_array().unwrap();
let vec = array.to_vec(); let vec = array.to_vec();
@ -175,68 +155,48 @@ pub fn build_ui(app: &Application) {
.unwrap(), .unwrap(),
); );
}); });
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(),
));
} else {
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]))); update_sys_tray.activate(Some(&glib::Variant::array_from_fixed_array(&[-1, -1])));
// internet check loop
thread::spawn(move || {
let mut last_result = false;
loop {
if last_result == true {
std::thread::sleep(std::time::Duration::from_secs(60));
}
let check_internet_connection_cli = Command::new("ping")
.arg("iso.pika-os.com")
.arg("-c 1")
.output()
.expect("failed to execute process");
if check_internet_connection_cli.status.success() {
constant_loop_sender_clone0
.send_blocking(ConstantLoopMessage::InternetStatus(true))
.expect("The channel needs to be open.");
last_result = true
} else {
constant_loop_sender_clone0
.send_blocking(ConstantLoopMessage::InternetStatus(false))
.expect("The channel needs to be open.");
last_result = false
}
}
});
// update interval loop
thread::spawn(move || loop { thread::spawn(move || loop {
let automatically_check_for_updates = match Command::new("ping").arg("google.com").arg("-c 1").output() {
automatically_check_for_updates_arc.load(std::sync::atomic::Ordering::Relaxed); Ok(t) if t.status.success() => internet_loop_sender
if automatically_check_for_updates { .send_blocking(true)
match update_interval_arc.lock() { .expect("The channel needs to be open"),
Ok(update_interval) => { _ => internet_loop_sender
std::thread::sleep(std::time::Duration::from_millis(*update_interval as u64)); .send_blocking(false)
constant_loop_sender_clone1 .expect("The channel needs to be open"),
.send_blocking(ConstantLoopMessage::RefreshRequest) };
.expect("The channel needs to be open."); thread::sleep(std::time::Duration::from_secs(5));
}
Err(_) => {}
}
}
}); });
let window_banner = Banner::builder().revealed(false).build(); let window_banner = Banner::builder().revealed(false).build();
let internet_connected_status = internet_connected.clone(); let internet_connected_status = internet_connected.clone();
let internet_loop_context = MainContext::default();
// The main loop executes the asynchronous block
internet_loop_context.spawn_local(clone!(
#[weak]
window_banner,
async move {
while let Ok(state) = internet_loop_receiver.recv().await {
let banner_text = t!("banner_text_no_internet").to_string();
if state == true {
*internet_connected_status.borrow_mut() = true;
if window_banner.title() == banner_text {
window_banner.set_revealed(false)
}
} else {
*internet_connected_status.borrow_mut() = false;
window_banner.set_title(&banner_text);
window_banner.set_revealed(true)
}
}
}
));
let window_headerbar = HeaderBar::builder() let window_headerbar = HeaderBar::builder()
.title_widget(&WindowTitle::builder().title(t!("application_name")).build()) .title_widget(&WindowTitle::builder().title(t!("application_name")).build())
.show_title(false) .show_title(false)
@ -244,8 +204,8 @@ 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, 1100.0,
LengthUnit::Sp, LengthUnit::Px,
)); ));
let window_adw_stack = gtk::Stack::builder() let window_adw_stack = gtk::Stack::builder()
@ -338,7 +298,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
@ -366,6 +326,11 @@ pub fn build_ui(app: &Application) {
.icon_name("dialog-information-symbolic") .icon_name("dialog-information-symbolic")
.build(); .build();
let refresh_button = gtk::Button::builder()
.icon_name("view-refresh-symbolic")
.tooltip_text(t!("refresh_button_tooltip_text"))
.build();
let credits_window = AboutWindow::builder() let credits_window = AboutWindow::builder()
.application_icon(APP_ICON) .application_icon(APP_ICON)
.application_name(t!("application_name")) .application_name(t!("application_name"))
@ -585,8 +550,9 @@ pub fn build_ui(app: &Application) {
.position(|r| r == "--flatpak-installer") .position(|r| r == "--flatpak-installer")
.unwrap() as i32) .unwrap() as i32)
+ 1) as usize; + 1) as usize;
if index > gtk_application_args.len() - 1 { if index > gtk_application_args.len() -1 {
flatpak_entry_signal_action.activate(Some(&glib::Variant::from(""))); flatpak_entry_signal_action
.activate(Some(&glib::Variant::from("")));
} else { } else {
flatpak_entry_signal_action flatpak_entry_signal_action
.activate(Some(&glib::Variant::from(&gtk_application_args[index]))); .activate(Some(&glib::Variant::from(&gtk_application_args[index])));
@ -635,43 +601,6 @@ pub fn build_ui(app: &Application) {
} }
} }
)); ));
let constant_loop_context = MainContext::default();
// The main loop executes the asynchronous block
constant_loop_context.spawn_local(clone!(
#[weak]
window_banner,
#[strong]
update_sys_tray,
#[strong]
apt_retry_signal_action,
#[strong]
flatpak_retry_signal_action,
async move {
while let Ok(message) = constant_loop_receiver.recv().await {
let banner_text = t!("banner_text_no_internet").to_string();
match message {
ConstantLoopMessage::InternetStatus(state) => {
if state == true {
*internet_connected_status.borrow_mut() = true;
if window_banner.title() == banner_text {
window_banner.set_revealed(false)
}
} else {
*internet_connected_status.borrow_mut() = false;
window_banner.set_title(&banner_text);
window_banner.set_revealed(true)
}
}
ConstantLoopMessage::RefreshRequest => {
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);
}
}
}
}
));
} }
fn add_content_button( fn add_content_button(