diff --git a/.github/release-nest-v3 b/.github/release-nest-v3 index da2d398..19c7bdb 100644 --- a/.github/release-nest-v3 +++ b/.github/release-nest-v3 @@ -1 +1 @@ -14 \ No newline at end of file +16 \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 16332af..90824e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1774,6 +1774,7 @@ dependencies = [ "libadwaita", "libflatpak", "lock_api 0.4.12", + "os_pipe", "pretty-bytes", "regex", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index a67b120..d0244c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,4 +46,5 @@ strfmt = "0.2.4" configparser = "3.1.0" ksni = "0.2.2" single-instance = "0.3.3" +os_pipe = "1.1.5" diff --git a/Makefile b/Makefile index b4272e8..62187dc 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,8 @@ install: cp -vf data/pikman-update-manager-autostart $(DESTDIR)/usr/bin/ cp -vf data/flatpak-installer $(DESTDIR)/usr/bin/ cp -vf data/software-properties-gtk $(DESTDIR)/usr/bin/ - cp -vf target/release/apt_update $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/ +# cp -vf target/release/apt_update $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/ + cp -vf data/apt_update $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/ cp -vf target/release/apt_full_upgrade $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/ cp -vf data/modify_repo.sh $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/ cp -vf data/*.gschema.xml $(DESTDIR)/usr/share/glib-2.0/schemas/ @@ -41,7 +42,8 @@ install_no_build_debug: cp -vf data/pikman-update-manager-autostart $(DESTDIR)/usr/bin/ cp -vf data/flatpak-installer $(DESTDIR)/usr/bin/ cp -vf data/software-properties-gtk $(DESTDIR)/usr/bin/ - cp -vf target/debug/apt_update $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/ +# cp -vf target/debug/apt_update $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/ + cp -vf data/apt_update $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/ cp -vf target/debug/apt_full_upgrade $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/ cp -vf data/modify_repo.sh $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/ cp -vf data/*.gschema.xml $(DESTDIR)/usr/share/glib-2.0/schemas/ diff --git a/data/apt_update b/data/apt_update new file mode 100644 index 0000000..682d3d2 --- /dev/null +++ b/data/apt_update @@ -0,0 +1,2 @@ +#! /bin/bash +apt-get update -y \ No newline at end of file diff --git a/debian/changelog b/debian/changelog index 1187646..f07626e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pikman-update-manager (1.0.1-100pika5) pikauwu; urgency=medium +pikman-update-manager (1.0.1-100pika7) pikauwu; urgency=medium * initial release diff --git a/debian/control b/debian/control index 8b227cb..a9176f0 100644 --- a/debian/control +++ b/debian/control @@ -20,7 +20,7 @@ Standards-Version: 3.9.5 Package: pikman-update-manager Architecture: linux-any -Pre-Depends: apt +Pre-Depends: apt, libglib2.0-bin Depends: libadwaita-1-0, libgtk-4-1, coreutils, diff --git a/src/bin/gui/apt_update_page/mod.rs b/src/bin/gui/apt_update_page/mod.rs index b523de3..0151002 100644 --- a/src/bin/gui/apt_update_page/mod.rs +++ b/src/bin/gui/apt_update_page/mod.rs @@ -5,15 +5,43 @@ use adw::gio::SimpleAction; use adw::prelude::*; use gtk::glib::*; use gtk::*; -use pika_unixsocket_tools::pika_unixsocket_tools::*; +//use pika_unixsocket_tools::pika_unixsocket_tools::*; use rust_apt::cache::*; use rust_apt::new_cache; use rust_apt::records::RecordField; use std::cell::RefCell; -use std::process::Command; +//use std::process::Command; +use std::io::BufRead; +use std::io::BufReader; use std::rc::Rc; use std::thread; -use tokio::runtime::Runtime; +//use tokio::runtime::Runtime; +use duct::cmd; + +enum AddonChannelMsg { + LogLoopLine(String), + LogLoopStatus(bool) +} + +fn run_addon_command( + log_loop_sender: async_channel::Sender, +) -> Result<(), std::boxed::Box> { + 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()?; + for line in BufReader::new(pipe_reader).lines() { + let line_clone = line?; + log_loop_sender + .send_blocking(AddonChannelMsg::LogLoopLine(line_clone.clone())) + .expect("Channel needs to be opened."); + println!("{}", line_clone); + } + child.wait()?; + + Ok(()) +} #[derive(Clone)] pub struct AptPackageSocket { @@ -37,13 +65,13 @@ pub fn apt_update_page( apt_update_count: &Rc>, flatpak_update_count: &Rc>, ) -> gtk::Box { - let (update_percent_sender, update_percent_receiver) = async_channel::unbounded::(); - let update_percent_sender = update_percent_sender.clone(); + /*let (update_percent_sender, update_percent_receiver) = async_channel::unbounded::(); + //let update_percent_sender = update_percent_sender.clone(); let (update_speed_sender, update_speed_receiver) = async_channel::unbounded::(); - let update_speed_sender = update_speed_sender.clone(); + //let update_speed_sender = update_speed_sender.clone(); let (update_status_sender, update_status_receiver) = async_channel::unbounded::(); - let update_status_sender = update_status_sender.clone(); - let update_status_sender_clone0 = update_status_sender.clone(); + //let update_status_sender = update_status_sender.clone(); + //let update_status_sender_clone0 = update_status_sender.clone();*/ let (get_upgradable_sender, get_upgradable_receiver) = async_channel::unbounded(); let get_upgradable_sender = get_upgradable_sender.clone(); @@ -51,7 +79,7 @@ pub fn apt_update_page( let excluded_updates_vec: Rc>> = Rc::new(RefCell::new(Vec::new())); - thread::spawn(move || { + /*thread::spawn(move || { Runtime::new().unwrap().block_on(start_socket_server_no_log( update_percent_sender, "/tmp/pika_apt_update_percent.sock", @@ -110,7 +138,29 @@ pub fn apt_update_page( } } }; + });*/ + + // TEMP APT FIX + let (log_loop_sender, log_loop_receiver) = async_channel::unbounded(); + let log_loop_sender: async_channel::Sender = log_loop_sender.clone(); + + let log_loop_sender_clone0 = log_loop_sender.clone(); + let log_loop_sender_clone1 = log_loop_sender.clone(); + + 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."); + } + } }); + // End of TEMP APT FIX let main_box = Box::builder() .hexpand(true) @@ -165,8 +215,26 @@ pub fn apt_update_page( .child(&packages_no_viewport_page) .build(); - let apt_update_dialog_child_box = Box::builder().orientation(Orientation::Vertical).build(); + //let apt_update_dialog_child_box = Box::builder().orientation(Orientation::Vertical).build(); + let log_terminal_buffer = gtk::TextBuffer::builder().build(); + + let log_terminal = gtk::TextView::builder() + .vexpand(true) + .hexpand(true) + .editable(false) + .buffer(&log_terminal_buffer) + .build(); + + let log_terminal_scroll = gtk::ScrolledWindow::builder() + .width_request(400) + .height_request(200) + .vexpand(true) + .hexpand(true) + .child(&log_terminal) + .build(); + + /* let apt_update_dialog_progress_bar = ProgressBar::builder().show_text(true).hexpand(true).build(); @@ -184,14 +252,16 @@ pub fn apt_update_page( .margin_top(10) .margin_bottom(10) .build(); - + apt_update_dialog_child_box.append(&apt_update_dialog_spinner); apt_update_dialog_child_box.append(&apt_speed_label); apt_update_dialog_child_box.append(&apt_update_dialog_progress_bar); + */ let apt_update_dialog = adw::MessageDialog::builder() .transient_for(&window) - .extra_child(&apt_update_dialog_child_box) + //.extra_child(&apt_update_dialog_child_box) + .extra_child(&log_terminal_scroll) .heading(t!("apt_update_dialog_heading")) .width_request(500) .build(); @@ -301,7 +371,7 @@ pub fn apt_update_page( bottom_bar.append(&select_button); bottom_bar.append(&update_button); - let update_percent_server_context = MainContext::default(); + /*let update_percent_server_context = MainContext::default(); // The main loop executes the asynchronous block update_percent_server_context.spawn_local(clone!( #[weak] @@ -388,6 +458,75 @@ pub fn apt_update_page( } } )); + */ + + let update_status_server_context = MainContext::default(); + // The main loop executes the asynchronous block + update_status_server_context.spawn_local(clone!( + #[strong] + apt_update_dialog, + #[strong] + log_terminal_buffer, + #[strong] + flatpak_retry_signal_action, + #[strong] + apt_update_count, + #[strong] + flatpak_update_count, + #[strong] + update_sys_tray, + async move { + while let Ok(state) = log_loop_receiver.recv().await { + match state { + AddonChannelMsg::LogLoopStatus(state) => { + 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()); + 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(), + ]))); + } + false => { + get_apt_upgrades(&get_upgradable_sender); + //apt_update_dialog_child_box.set_visible(false); + apt_update_dialog.set_extra_child(Some( + &Image::builder() + .pixel_size(128) + .icon_name("dialog-error-symbolic") + .halign(Align::Center) + .build(), + )); + 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); + 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(), + ]))); + } + } + } + AddonChannelMsg::LogLoopLine(state) => { + log_terminal_buffer.insert(&mut log_terminal_buffer.end_iter(), &("\n".to_string() + &state)) + } + } + } + } + )); let get_upgradable_server_context = MainContext::default(); // The main loop executes the asynchronous block diff --git a/src/bin/gui/build_ui/mod.rs b/src/bin/gui/build_ui/mod.rs index f43fec3..0dc9a2b 100644 --- a/src/bin/gui/build_ui/mod.rs +++ b/src/bin/gui/build_ui/mod.rs @@ -450,15 +450,13 @@ pub fn build_ui(app: &Application) { let apt_update_view_stack_bin = Bin::builder().build(); apt_retry_signal_action.connect_activate(clone!( - #[weak] - window, #[strong] - apt_retry_signal_action, + window, #[strong] flatpak_retry_signal_action, #[strong] apt_update_view_stack_bin, - #[weak] + #[strong] flatpak_ran_once, #[strong] update_sys_tray, @@ -466,12 +464,12 @@ pub fn build_ui(app: &Application) { apt_update_count, #[strong] flatpak_update_count, - move |_, _| { + move |action, _| { apt_update_view_stack_bin.set_child(Some(&apt_update_page::apt_update_page( - window, - &apt_retry_signal_action, + window.clone(), + &action, &flatpak_retry_signal_action, - flatpak_ran_once, + flatpak_ran_once.clone(), &update_sys_tray, &apt_update_count, &flatpak_update_count, @@ -483,7 +481,7 @@ pub fn build_ui(app: &Application) { window.clone(), &apt_retry_signal_action, &flatpak_retry_signal_action, - flatpak_ran_once, + flatpak_ran_once.clone(), &update_sys_tray, &apt_update_count, &flatpak_update_count, diff --git a/src/bin/gui/style.css b/src/bin/gui/style.css index cb96f95..8061ebd 100644 --- a/src/bin/gui/style.css +++ b/src/bin/gui/style.css @@ -22,7 +22,9 @@ } .background-accent-bg { - background: @accent_bg_color; +# background: @accent_bg_color; + background: green; + animation:blink 1s linear infinite; border-radius: 10px; padding: 5px; } @@ -68,4 +70,12 @@ .disable-outline { outline: none; +} + +@keyframes blink{ + 0%{opacity: 1;} + 25%{opacity: 0.75;} + 50%{opacity: 0.5;} + 75%{opacity: 0.75;} + 100%{opacity: 1;} } \ No newline at end of file