Build with speed meter and interval gui
All checks were successful
PikaOS Package Build & Release (amd64-v3) / build (push) Successful in 2m38s
All checks were successful
PikaOS Package Build & Release (amd64-v3) / build (push) Successful in 2m38s
This commit is contained in:
parent
27217bfc50
commit
525183787f
2
.github/release-nest-v3
vendored
2
.github/release-nest-v3
vendored
@ -1 +1 @@
|
||||
13
|
||||
14
|
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -1,4 +1,4 @@
|
||||
pikman-update-manager (1.0.1-100pika4) pikauwu; urgency=medium
|
||||
pikman-update-manager (1.0.1-100pika5) pikauwu; urgency=medium
|
||||
|
||||
* initial release
|
||||
|
||||
|
@ -164,5 +164,8 @@
|
||||
"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}"
|
||||
"apt_update_str_fail": "Download Failed: {DESC} {SHORT_DESC}",
|
||||
"retry_interval_labal_label": "Automatically Check for updates",
|
||||
"retry_interval_spinrow_title": "Automatic Check Interval",
|
||||
"retry_interval_spinrow_subtitle": "In Hours"
|
||||
}
|
@ -7,6 +7,9 @@ use std::cell::Ref;
|
||||
use std::cell::RefCell;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
||||
mod add_dialog;
|
||||
mod deb822_edit_dialog;
|
||||
@ -19,7 +22,11 @@ enum AptSourceConfig {
|
||||
|
||||
pub fn apt_manage_page(
|
||||
window: adw::ApplicationWindow,
|
||||
glib_settings: &gio::Settings,
|
||||
apt_retry_signal_action: &SimpleAction,
|
||||
thread_sleep_sender: &std::sync::mpsc::Sender<()>,
|
||||
automatically_check_for_updates_arc: &Arc<AtomicBool>,
|
||||
update_interval_arc: &Arc<Mutex<i32>>,
|
||||
) -> gtk::Box {
|
||||
let retry_signal_action = gio::SimpleAction::new("apt_manage_retry", None);
|
||||
|
||||
@ -536,6 +543,103 @@ pub fn apt_manage_page(
|
||||
|
||||
//
|
||||
|
||||
let retry_interval_box = gtk::Box::builder()
|
||||
.orientation(Orientation::Horizontal)
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.margin_start(10)
|
||||
.margin_end(10)
|
||||
.margin_bottom(10)
|
||||
.build();
|
||||
|
||||
let retry_interval_labal = gtk::Label::builder()
|
||||
.label(t!("retry_interval_labal_label"))
|
||||
.margin_start(2)
|
||||
.margin_end(5)
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
let retry_interval_switch = gtk::Switch::builder()
|
||||
.active(glib_settings.boolean("check-for-updates"))
|
||||
.margin_end(5)
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
let retry_interval_spinrow= adw::SpinRow::builder()
|
||||
.title(t!("retry_interval_spinrow_title"))
|
||||
.subtitle(t!("retry_interval_spinrow_title"))
|
||||
.activatable(false)
|
||||
.selectable(false)
|
||||
.climb_rate(1.0)
|
||||
.adjustment(>k::Adjustment::new((glib_settings.int("update-interval") as f64) / 3600000.0, 1.0, 24.0, 1.0, 0.0, 0.0))
|
||||
.halign(Align::Start)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
retry_interval_spinrow.connect_value_notify(clone!(
|
||||
#[strong]
|
||||
glib_settings,
|
||||
#[strong]
|
||||
automatically_check_for_updates_arc,
|
||||
#[strong]
|
||||
update_interval_arc,
|
||||
#[strong]
|
||||
thread_sleep_sender,
|
||||
move |spinrow| {
|
||||
match glib_settings.set_int("update-interval", (spinrow.value() * 3600000.0) as i32) {
|
||||
Ok(_) => {
|
||||
{
|
||||
automatically_check_for_updates_arc.store(glib_settings.boolean("check-for-updates"), std::sync::atomic::Ordering::Relaxed);
|
||||
let mut update_interval_arc_gaurd = loop{
|
||||
if let Ok(guard) = update_interval_arc.lock() {
|
||||
break guard;
|
||||
}
|
||||
};
|
||||
*update_interval_arc_gaurd = glib_settings.int("update-interval");
|
||||
}
|
||||
thread_sleep_sender.send(()).unwrap();
|
||||
}
|
||||
Err(_) => {
|
||||
spinrow.set_value(glib_settings.int("update-interval") as f64 / 3600000.0);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
retry_interval_switch.connect_state_set(clone!(
|
||||
#[strong]
|
||||
glib_settings,
|
||||
#[strong]
|
||||
automatically_check_for_updates_arc,
|
||||
#[strong]
|
||||
update_interval_arc,
|
||||
#[strong]
|
||||
thread_sleep_sender,
|
||||
move |switch, state| {
|
||||
match glib_settings.set_boolean("check-for-updates", state) {
|
||||
Ok(_) => {
|
||||
{
|
||||
automatically_check_for_updates_arc.store(glib_settings.boolean("check-for-updates"), std::sync::atomic::Ordering::Relaxed);
|
||||
let mut update_interval_arc_gaurd = loop{
|
||||
if let Ok(guard) = update_interval_arc.lock() {
|
||||
break guard;
|
||||
}
|
||||
};
|
||||
*update_interval_arc_gaurd = glib_settings.int("update-interval");
|
||||
}
|
||||
thread_sleep_sender.send(()).unwrap();
|
||||
}
|
||||
Err(_) => {
|
||||
switch.set_active(!state);
|
||||
}
|
||||
}
|
||||
glib::Propagation::Proceed
|
||||
}
|
||||
));
|
||||
|
||||
retry_interval_spinrow.add_css_class("disable-outline");
|
||||
|
||||
unofficial_sources_edit_box.append(&unofficial_source_add_button);
|
||||
unofficial_sources_edit_box.append(&unofficial_source_edit_button);
|
||||
unofficial_sources_edit_box.append(&unofficial_source_remove_button);
|
||||
@ -545,6 +649,12 @@ pub fn apt_manage_page(
|
||||
|
||||
//
|
||||
|
||||
retry_interval_box.append(&retry_interval_labal);
|
||||
retry_interval_box.append(&retry_interval_switch);
|
||||
retry_interval_box.append(&retry_interval_spinrow);
|
||||
|
||||
//
|
||||
|
||||
main_box.append(&system_mirror_label0);
|
||||
main_box.append(&system_mirror_label1);
|
||||
main_box.append(&mirror_entry_box);
|
||||
@ -555,6 +665,7 @@ pub fn apt_manage_page(
|
||||
main_box.append(&unofficial_sources_label0);
|
||||
main_box.append(&unofficial_sources_label1);
|
||||
main_box.append(&unofficial_sources_viewport);
|
||||
main_box.append(&retry_interval_box);
|
||||
|
||||
main_box
|
||||
}
|
@ -102,6 +102,8 @@ pub fn build_ui(app: &Application) {
|
||||
let update_interval_arc = Arc::new(Mutex::new(glib_settings.int("update-interval")));
|
||||
let internet_connected = Rc::new(RefCell::new(false));
|
||||
|
||||
let (thread_sleep_sender, thread_sleep_receiver) = std::sync::mpsc::channel::<()>();
|
||||
|
||||
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();
|
||||
@ -216,22 +218,38 @@ pub fn build_ui(app: &Application) {
|
||||
}
|
||||
});
|
||||
|
||||
{
|
||||
let automatically_check_for_updates_arc = automatically_check_for_updates_arc.clone();
|
||||
let update_interval_arc = update_interval_arc.clone();
|
||||
|
||||
// update interval loop
|
||||
thread::spawn(move || loop {
|
||||
let automatically_check_for_updates =
|
||||
thread::spawn(move || {
|
||||
loop {
|
||||
let local_interval: i32;
|
||||
let automatically_check_for_updates =
|
||||
automatically_check_for_updates_arc.load(std::sync::atomic::Ordering::Relaxed);
|
||||
if automatically_check_for_updates {
|
||||
match update_interval_arc.lock() {
|
||||
Ok(update_interval) => {
|
||||
std::thread::sleep(std::time::Duration::from_millis(*update_interval as u64));
|
||||
constant_loop_sender_clone1
|
||||
.send_blocking(ConstantLoopMessage::RefreshRequest)
|
||||
.expect("The channel needs to be open.");
|
||||
}
|
||||
Err(_) => {}
|
||||
if automatically_check_for_updates {
|
||||
let update_interval = match update_interval_arc.lock() {
|
||||
Ok(t) => t,
|
||||
Err(_) => {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
local_interval = *update_interval;
|
||||
std::mem::drop(update_interval);
|
||||
//println!("Sleeping on auto update check: {}", local_interval);
|
||||
if let Ok(_) = thread_sleep_receiver.recv_timeout (std::time::Duration::from_millis(local_interval as u64)) {
|
||||
//println!("Sleeping on auto was interrupted was interrupted");
|
||||
continue;
|
||||
}
|
||||
//println!("Starting Refresh Request");
|
||||
constant_loop_sender_clone1
|
||||
.send_blocking(ConstantLoopMessage::RefreshRequest)
|
||||
.expect("The channel needs to be open.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let window_banner = Banner::builder().revealed(false).build();
|
||||
|
||||
@ -325,6 +343,9 @@ pub fn build_ui(app: &Application) {
|
||||
window_toolbar.add_top_bar(&window_headerbar);
|
||||
window_toolbar.add_top_bar(&window_banner);
|
||||
|
||||
let window_box = gtk::Box::new(gtk::Orientation::Horizontal, 0);
|
||||
window_box.append(&window_content_page_split_view);
|
||||
|
||||
// create the main Application window
|
||||
let window = ApplicationWindow::builder()
|
||||
// The text on the titlebar
|
||||
@ -338,9 +359,9 @@ pub fn build_ui(app: &Application) {
|
||||
.default_width(glib_settings.int("window-width"))
|
||||
.default_height(glib_settings.int("window-height"))
|
||||
//
|
||||
.width_request(1000)
|
||||
.height_request(700)
|
||||
.content(&window_content_page_split_view)
|
||||
.width_request(1140)
|
||||
.height_request(780)
|
||||
.content(&window_box)
|
||||
// Startup
|
||||
.startup_id(APP_ID)
|
||||
// build the window
|
||||
@ -354,13 +375,17 @@ pub fn build_ui(app: &Application) {
|
||||
window.maximize()
|
||||
}
|
||||
|
||||
window.connect_close_request(move |window| {
|
||||
let size = window.default_size();
|
||||
let _ = glib_settings.set_int("window-width", size.0);
|
||||
let _ = glib_settings.set_int("window-height", size.1);
|
||||
let _ = glib_settings.set_boolean("is-maximized", window.is_maximized());
|
||||
glib::Propagation::Proceed
|
||||
});
|
||||
{
|
||||
let glib_settings = glib_settings.clone();
|
||||
|
||||
window.connect_close_request(move |window| {
|
||||
let size = window.default_size();
|
||||
let _ = glib_settings.set_int("window-width", size.0);
|
||||
let _ = glib_settings.set_int("window-height", size.1);
|
||||
let _ = glib_settings.set_boolean("is-maximized", window.is_maximized());
|
||||
glib::Propagation::Proceed
|
||||
});
|
||||
}
|
||||
|
||||
let credits_button = gtk::Button::builder()
|
||||
.icon_name("dialog-information-symbolic")
|
||||
@ -497,7 +522,7 @@ pub fn build_ui(app: &Application) {
|
||||
window_adw_view_switcher_sidebar_box.append(&flatpak_update_page_toggle_button);
|
||||
|
||||
window_adw_stack.add_titled(
|
||||
&apt_manage_page(window.clone(), &apt_retry_signal_action),
|
||||
&apt_manage_page(window.clone(), &glib_settings, &apt_retry_signal_action,&thread_sleep_sender, &automatically_check_for_updates_arc, &update_interval_arc),
|
||||
Some("apt_manage_page"),
|
||||
&t!("apt_manage_page_title"),
|
||||
);
|
||||
|
@ -65,3 +65,7 @@
|
||||
font-weight: 800;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.disable-outline {
|
||||
outline: none;
|
||||
}
|
Loading…
Reference in New Issue
Block a user