add basis for theme change detecttion
This commit is contained in:
parent
d36bda43a5
commit
a5149a990b
@ -567,13 +567,20 @@ pub fn apt_manage_page(
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
let retry_interval_spinrow= adw::SpinRow::builder()
|
||||
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))
|
||||
.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();
|
||||
@ -591,21 +598,25 @@ pub fn apt_manage_page(
|
||||
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");
|
||||
}
|
||||
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]
|
||||
@ -620,14 +631,17 @@ pub fn apt_manage_page(
|
||||
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");
|
||||
}
|
||||
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(_) => {
|
||||
|
@ -20,17 +20,20 @@ use duct::cmd;
|
||||
|
||||
enum AddonChannelMsg {
|
||||
LogLoopLine(String),
|
||||
LogLoopStatus(bool)
|
||||
LogLoopStatus(bool),
|
||||
}
|
||||
|
||||
fn run_addon_command(
|
||||
log_loop_sender: async_channel::Sender<AddonChannelMsg>,
|
||||
) -> Result<(), std::boxed::Box<dyn std::error::Error + Send + Sync>> {
|
||||
let (pipe_reader, pipe_writer) = os_pipe::pipe()?;
|
||||
let child = cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/apt_update")
|
||||
.stderr_to_stdout()
|
||||
.stdout_file(pipe_writer)
|
||||
.start()?;
|
||||
let child = cmd!(
|
||||
"pkexec",
|
||||
"/usr/lib/pika/pikman-update-manager/scripts/apt_update"
|
||||
)
|
||||
.stderr_to_stdout()
|
||||
.stdout_file(pipe_writer)
|
||||
.start()?;
|
||||
for line in BufReader::new(pipe_reader).lines() {
|
||||
let line_clone = line?;
|
||||
log_loop_sender
|
||||
@ -60,6 +63,7 @@ pub fn apt_update_page(
|
||||
window: adw::ApplicationWindow,
|
||||
retry_signal_action: &SimpleAction,
|
||||
flatpak_retry_signal_action: &SimpleAction,
|
||||
theme_changed_action: &SimpleAction,
|
||||
flatpak_ran_once: Rc<RefCell<bool>>,
|
||||
update_sys_tray: &SimpleAction,
|
||||
apt_update_count: &Rc<RefCell<i32>>,
|
||||
@ -149,16 +153,20 @@ pub fn apt_update_page(
|
||||
|
||||
std::thread::spawn(move || {
|
||||
let command = run_addon_command(log_loop_sender_clone0);
|
||||
match command {
|
||||
Ok(_) => {
|
||||
println!("Status: Addon Command Successful");
|
||||
log_loop_sender_clone1.send_blocking(AddonChannelMsg::LogLoopStatus(true)).expect("The channel needs to be open.");
|
||||
}
|
||||
Err(_) => {
|
||||
println!("Status: Addon Command Failed");
|
||||
log_loop_sender_clone1.send_blocking(AddonChannelMsg::LogLoopStatus(false)).expect("The channel needs to be open.");
|
||||
}
|
||||
match command {
|
||||
Ok(_) => {
|
||||
println!("Status: Addon Command Successful");
|
||||
log_loop_sender_clone1
|
||||
.send_blocking(AddonChannelMsg::LogLoopStatus(true))
|
||||
.expect("The channel needs to be open.");
|
||||
}
|
||||
Err(_) => {
|
||||
println!("Status: Addon Command Failed");
|
||||
log_loop_sender_clone1
|
||||
.send_blocking(AddonChannelMsg::LogLoopStatus(false))
|
||||
.expect("The channel needs to be open.");
|
||||
}
|
||||
}
|
||||
});
|
||||
// End of TEMP APT FIX
|
||||
|
||||
@ -359,11 +367,14 @@ pub fn apt_update_page(
|
||||
retry_signal_action,
|
||||
#[strong]
|
||||
excluded_updates_vec,
|
||||
#[strong]
|
||||
theme_changed_action,
|
||||
move |_| {
|
||||
process::apt_process_update(
|
||||
&excluded_updates_vec.borrow(),
|
||||
window,
|
||||
&retry_signal_action,
|
||||
&theme_changed_action,
|
||||
);
|
||||
}
|
||||
));
|
||||
@ -482,17 +493,22 @@ pub fn apt_update_page(
|
||||
match state {
|
||||
true => {
|
||||
get_apt_upgrades(&get_upgradable_sender);
|
||||
log_terminal_buffer.delete(&mut log_terminal_buffer.start_iter(), &mut log_terminal_buffer.end_iter());
|
||||
log_terminal_buffer.delete(
|
||||
&mut log_terminal_buffer.start_iter(),
|
||||
&mut log_terminal_buffer.end_iter(),
|
||||
);
|
||||
apt_update_dialog.close();
|
||||
let mut flatpak_ran_once_borrow = flatpak_ran_once.borrow_mut();
|
||||
if *flatpak_ran_once_borrow != true {
|
||||
flatpak_retry_signal_action.activate(None);
|
||||
*flatpak_ran_once_borrow = 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(),
|
||||
]),
|
||||
));
|
||||
}
|
||||
false => {
|
||||
get_apt_upgrades(&get_upgradable_sender);
|
||||
@ -504,25 +520,31 @@ pub fn apt_update_page(
|
||||
.halign(Align::Center)
|
||||
.build(),
|
||||
));
|
||||
apt_update_dialog.set_title(Some(
|
||||
&t!("apt_update_dialog_status_failed").to_string(),
|
||||
));
|
||||
apt_update_dialog
|
||||
.set_title(Some(&t!("apt_update_dialog_status_failed").to_string()));
|
||||
apt_update_dialog.set_response_enabled("apt_update_dialog_retry", true);
|
||||
apt_update_dialog.set_response_enabled("apt_update_dialog_ignore", true);
|
||||
.set_response_enabled("apt_update_dialog_retry", true);
|
||||
apt_update_dialog
|
||||
.set_response_enabled("apt_update_dialog_ignore", true);
|
||||
let mut flatpak_ran_once_borrow = flatpak_ran_once.borrow_mut();
|
||||
if *flatpak_ran_once_borrow != true {
|
||||
flatpak_retry_signal_action.activate(None);
|
||||
*flatpak_ran_once_borrow = 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(),
|
||||
]),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
AddonChannelMsg::LogLoopLine(state) => {
|
||||
log_terminal_buffer.insert(&mut log_terminal_buffer.end_iter(), &("\n".to_string() + &state))
|
||||
}
|
||||
AddonChannelMsg::LogLoopLine(state) => log_terminal_buffer.insert(
|
||||
&mut log_terminal_buffer.end_iter(),
|
||||
&("\n".to_string() + &state),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ pub fn apt_process_update(
|
||||
excluded_updates_vec: &Vec<String>,
|
||||
window: adw::ApplicationWindow,
|
||||
retry_signal_action: &SimpleAction,
|
||||
theme_changed_action: &SimpleAction,
|
||||
) {
|
||||
let excluded_updates_alert_dialog = adw::MessageDialog::builder()
|
||||
.transient_for(&window)
|
||||
@ -97,7 +98,14 @@ pub fn apt_process_update(
|
||||
retry_signal_action,
|
||||
#[strong]
|
||||
excluded_updates_vec,
|
||||
move |_, _| apt_confirm_window(&excluded_updates_vec, window, &retry_signal_action)
|
||||
#[strong]
|
||||
theme_changed_action,
|
||||
move |_, _| apt_confirm_window(
|
||||
&excluded_updates_vec,
|
||||
window,
|
||||
&retry_signal_action,
|
||||
&theme_changed_action
|
||||
)
|
||||
));
|
||||
|
||||
if excluded_updates_vec.is_empty() {
|
||||
@ -115,6 +123,7 @@ fn apt_confirm_window(
|
||||
excluded_updates_vec: &Vec<String>,
|
||||
window: adw::ApplicationWindow,
|
||||
retry_signal_action: &SimpleAction,
|
||||
theme_changed_action: &SimpleAction,
|
||||
) {
|
||||
let to_be_removed_packages_vec: Rc<RefCell<Vec<String>>> = Rc::new(RefCell::new(Vec::new()));
|
||||
// Emulate Apt Full Upgrade to get transaction info
|
||||
@ -306,13 +315,20 @@ fn apt_confirm_window(
|
||||
retry_signal_action,
|
||||
#[strong]
|
||||
apt_confirm_dialog,
|
||||
#[strong]
|
||||
theme_changed_action,
|
||||
move |_, _| {
|
||||
let retry_signal_action0 = retry_signal_action.clone();
|
||||
let theme_changed_action0 = theme_changed_action.clone();
|
||||
apt_confirm_dialog
|
||||
.clone()
|
||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||
if choice == "apt_confirm_dialog_confirm" {
|
||||
apt_full_upgrade_from_socket(window, &retry_signal_action0);
|
||||
apt_full_upgrade_from_socket(
|
||||
window,
|
||||
&retry_signal_action0,
|
||||
&theme_changed_action0,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -384,6 +400,7 @@ fn apt_confirm_window(
|
||||
fn apt_full_upgrade_from_socket(
|
||||
window: adw::ApplicationWindow,
|
||||
retry_signal_action: &SimpleAction,
|
||||
theme_changed_action: &SimpleAction,
|
||||
) {
|
||||
let (upgrade_percent_sender, upgrade_percent_receiver) = async_channel::unbounded::<String>();
|
||||
let upgrade_percent_sender = upgrade_percent_sender.clone();
|
||||
@ -464,14 +481,48 @@ fn apt_full_upgrade_from_socket(
|
||||
apt_upgrade_dialog_progress_bar.set_width_request(200);
|
||||
apt_upgrade_dialog_progress_bar.set_height_request(200);
|
||||
#[allow(deprecated)]
|
||||
apt_upgrade_dialog_progress_bar.set_progress_fill_color(window.style_context().lookup_color("accent_bg_color").unwrap());
|
||||
apt_upgrade_dialog_progress_bar.set_progress_fill_color(
|
||||
window
|
||||
.style_context()
|
||||
.lookup_color("accent_bg_color")
|
||||
.unwrap(),
|
||||
);
|
||||
#[allow(deprecated)]
|
||||
apt_upgrade_dialog_progress_bar.set_radius_fill_color(window.style_context().lookup_color("headerbar_bg_color").unwrap());
|
||||
apt_upgrade_dialog_progress_bar.set_radius_fill_color(
|
||||
window
|
||||
.style_context()
|
||||
.lookup_color("headerbar_bg_color")
|
||||
.unwrap(),
|
||||
);
|
||||
#[warn(deprecated)]
|
||||
apt_upgrade_dialog_progress_bar.set_progress_font(get_current_font());
|
||||
apt_upgrade_dialog_progress_bar.set_center_text(t!("progress_bar_circle_center_text"));
|
||||
apt_upgrade_dialog_progress_bar.set_fraction_font_size(24);
|
||||
apt_upgrade_dialog_progress_bar.set_center_text_font_size(8);
|
||||
theme_changed_action.connect_activate(clone!(
|
||||
#[strong]
|
||||
window,
|
||||
#[strong]
|
||||
apt_upgrade_dialog_progress_bar,
|
||||
move |_, _| {
|
||||
#[allow(deprecated)]
|
||||
apt_upgrade_dialog_progress_bar.set_progress_fill_color(
|
||||
window
|
||||
.style_context()
|
||||
.lookup_color("accent_bg_color")
|
||||
.unwrap(),
|
||||
);
|
||||
#[allow(deprecated)]
|
||||
apt_upgrade_dialog_progress_bar.set_radius_fill_color(
|
||||
window
|
||||
.style_context()
|
||||
.lookup_color("headerbar_bg_color")
|
||||
.unwrap(),
|
||||
);
|
||||
#[warn(deprecated)]
|
||||
apt_upgrade_dialog_progress_bar.set_progress_font(get_current_font());
|
||||
}
|
||||
));
|
||||
|
||||
let apt_speed_label = gtk::Label::builder()
|
||||
.halign(Align::Center)
|
||||
|
@ -16,39 +16,9 @@ use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use std::thread;
|
||||
|
||||
fn get_gsettings_font() -> String {
|
||||
let glib_settings = gio::Settings::new("org.gnome.desktop.interface");
|
||||
let font = glib_settings.string("font-name").to_string();
|
||||
let re = regex::Regex::new(r" [^ ]*$").unwrap();
|
||||
re.replace(&font, "").to_string()
|
||||
}
|
||||
|
||||
pub fn get_current_font() -> String {
|
||||
let mut gtk_config_file = configparser::ini::Ini::new();
|
||||
match std::fs::read_to_string(std::env::var_os("HOME").unwrap().to_string_lossy().to_string() + "/.config/gtk-4.0/settings.ini") {
|
||||
Ok(t) => {
|
||||
match gtk_config_file.read(t) {
|
||||
Ok(_) => {
|
||||
match gtk_config_file.get("Settings", "gtk-font-name") {
|
||||
Some(s) => {
|
||||
let re = regex::Regex::new(r",[^,]*$").unwrap();
|
||||
return re.replace(&s, "").to_string();
|
||||
},
|
||||
None => {
|
||||
return get_gsettings_font();
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
return get_gsettings_font();
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
return get_gsettings_font();
|
||||
}
|
||||
}
|
||||
|
||||
let settings = gtk::Settings::default().unwrap();
|
||||
settings.gtk_font_name().unwrap().to_string()
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -143,6 +113,9 @@ pub fn build_ui(app: &Application) {
|
||||
let constant_loop_sender_clone0 = constant_loop_sender.clone();
|
||||
let constant_loop_sender_clone1 = constant_loop_sender.clone();
|
||||
|
||||
let (gsettings_change_sender, gsettings_change_receiver) = async_channel::unbounded();
|
||||
let gsettings_change_sender_clone0 = gsettings_change_sender.clone();
|
||||
|
||||
let refresh_button = gtk::Button::builder()
|
||||
.icon_name("view-refresh-symbolic")
|
||||
.tooltip_text(t!("refresh_button_tooltip_text"))
|
||||
@ -154,6 +127,7 @@ pub fn build_ui(app: &Application) {
|
||||
let flatpak_update_count = Rc::new(RefCell::new(0));
|
||||
|
||||
let update_sys_tray = gio::SimpleAction::new("sys_tray", Some(glib::VariantTy::ARRAY));
|
||||
let theme_changed_action = gio::SimpleAction::new("theme_changed", None);
|
||||
|
||||
let (tray_service_sender, tray_service_receiver) = async_channel::unbounded();
|
||||
let tray_service_sender = tray_service_sender.clone();
|
||||
@ -254,36 +228,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();
|
||||
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 local_interval: i32;
|
||||
let automatically_check_for_updates =
|
||||
automatically_check_for_updates_arc.load(std::sync::atomic::Ordering::Relaxed);
|
||||
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");
|
||||
// update interval loop
|
||||
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 {
|
||||
let update_interval = match update_interval_arc.lock() {
|
||||
Ok(t) => t,
|
||||
Err(_) => {
|
||||
continue;
|
||||
}
|
||||
//println!("Starting Refresh Request");
|
||||
constant_loop_sender_clone1
|
||||
.send_blocking(ConstantLoopMessage::RefreshRequest)
|
||||
.expect("The channel needs to be open.");
|
||||
};
|
||||
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();
|
||||
@ -445,6 +421,66 @@ pub fn build_ui(app: &Application) {
|
||||
|
||||
//window.present();
|
||||
|
||||
// Theme update actions
|
||||
{
|
||||
let setting = gtk::Settings::default().unwrap();
|
||||
|
||||
setting.connect_gtk_application_prefer_dark_theme_notify(clone!(
|
||||
#[strong]
|
||||
theme_changed_action,
|
||||
move |_| {
|
||||
let theme_changed_action = theme_changed_action.clone();
|
||||
glib::timeout_add_seconds_local(5, move || {
|
||||
theme_changed_action.activate(None);
|
||||
glib::ControlFlow::Continue
|
||||
});
|
||||
}
|
||||
));
|
||||
setting.connect_gtk_font_name_notify(clone!(
|
||||
#[strong]
|
||||
theme_changed_action,
|
||||
move |_| {
|
||||
let theme_changed_action = theme_changed_action.clone();
|
||||
glib::timeout_add_seconds_local(5, move || {
|
||||
theme_changed_action.activate(None);
|
||||
glib::ControlFlow::Continue
|
||||
});
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
thread::spawn(move || {
|
||||
let context = glib::MainContext::default();
|
||||
let main_loop = glib::MainLoop::new(Some(&context), false);
|
||||
let gsettings = gtk::gio::Settings::new("org.gnome.desktop.interface");
|
||||
gsettings.connect_changed(
|
||||
Some("accent-color"),
|
||||
clone!(
|
||||
#[strong]
|
||||
gsettings_change_sender_clone0,
|
||||
move |_, _| {
|
||||
let gsettings_change_sender_clone0 = gsettings_change_sender_clone0.clone();
|
||||
glib::timeout_add_seconds_local(5, move || {
|
||||
gsettings_change_sender_clone0.send_blocking(()).unwrap();
|
||||
glib::ControlFlow::Continue
|
||||
});
|
||||
}
|
||||
),
|
||||
);
|
||||
main_loop.run()
|
||||
});
|
||||
|
||||
let gsettings_changed_context = MainContext::default();
|
||||
// The main loop executes the asynchronous block
|
||||
gsettings_changed_context.spawn_local(clone!(
|
||||
#[strong]
|
||||
theme_changed_action,
|
||||
async move {
|
||||
while let Ok(()) = gsettings_change_receiver.recv().await {
|
||||
theme_changed_action.activate(None);
|
||||
}
|
||||
}
|
||||
));
|
||||
// Flatpak Update Page
|
||||
|
||||
let flatpak_retry_signal_action = gio::SimpleAction::new("retry", None);
|
||||
@ -464,11 +500,14 @@ pub fn build_ui(app: &Application) {
|
||||
apt_update_count,
|
||||
#[strong]
|
||||
flatpak_update_count,
|
||||
#[strong]
|
||||
theme_changed_action,
|
||||
move |_, _| {
|
||||
flatpak_update_view_stack_bin.set_child(Some(
|
||||
&flatpak_update_page::flatpak_update_page(
|
||||
window,
|
||||
&flatpak_retry_signal_action,
|
||||
&theme_changed_action,
|
||||
&update_sys_tray,
|
||||
&apt_update_count,
|
||||
&flatpak_update_count,
|
||||
@ -499,11 +538,14 @@ pub fn build_ui(app: &Application) {
|
||||
apt_update_count,
|
||||
#[strong]
|
||||
flatpak_update_count,
|
||||
#[strong]
|
||||
theme_changed_action,
|
||||
move |action, _| {
|
||||
apt_update_view_stack_bin.set_child(Some(&apt_update_page::apt_update_page(
|
||||
window.clone(),
|
||||
&action,
|
||||
&flatpak_retry_signal_action,
|
||||
&theme_changed_action,
|
||||
flatpak_ran_once.clone(),
|
||||
&update_sys_tray,
|
||||
&apt_update_count,
|
||||
@ -516,6 +558,7 @@ pub fn build_ui(app: &Application) {
|
||||
window.clone(),
|
||||
&apt_retry_signal_action,
|
||||
&flatpak_retry_signal_action,
|
||||
&theme_changed_action,
|
||||
flatpak_ran_once.clone(),
|
||||
&update_sys_tray,
|
||||
&apt_update_count,
|
||||
@ -555,7 +598,14 @@ 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(), &glib_settings, &apt_retry_signal_action,&thread_sleep_sender, &automatically_check_for_updates_arc, &update_interval_arc),
|
||||
&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"),
|
||||
);
|
||||
|
@ -28,6 +28,7 @@ pub struct FlatpakRefStruct {
|
||||
pub fn flatpak_update_page(
|
||||
window: adw::ApplicationWindow,
|
||||
retry_signal_action: &SimpleAction,
|
||||
theme_changed_action: &SimpleAction,
|
||||
update_sys_tray: &SimpleAction,
|
||||
apt_update_count: &Rc<RefCell<i32>>,
|
||||
flatpak_update_count: &Rc<RefCell<i32>>,
|
||||
@ -214,9 +215,19 @@ pub fn flatpak_update_page(
|
||||
flatpak_update_dialog_progress_bar.set_width_request(200);
|
||||
flatpak_update_dialog_progress_bar.set_height_request(200);
|
||||
#[allow(deprecated)]
|
||||
flatpak_update_dialog_progress_bar.set_progress_fill_color(window.style_context().lookup_color("accent_bg_color").unwrap());
|
||||
flatpak_update_dialog_progress_bar.set_progress_fill_color(
|
||||
window
|
||||
.style_context()
|
||||
.lookup_color("accent_bg_color")
|
||||
.unwrap(),
|
||||
);
|
||||
#[allow(deprecated)]
|
||||
flatpak_update_dialog_progress_bar.set_radius_fill_color(window.style_context().lookup_color("headerbar_bg_color").unwrap());
|
||||
flatpak_update_dialog_progress_bar.set_radius_fill_color(
|
||||
window
|
||||
.style_context()
|
||||
.lookup_color("headerbar_bg_color")
|
||||
.unwrap(),
|
||||
);
|
||||
#[warn(deprecated)]
|
||||
flatpak_update_dialog_progress_bar.set_progress_font(get_current_font());
|
||||
flatpak_update_dialog_progress_bar.set_center_text(t!("progress_bar_circle_center_text"));
|
||||
@ -324,6 +335,8 @@ pub fn flatpak_update_page(
|
||||
#[weak]
|
||||
retry_signal_action,
|
||||
#[strong]
|
||||
theme_changed_action,
|
||||
#[strong]
|
||||
system_refs_for_upgrade_vec_all_clone0,
|
||||
#[strong]
|
||||
user_refs_for_upgrade_vec_all_clone0,
|
||||
@ -335,6 +348,7 @@ pub fn flatpak_update_page(
|
||||
&user_refs_for_upgrade_vec_all_clone0.borrow(),
|
||||
window,
|
||||
&retry_signal_action,
|
||||
&theme_changed_action,
|
||||
)
|
||||
}
|
||||
));
|
||||
|
@ -51,6 +51,7 @@ pub fn flatpak_process_update(
|
||||
user_refs_for_upgrade_vec_all: &Vec<FlatpakRefRow>,
|
||||
window: adw::ApplicationWindow,
|
||||
retry_signal_action: &SimpleAction,
|
||||
theme_changed_action: &SimpleAction,
|
||||
) {
|
||||
// Emulate Flatpak Full Upgrade to get transaction info
|
||||
let mut flatpak_changes_struct = FlatpakChangesInfo {
|
||||
@ -207,6 +208,7 @@ pub fn flatpak_process_update(
|
||||
flatpak_confirm_dialog.set_close_response("flatpak_confirm_dialog_cancel");
|
||||
|
||||
let retry_signal_action0 = retry_signal_action.clone();
|
||||
let theme_changed_action0 = theme_changed_action.clone();
|
||||
flatpak_confirm_dialog
|
||||
.clone()
|
||||
.choose(None::<&gio::Cancellable>, move |choice| {
|
||||
@ -216,6 +218,7 @@ pub fn flatpak_process_update(
|
||||
user_refs_for_upgrade_vec,
|
||||
window,
|
||||
&retry_signal_action0,
|
||||
&theme_changed_action0,
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -226,6 +229,7 @@ fn flatpak_run_transactions(
|
||||
user_refs_for_upgrade_vec: Vec<String>,
|
||||
window: adw::ApplicationWindow,
|
||||
retry_signal_action: &SimpleAction,
|
||||
theme_changed_action: &SimpleAction,
|
||||
) {
|
||||
let (transaction_percent_sender, transaction_percent_receiver) =
|
||||
async_channel::unbounded::<u32>();
|
||||
@ -363,7 +367,8 @@ fn flatpak_run_transactions(
|
||||
let flatpak_transaction_dialog_child_box =
|
||||
Box::builder().orientation(Orientation::Vertical).build();
|
||||
|
||||
let flatpak_transaction_dialog_progress_bar = circularprogressbar_rs::CircularProgressBar::new();
|
||||
let flatpak_transaction_dialog_progress_bar =
|
||||
circularprogressbar_rs::CircularProgressBar::new();
|
||||
flatpak_transaction_dialog_progress_bar.set_line_width(10.0);
|
||||
flatpak_transaction_dialog_progress_bar.set_fill_radius(true);
|
||||
flatpak_transaction_dialog_progress_bar.set_hexpand(true);
|
||||
@ -371,14 +376,48 @@ fn flatpak_run_transactions(
|
||||
flatpak_transaction_dialog_progress_bar.set_width_request(200);
|
||||
flatpak_transaction_dialog_progress_bar.set_height_request(200);
|
||||
#[allow(deprecated)]
|
||||
flatpak_transaction_dialog_progress_bar.set_progress_fill_color(window.style_context().lookup_color("accent_bg_color").unwrap());
|
||||
flatpak_transaction_dialog_progress_bar.set_progress_fill_color(
|
||||
window
|
||||
.style_context()
|
||||
.lookup_color("accent_bg_color")
|
||||
.unwrap(),
|
||||
);
|
||||
#[allow(deprecated)]
|
||||
flatpak_transaction_dialog_progress_bar.set_radius_fill_color(window.style_context().lookup_color("headerbar_bg_color").unwrap());
|
||||
flatpak_transaction_dialog_progress_bar.set_radius_fill_color(
|
||||
window
|
||||
.style_context()
|
||||
.lookup_color("headerbar_bg_color")
|
||||
.unwrap(),
|
||||
);
|
||||
#[warn(deprecated)]
|
||||
flatpak_transaction_dialog_progress_bar.set_progress_font(get_current_font());
|
||||
flatpak_transaction_dialog_progress_bar.set_center_text(t!("progress_bar_circle_center_text"));
|
||||
flatpak_transaction_dialog_progress_bar.set_fraction_font_size(24);
|
||||
flatpak_transaction_dialog_progress_bar.set_center_text_font_size(8);
|
||||
theme_changed_action.connect_activate(clone!(
|
||||
#[strong]
|
||||
window,
|
||||
#[strong]
|
||||
flatpak_transaction_dialog_progress_bar,
|
||||
move |_, _| {
|
||||
#[allow(deprecated)]
|
||||
flatpak_transaction_dialog_progress_bar.set_progress_fill_color(
|
||||
window
|
||||
.style_context()
|
||||
.lookup_color("accent_bg_color")
|
||||
.unwrap(),
|
||||
);
|
||||
#[allow(deprecated)]
|
||||
flatpak_transaction_dialog_progress_bar.set_radius_fill_color(
|
||||
window
|
||||
.style_context()
|
||||
.lookup_color("headerbar_bg_color")
|
||||
.unwrap(),
|
||||
);
|
||||
#[warn(deprecated)]
|
||||
flatpak_transaction_dialog_progress_bar.set_progress_font(get_current_font());
|
||||
}
|
||||
));
|
||||
|
||||
flatpak_transaction_dialog_child_box.append(&flatpak_transaction_dialog_progress_bar);
|
||||
|
||||
|
@ -21,10 +21,30 @@
|
||||
padding-bottom: 3px;
|
||||
}
|
||||
|
||||
.round-all-scroll-no-padding {
|
||||
border-top-right-radius: 15px;
|
||||
border-top-left-radius: 15px;
|
||||
border-bottom-right-radius: 15px;
|
||||
border-bottom-left-radius: 15px;
|
||||
padding-top: 0px;
|
||||
padding-right: 0px;
|
||||
padding-left: 0px;
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
|
||||
.no-round-borders {
|
||||
border-top-right-radius: 0px;
|
||||
border-top-left-radius: 0px;
|
||||
border-bottom-right-radius: 0px;
|
||||
border-bottom-left-radius: 0px;
|
||||
padding-top: 0px;
|
||||
padding-right: 0px;
|
||||
padding-left: 0px;
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
|
||||
.background-accent-bg {
|
||||
# background: @accent_bg_color;
|
||||
background: green;
|
||||
animation:blink 1s linear infinite;
|
||||
background: @accent_bg_color;
|
||||
border-radius: 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
@ -71,11 +91,3 @@
|
||||
.disable-outline {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
@keyframes blink{
|
||||
0%{opacity: 1;}
|
||||
25%{opacity: 0.75;}
|
||||
50%{opacity: 0.5;}
|
||||
75%{opacity: 0.75;}
|
||||
100%{opacity: 1;}
|
||||
}
|
@ -162,7 +162,8 @@ impl<'a> DynAcquireProgress for AptUpdateProgressSocket<'a> {
|
||||
let progress_percent: f32 =
|
||||
(status.current_bytes() as f32 * 100.0) / status.total_bytes() as f32;
|
||||
let speed = if self.pulse_interval != 0 {
|
||||
(status.current_bytes() as f64 - self.last_pulse_bytes as f64) / (self.pulse_interval as f64 / 1000000.0)
|
||||
(status.current_bytes() as f64 - self.last_pulse_bytes as f64)
|
||||
/ (self.pulse_interval as f64 / 1000000.0)
|
||||
} else {
|
||||
status.current_bytes() as f64 - self.last_pulse_bytes as f64
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user