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
|
* initial release
|
||||||
|
|
||||||
|
@ -164,5 +164,8 @@
|
|||||||
"apt_update_str_hit": "Up-to-date: {DESC} {SHORT_DESC}",
|
"apt_update_str_hit": "Up-to-date: {DESC} {SHORT_DESC}",
|
||||||
"apt_update_str_fetch": "Fetching: {DESC} {SHORT_DESC}",
|
"apt_update_str_fetch": "Fetching: {DESC} {SHORT_DESC}",
|
||||||
"apt_update_str_done": "Downloading: {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::cell::RefCell;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use std::sync::atomic::AtomicBool;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use std::sync::Mutex;
|
||||||
|
|
||||||
mod add_dialog;
|
mod add_dialog;
|
||||||
mod deb822_edit_dialog;
|
mod deb822_edit_dialog;
|
||||||
@ -19,7 +22,11 @@ enum AptSourceConfig {
|
|||||||
|
|
||||||
pub fn apt_manage_page(
|
pub fn apt_manage_page(
|
||||||
window: adw::ApplicationWindow,
|
window: adw::ApplicationWindow,
|
||||||
|
glib_settings: &gio::Settings,
|
||||||
apt_retry_signal_action: &SimpleAction,
|
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 {
|
) -> gtk::Box {
|
||||||
let retry_signal_action = gio::SimpleAction::new("apt_manage_retry", None);
|
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_add_button);
|
||||||
unofficial_sources_edit_box.append(&unofficial_source_edit_button);
|
unofficial_sources_edit_box.append(&unofficial_source_edit_button);
|
||||||
unofficial_sources_edit_box.append(&unofficial_source_remove_button);
|
unofficial_sources_edit_box.append(&unofficial_source_remove_button);
|
||||||
@ -543,6 +647,12 @@ pub fn apt_manage_page(
|
|||||||
unofficial_sources_box.append(&unofficial_sources_columnview_bin);
|
unofficial_sources_box.append(&unofficial_sources_columnview_bin);
|
||||||
unofficial_sources_box.append(&unofficial_sources_edit_box);
|
unofficial_sources_box.append(&unofficial_sources_edit_box);
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
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_label0);
|
||||||
@ -555,6 +665,7 @@ pub fn apt_manage_page(
|
|||||||
main_box.append(&unofficial_sources_label0);
|
main_box.append(&unofficial_sources_label0);
|
||||||
main_box.append(&unofficial_sources_label1);
|
main_box.append(&unofficial_sources_label1);
|
||||||
main_box.append(&unofficial_sources_viewport);
|
main_box.append(&unofficial_sources_viewport);
|
||||||
|
main_box.append(&retry_interval_box);
|
||||||
|
|
||||||
main_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 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 (thread_sleep_sender, thread_sleep_receiver) = std::sync::mpsc::channel::<()>();
|
||||||
|
|
||||||
let (constant_loop_sender, constant_loop_receiver) = async_channel::unbounded();
|
let (constant_loop_sender, constant_loop_receiver) = async_channel::unbounded();
|
||||||
let constant_loop_sender_clone0 = constant_loop_sender.clone();
|
let constant_loop_sender_clone0 = constant_loop_sender.clone();
|
||||||
let constant_loop_sender_clone1 = 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
|
// update interval loop
|
||||||
thread::spawn(move || loop {
|
thread::spawn(move || {
|
||||||
let automatically_check_for_updates =
|
loop {
|
||||||
|
let local_interval: i32;
|
||||||
|
let automatically_check_for_updates =
|
||||||
automatically_check_for_updates_arc.load(std::sync::atomic::Ordering::Relaxed);
|
automatically_check_for_updates_arc.load(std::sync::atomic::Ordering::Relaxed);
|
||||||
if automatically_check_for_updates {
|
if automatically_check_for_updates {
|
||||||
match update_interval_arc.lock() {
|
let update_interval = match update_interval_arc.lock() {
|
||||||
Ok(update_interval) => {
|
Ok(t) => t,
|
||||||
std::thread::sleep(std::time::Duration::from_millis(*update_interval as u64));
|
Err(_) => {
|
||||||
constant_loop_sender_clone1
|
continue;
|
||||||
.send_blocking(ConstantLoopMessage::RefreshRequest)
|
}
|
||||||
.expect("The channel needs to be open.");
|
};
|
||||||
}
|
local_interval = *update_interval;
|
||||||
Err(_) => {}
|
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();
|
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_headerbar);
|
||||||
window_toolbar.add_top_bar(&window_banner);
|
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
|
// create the main Application window
|
||||||
let window = ApplicationWindow::builder()
|
let window = ApplicationWindow::builder()
|
||||||
// The text on the titlebar
|
// The text on the titlebar
|
||||||
@ -338,9 +359,9 @@ 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(1140)
|
||||||
.height_request(700)
|
.height_request(780)
|
||||||
.content(&window_content_page_split_view)
|
.content(&window_box)
|
||||||
// Startup
|
// Startup
|
||||||
.startup_id(APP_ID)
|
.startup_id(APP_ID)
|
||||||
// build the window
|
// build the window
|
||||||
@ -354,13 +375,17 @@ pub fn build_ui(app: &Application) {
|
|||||||
window.maximize()
|
window.maximize()
|
||||||
}
|
}
|
||||||
|
|
||||||
window.connect_close_request(move |window| {
|
{
|
||||||
let size = window.default_size();
|
let glib_settings = glib_settings.clone();
|
||||||
let _ = glib_settings.set_int("window-width", size.0);
|
|
||||||
let _ = glib_settings.set_int("window-height", size.1);
|
window.connect_close_request(move |window| {
|
||||||
let _ = glib_settings.set_boolean("is-maximized", window.is_maximized());
|
let size = window.default_size();
|
||||||
glib::Propagation::Proceed
|
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()
|
let credits_button = gtk::Button::builder()
|
||||||
.icon_name("dialog-information-symbolic")
|
.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_view_switcher_sidebar_box.append(&flatpak_update_page_toggle_button);
|
||||||
|
|
||||||
window_adw_stack.add_titled(
|
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"),
|
Some("apt_manage_page"),
|
||||||
&t!("apt_manage_page_title"),
|
&t!("apt_manage_page_title"),
|
||||||
);
|
);
|
||||||
|
@ -64,4 +64,8 @@
|
|||||||
.size-20-bold-text {
|
.size-20-bold-text {
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disable-outline {
|
||||||
|
outline: none;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user