Add update intervals + fix window clipping
This commit is contained in:
parent
51cceb4955
commit
0cea668b3c
2
.github/release-nest-v3
vendored
2
.github/release-nest-v3
vendored
@ -1 +1 @@
|
|||||||
9
|
10
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1736,7 +1736,7 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pikman-update-manager"
|
name = "pikman-update-manager"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-channel",
|
"async-channel",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "pikman-update-manager"
|
name = "pikman-update-manager"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
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
|
||||||
|
@ -13,12 +13,13 @@
|
|||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Default window maximized behaviour</summary>
|
<summary>Default window maximized behaviour</summary>
|
||||||
</key>
|
</key>
|
||||||
<key type="b" name="startup-show">
|
<key name="check-for-updates" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<summary>Show PikaOS Welcome on startup.</summary>
|
<summary>Default window maximized behaviour</summary>
|
||||||
<description>
|
</key>
|
||||||
Show PikaOS Welcome on startup.
|
<key name="update-interval" type="i">
|
||||||
</description>
|
<default>22000000</default>
|
||||||
|
<summary>Update intervals in ms</summary>
|
||||||
</key>
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -1,4 +1,4 @@
|
|||||||
pikman-update-manager (1.0.0-100pika4) pikauwu; urgency=medium
|
pikman-update-manager (1.0.1-100pika1) pikauwu; urgency=medium
|
||||||
|
|
||||||
* initial release
|
* initial release
|
||||||
|
|
||||||
|
2
main.sh
2
main.sh
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
VERSION="1.0.0"
|
VERSION="1.0.1"
|
||||||
|
|
||||||
source ./pika-build-config.sh
|
source ./pika-build-config.sh
|
||||||
|
|
||||||
|
@ -457,23 +457,25 @@ 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) => {
|
AptSourceConfig::DEB822(src) => match &src.signed_by {
|
||||||
match &src.signed_by {
|
Some(t) => {
|
||||||
Some(t) => _command = duct::cmd!(
|
_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",
|
||||||
|
@ -11,6 +11,9 @@ 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)]
|
||||||
@ -83,15 +86,30 @@ 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 internet_loop_sender = internet_loop_sender.clone();
|
let (constant_loop_sender, constant_loop_receiver) = async_channel::unbounded();
|
||||||
|
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
|
||||||
|
|
||||||
@ -116,6 +134,8 @@ 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();
|
||||||
@ -155,43 +175,94 @@ 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 {
|
||||||
match Command::new("ping").arg("google.com").arg("-c 1").output() {
|
let automatically_check_for_updates =
|
||||||
Ok(t) if t.status.success() => internet_loop_sender
|
automatically_check_for_updates_arc.load(std::sync::atomic::Ordering::Relaxed);
|
||||||
.send_blocking(true)
|
if automatically_check_for_updates {
|
||||||
.expect("The channel needs to be open"),
|
match update_interval_arc.lock() {
|
||||||
_ => internet_loop_sender
|
Ok(update_interval) => {
|
||||||
.send_blocking(false)
|
std::thread::sleep(std::time::Duration::from_millis(*update_interval as u64));
|
||||||
.expect("The channel needs to be open"),
|
constant_loop_sender_clone1
|
||||||
};
|
.send_blocking(ConstantLoopMessage::RefreshRequest)
|
||||||
thread::sleep(std::time::Duration::from_secs(5));
|
.expect("The channel needs to be open.");
|
||||||
|
}
|
||||||
|
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();
|
let constant_loop_context = MainContext::default();
|
||||||
// The main loop executes the asynchronous block
|
// The main loop executes the asynchronous block
|
||||||
internet_loop_context.spawn_local(clone!(
|
constant_loop_context.spawn_local(clone!(
|
||||||
#[weak]
|
#[weak]
|
||||||
window_banner,
|
window_banner,
|
||||||
|
#[weak]
|
||||||
|
refresh_button,
|
||||||
async move {
|
async move {
|
||||||
while let Ok(state) = internet_loop_receiver.recv().await {
|
while let Ok(message) = constant_loop_receiver.recv().await {
|
||||||
let banner_text = t!("banner_text_no_internet").to_string();
|
let banner_text = t!("banner_text_no_internet").to_string();
|
||||||
if state == true {
|
match message {
|
||||||
*internet_connected_status.borrow_mut() = true;
|
ConstantLoopMessage::InternetStatus(state) => {
|
||||||
if window_banner.title() == banner_text {
|
if state == true {
|
||||||
window_banner.set_revealed(false)
|
*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 => {
|
||||||
|
refresh_button.emit_clicked();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
*internet_connected_status.borrow_mut() = false;
|
|
||||||
window_banner.set_title(&banner_text);
|
|
||||||
window_banner.set_revealed(true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,8 +275,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,
|
||||||
1100.0,
|
1140.0,
|
||||||
LengthUnit::Px,
|
LengthUnit::Sp,
|
||||||
));
|
));
|
||||||
|
|
||||||
let window_adw_stack = gtk::Stack::builder()
|
let window_adw_stack = gtk::Stack::builder()
|
||||||
@ -298,7 +369,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(1000)
|
.width_request(900)
|
||||||
.height_request(700)
|
.height_request(700)
|
||||||
.content(&window_content_page_split_view)
|
.content(&window_content_page_split_view)
|
||||||
// Startup
|
// Startup
|
||||||
@ -326,11 +397,6 @@ 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"))
|
||||||
@ -550,12 +616,11 @@ 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
|
flatpak_entry_signal_action.activate(Some(&glib::Variant::from("")));
|
||||||
.activate(Some(&glib::Variant::from("")));
|
|
||||||
} else {
|
} else {
|
||||||
flatpak_entry_signal_action
|
flatpak_entry_signal_action
|
||||||
.activate(Some(&glib::Variant::from(>k_application_args[index])));
|
.activate(Some(&glib::Variant::from(>k_application_args[index])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user