diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 04ab7f9..596a428 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -9,9 +9,16 @@ + + + + + + + - { + "keyToString": { + "ASKED_ADD_EXTERNAL_FILES": "true", + "Cargo.Build all.executor": "Run", + "Cargo.Run apt_update.executor": "Run", + "Cargo.Run pikman-update-manager.executor": "Run", + "Cargo.Test pikman-update-manager.executor": "Run", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.rust.reset.selective.auto.import": "true", + "git-widget-placeholder": "main", + "last_opened_file_path": "/home/ward/RustroverProjects/pikman-update-manager", + "node.js.detected.package.eslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "org.rust.cargo.project.model.PROJECT_DISCOVERY": "true", + "org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "", + "org.rust.disableDetachedFileInspection/home/ward/RustroverProjects/pikman-update-manager/src/apt_update_progress_socket/lib.rs": "true", + "org.rust.first.attach.projects": "true" } -}]]> +} @@ -128,9 +135,9 @@ + - @@ -162,7 +169,9 @@ - + + + diff --git a/src/bin/apt/apt_full_upgrade/main.rs b/src/bin/apt/apt_full_upgrade/main.rs index 5d81f9b..6f00044 100644 --- a/src/bin/apt/apt_full_upgrade/main.rs +++ b/src/bin/apt/apt_full_upgrade/main.rs @@ -4,8 +4,6 @@ use pika_unixsocket_tools::pika_unixsocket_tools::*; use rust_apt::cache::Upgrade; use rust_apt::new_cache; use rust_apt::progress::{AcquireProgress, InstallProgress}; -use std::fs::*; -use std::process::exit; use tokio::runtime::Runtime; fn main() { diff --git a/src/bin/apt/apt_update/main.rs b/src/bin/apt/apt_update/main.rs index d3622f2..cd44841 100644 --- a/src/bin/apt/apt_update/main.rs +++ b/src/bin/apt/apt_update/main.rs @@ -1,8 +1,7 @@ use pika_unixsocket_tools::apt_update_progress_socket::AptUpdateProgressSocket; use pika_unixsocket_tools::pika_unixsocket_tools::*; use rust_apt::new_cache; -use rust_apt::progress::{AcquireProgress, DynAcquireProgress}; -use tokio::io::{AsyncReadExt, AsyncWriteExt}; +use rust_apt::progress::{AcquireProgress}; use tokio::runtime::Runtime; fn main() { diff --git a/src/bin/gui/apt_package_row/imp.rs b/src/bin/gui/apt_package_row/imp.rs index 6968bb2..a709094 100644 --- a/src/bin/gui/apt_package_row/imp.rs +++ b/src/bin/gui/apt_package_row/imp.rs @@ -1,14 +1,11 @@ -use std::{cell::RefCell, default, sync::OnceLock}; +use std::{cell::RefCell, sync::OnceLock}; -use crate::apt_update_page::AptPackageSocket; use adw::*; use adw::{prelude::*, subclass::prelude::*}; use glib::{clone, subclass::Signal, Properties}; -use gtk::Orientation::Horizontal; use gtk::*; use pretty_bytes::converter::convert; use std::env; -use std::os::unix::raw::nlink_t; // ANCHOR: custom_button // Object holding the state @@ -43,7 +40,7 @@ pub struct AptPackageRow { impl ObjectSubclass for AptPackageRow { const NAME: &'static str = "AptPackageRow"; type Type = super::AptPackageRow; - type ParentType = adw::ExpanderRow; + type ParentType = ExpanderRow; } // ANCHOR: object_impl @@ -77,11 +74,11 @@ impl ObjectImpl for AptPackageRow { // `SYNC_CREATE` ensures that the label will be immediately set let obj = self.obj(); - let prefix_box = gtk::Box::new(Orientation::Vertical, 0); + let prefix_box = Box::new(Orientation::Vertical, 0); - let expandable_box = gtk::Box::new(Orientation::Vertical, 0); + let expandable_box = Box::new(Orientation::Vertical, 0); - obj.connect_package_name_notify(clone!(@weak prefix_box, @weak expandable_box, @strong obj => move |obj| { + obj.connect_package_name_notify(clone!(#[weak] prefix_box, #[weak] expandable_box, #[strong] obj, move |_| { remove_all_children_from_box(&prefix_box); remove_all_children_from_box(&expandable_box); // @@ -97,13 +94,13 @@ impl ObjectImpl for AptPackageRow { // create_prefix_content(&prefix_box, &package_name, &package_arch, &package_installed_version, &package_candidate_version); // - create_expandable_content(obj, &expandable_box, package_description, package_source_uri, package_maintainer, package_size, package_installed_size); + create_expandable_content(&obj, &expandable_box, package_description, package_source_uri, package_maintainer, package_size, package_installed_size); })); obj.add_prefix(&prefix_box); obj.add_row(&expandable_box); - let suffix_toggle = gtk::CheckButton::builder() + let suffix_toggle = CheckButton::builder() .tooltip_text(t!("mark_for_update")) .halign(Align::Center) .valign(Align::Center) @@ -111,7 +108,7 @@ impl ObjectImpl for AptPackageRow { .vexpand(false) .build(); - suffix_toggle.connect_toggled(clone!( @weak obj, @weak suffix_toggle => move |_| { + suffix_toggle.connect_toggled(clone!( #[weak] obj, #[weak] suffix_toggle, move |_| { if suffix_toggle.is_active() { obj.emit_by_name::<()>("checkbutton-toggled", &[]); } else { @@ -141,11 +138,11 @@ impl ListBoxRowImpl for AptPackageRow {} impl PreferencesRowImpl for AptPackageRow {} impl ExpanderRowImpl for AptPackageRow {} -fn create_version_badge(installed_version: &str, candidate_version: &str) -> gtk::ListBox { +fn create_version_badge(installed_version: &str, candidate_version: &str) -> ListBox { let (base_version, installed_diff, candidate_diff) = get_diff_by_prefix(installed_version, candidate_version); - let badge_box = gtk::Box::builder() + let badge_box = Box::builder() .halign(Align::Start) .hexpand(false) .orientation(Orientation::Horizontal) @@ -155,14 +152,14 @@ fn create_version_badge(installed_version: &str, candidate_version: &str) -> gtk .margin_top(5) .build(); - let installed_version_box = gtk::Box::builder() + let installed_version_box = Box::builder() .halign(Align::Start) .hexpand(false) .orientation(Orientation::Horizontal) .tooltip_text(t!("installed_version_badge_text")) .build(); - let installed_version_base_version_label = gtk::Label::builder() + let installed_version_base_version_label = Label::builder() .label(format!( "{}: {}", t!("installed_version_badge_text"), @@ -174,7 +171,7 @@ fn create_version_badge(installed_version: &str, candidate_version: &str) -> gtk .vexpand(true) .build(); - let installed_diff_label = gtk::Label::builder() + let installed_diff_label = Label::builder() .label(installed_diff) .valign(Align::Center) .halign(Align::Start) @@ -186,19 +183,19 @@ fn create_version_badge(installed_version: &str, candidate_version: &str) -> gtk installed_version_box.append(&installed_version_base_version_label.clone()); installed_version_box.append(&installed_diff_label); - let label_separator = gtk::Separator::builder() + let label_separator = Separator::builder() .margin_start(5) .margin_end(5) .build(); - let candidate_version_box = gtk::Box::builder() + let candidate_version_box = Box::builder() .halign(Align::Start) .hexpand(false) .orientation(Orientation::Horizontal) .tooltip_text(t!("candidate_version_badge_text")) .build(); - let candidate_version_base_version_label = gtk::Label::builder() + let candidate_version_base_version_label = Label::builder() .label(format!( "{}: {}", t!("candidate_version_badge_text"), @@ -210,7 +207,7 @@ fn create_version_badge(installed_version: &str, candidate_version: &str) -> gtk .vexpand(true) .build(); - let candidate_diff_label = gtk::Label::builder() + let candidate_diff_label = Label::builder() .label(candidate_diff) .valign(Align::Center) .halign(Align::Start) @@ -226,7 +223,7 @@ fn create_version_badge(installed_version: &str, candidate_version: &str) -> gtk badge_box.append(&label_separator); badge_box.append(&candidate_version_box); - let boxedlist = gtk::ListBox::builder() + let boxedlist = ListBox::builder() .selection_mode(SelectionMode::None) .halign(Align::Start) .valign(Align::End) @@ -240,8 +237,8 @@ fn create_version_badge(installed_version: &str, candidate_version: &str) -> gtk boxedlist } -fn create_arch_badge(arch: &str) -> gtk::ListBox { - let arch_label = gtk::Label::builder() +fn create_arch_badge(arch: &str) -> ListBox { + let arch_label = Label::builder() .halign(Align::Start) .hexpand(false) .label(format!("{}: {}", t!("arch_label_label"), arch)) @@ -251,7 +248,7 @@ fn create_arch_badge(arch: &str) -> gtk::ListBox { .margin_top(5) .build(); - let boxedlist = gtk::ListBox::builder() + let boxedlist = ListBox::builder() .selection_mode(SelectionMode::None) .halign(Align::Start) .valign(Align::End) @@ -278,7 +275,7 @@ fn create_prefix_content( package_installed_version: &str, package_candidate_version: &str, ) { - let package_label = gtk::Label::builder() + let package_label = Label::builder() .halign(Align::Start) .margin_start(5) .margin_end(5) @@ -287,7 +284,7 @@ fn create_prefix_content( .label(package_name) .build(); package_label.add_css_class("size-20-bold-text"); - let version_box = gtk::Box::new(Orientation::Horizontal, 0); + let version_box = Box::new(Orientation::Horizontal, 0); version_box.append(&create_version_badge( package_installed_version, package_candidate_version, @@ -306,7 +303,7 @@ fn create_expandable_content( package_size: u64, package_installed_size: u64, ) { - let expandable_page_selection_box = gtk::Box::builder() + let expandable_page_selection_box = Box::builder() .orientation(Orientation::Horizontal) .hexpand(false) .vexpand(false) @@ -319,19 +316,19 @@ fn create_expandable_content( .build(); expandable_page_selection_box.add_css_class("linked"); // - let description_page_button = gtk::ToggleButton::builder() + let description_page_button = ToggleButton::builder() .label(t!("description_button_label")) .active(true) .build(); - let extra_info_page_button = gtk::ToggleButton::builder() + let extra_info_page_button = ToggleButton::builder() .label(t!("extra_info_page_button_label")) .group(&description_page_button) .build(); - let uris_page_button = gtk::ToggleButton::builder() + let uris_page_button = ToggleButton::builder() .label(t!("uris_page_button_label")) .group(&description_page_button) .build(); - let changelog_page_button = gtk::ToggleButton::builder() + let changelog_page_button = ToggleButton::builder() .label(t!("changelog_page_button_label")) // till we find a way to implement .sensitive(false) @@ -344,31 +341,31 @@ fn create_expandable_content( // expandable_box.append(&expandable_page_selection_box); // - let expandable_bin = adw::Bin::builder().hexpand(true).vexpand(true).build(); + let expandable_bin = Bin::builder().hexpand(true).vexpand(true).build(); // description_page_button.connect_clicked( - clone!(@strong expandable_bin, @strong description_page_button => move |_|{ + clone!(#[strong] expandable_bin, #[strong] description_page_button, move |_|{ if description_page_button.is_active() { expandable_bin.set_child(Some(&description_stack_page(&package_description))); } }), ); - extra_info_page_button.connect_clicked(clone!(@strong expandable_bin, @strong extra_info_page_button => move |_|{ + extra_info_page_button.connect_clicked(clone!(#[strong] expandable_bin, #[strong] extra_info_page_button, move |_|{ if extra_info_page_button.is_active() { expandable_bin.set_child(Some(&extra_info_stack_page(&package_maintainer, package_size, package_installed_size))); } })); uris_page_button.connect_clicked( - clone!(@strong expandable_bin, @strong uris_page_button => move |_|{ + clone!(#[strong] expandable_bin, #[strong] uris_page_button, move |_|{ if uris_page_button.is_active() { expandable_bin.set_child(Some(&uris_stack_page(&package_source_uri))); } }), ); - apt_package_row.connect_expanded_notify(clone!(@strong expandable_bin, @strong expandable_box, @strong apt_package_row, @strong description_page_button => move |apt_package_row| { + apt_package_row.connect_expanded_notify(clone!(#[strong] expandable_bin, #[strong] expandable_box, #[strong] apt_package_row, #[strong] description_page_button, move |_| { if apt_package_row.property("expanded") { description_page_button.set_active(true); description_page_button.emit_by_name::<()>("clicked", &[]); @@ -382,15 +379,15 @@ fn create_expandable_content( } fn uris_stack_page(package_source_uri: &str) -> gtk::Box { - let uris_content_box = gtk::Box::builder() + let uris_content_box = Box::builder() .hexpand(true) .vexpand(true) .orientation(Orientation::Vertical) .build(); - let uris_text_buffer = gtk::TextBuffer::builder() + let uris_text_buffer = TextBuffer::builder() .text(package_source_uri.to_owned() + "\n") .build(); - let uris_text_view = gtk::TextView::builder() + let uris_text_view = TextView::builder() .buffer(&uris_text_buffer) .hexpand(true) .vexpand(true) @@ -406,15 +403,15 @@ fn uris_stack_page(package_source_uri: &str) -> gtk::Box { } fn description_stack_page(package_description: &str) -> gtk::Box { - let description_content_box = gtk::Box::builder() + let description_content_box = Box::builder() .hexpand(true) .vexpand(true) .orientation(Orientation::Vertical) .build(); - let description_text_buffer = gtk::TextBuffer::builder() + let description_text_buffer = TextBuffer::builder() .text(package_description.to_owned() + "\n") .build(); - let description_text_view = gtk::TextView::builder() + let description_text_view = TextView::builder() .buffer(&description_text_buffer) .hexpand(true) .vexpand(true) @@ -433,14 +430,14 @@ fn extra_info_stack_page( package_size: u64, package_installed_size: u64, ) -> gtk::Box { - let extra_info_badges_content_box = gtk::Box::builder() + let extra_info_badges_content_box = Box::builder() .hexpand(true) .vexpand(true) .orientation(Orientation::Vertical) .build(); - let extra_info_badges_size_group = gtk::SizeGroup::new(SizeGroupMode::Both); - let extra_info_badges_size_group0 = gtk::SizeGroup::new(SizeGroupMode::Both); - let extra_info_badges_size_group1 = gtk::SizeGroup::new(SizeGroupMode::Both); + let extra_info_badges_size_group = SizeGroup::new(SizeGroupMode::Both); + let extra_info_badges_size_group0 = SizeGroup::new(SizeGroupMode::Both); + let extra_info_badges_size_group1 = SizeGroup::new(SizeGroupMode::Both); let package_size = package_size as f64; let package_installed_size = package_installed_size as f64; extra_info_badges_content_box.append(&create_color_badge( @@ -473,13 +470,13 @@ fn create_color_badge( label0_text: &str, label1_text: &str, css_style: &str, - group_size: >k::SizeGroup, - group_size0: >k::SizeGroup, - group_size1: >k::SizeGroup, -) -> gtk::ListBox { - let badge_box = gtk::Box::builder().build(); + group_size: &SizeGroup, + group_size0: &SizeGroup, + group_size1: &SizeGroup, +) -> ListBox { + let badge_box = Box::builder().build(); - let label0 = gtk::Label::builder() + let label0 = Label::builder() .label(label0_text) .margin_start(5) .margin_end(5) @@ -492,9 +489,9 @@ fn create_color_badge( .build(); group_size0.add_widget(&label0); - let label_seprator = gtk::Separator::builder().build(); + let label_separator = Separator::builder().build(); - let label1 = gtk::Label::builder() + let label1 = Label::builder() .label(label1_text) .margin_start(3) .margin_end(0) @@ -510,10 +507,10 @@ fn create_color_badge( label1.add_css_class(css_style); badge_box.append(&label0); - badge_box.append(&label_seprator); + badge_box.append(&label_separator); badge_box.append(&label1); - let boxedlist = gtk::ListBox::builder() + let boxedlist = ListBox::builder() .selection_mode(SelectionMode::None) .halign(Align::Start) .valign(Align::Start) diff --git a/src/bin/gui/apt_update_page/mod.rs b/src/bin/gui/apt_update_page/mod.rs index ca5be7f..8c4d072 100644 --- a/src/bin/gui/apt_update_page/mod.rs +++ b/src/bin/gui/apt_update_page/mod.rs @@ -1,28 +1,19 @@ mod process; use crate::apt_package_row::AptPackageRow; -use adw::gio::{Action, SimpleAction}; +use adw::gio::{SimpleAction}; use adw::prelude::*; -use adw::ActionRow; use gtk::glib::*; use gtk::*; use pika_unixsocket_tools::pika_unixsocket_tools::*; use rust_apt::cache::*; use rust_apt::new_cache; use rust_apt::records::RecordField; -use rust_apt::*; use std::cell::RefCell; -use std::ops::Deref; -use std::path::Path; use std::process::Command; use std::rc::Rc; -use std::sync::atomic::AtomicBool; -use std::sync::Arc; -use std::{fs, thread}; -use tokio::io::AsyncReadExt; -use tokio::net::{UnixListener, UnixStream}; +use std::{thread}; use tokio::runtime::Runtime; -use tokio::task; pub struct AptPackageSocket { pub name: String, @@ -86,13 +77,13 @@ pub fn apt_update_page( } }); - let main_box = gtk::Box::builder() + let main_box = Box::builder() .hexpand(true) .vexpand(true) .orientation(Orientation::Vertical) .build(); - let searchbar = gtk::SearchEntry::builder() + let searchbar = SearchEntry::builder() .search_delay(500) .margin_top(15) .margin_bottom(15) @@ -101,16 +92,15 @@ pub fn apt_update_page( .build(); searchbar.add_css_class("rounded-all-25"); - let packages_boxedlist = gtk::ListBox::builder() + let packages_boxedlist = ListBox::builder() .selection_mode(SelectionMode::None) .margin_end(15) .margin_start(15) .sensitive(false) .build(); packages_boxedlist.add_css_class("boxed-list"); - let rows_size_group = gtk::SizeGroup::new(SizeGroupMode::Both); - - let packages_viewport = gtk::ScrolledWindow::builder() + + let packages_viewport = ScrolledWindow::builder() .vexpand(true) .hexpand(true) .margin_bottom(15) @@ -121,16 +111,16 @@ pub fn apt_update_page( .child(&packages_boxedlist) .build(); - let apt_update_dialog_child_box = gtk::Box::builder() + let apt_update_dialog_child_box = Box::builder() .orientation(Orientation::Vertical) .build(); - let apt_update_dialog_progress_bar = gtk::ProgressBar::builder() + let apt_update_dialog_progress_bar = ProgressBar::builder() .show_text(true) .hexpand(true) .build(); - let apt_update_dialog_spinner = gtk::Spinner::builder() + let apt_update_dialog_spinner = Spinner::builder() .hexpand(true) .valign(Align::Start) .halign(Align::Center) @@ -171,9 +161,9 @@ pub fn apt_update_page( } }); - let bottom_bar = gtk::Box::builder().valign(Align::End).build(); + let bottom_bar = Box::builder().valign(Align::End).build(); - let select_button = gtk::Button::builder() + let select_button = Button::builder() .halign(Align::End) .valign(Align::Center) .hexpand(true) @@ -183,7 +173,7 @@ pub fn apt_update_page( .label(t!("select_button_deselect_all")) .build(); - select_button.connect_clicked(clone!(@weak select_button, @weak packages_boxedlist => move |_| { + select_button.connect_clicked(clone!(#[weak] select_button, #[weak] packages_boxedlist, move |_| { let select_button_label = select_button.label().unwrap(); let value_to_mark = if select_button_label == t!("select_button_select_all").to_string() { true @@ -195,7 +185,7 @@ pub fn apt_update_page( set_all_apt_row_marks_to(&packages_boxedlist, value_to_mark) })); - let update_button = gtk::Button::builder() + let update_button = Button::builder() .halign(Align::End) .valign(Align::Center) .hexpand(false) @@ -207,7 +197,7 @@ pub fn apt_update_page( update_button.add_css_class("destructive-action"); update_button.connect_clicked( - clone!(@weak window, @weak retry_signal_action, @strong excluded_updates_vec => move |_| { + clone!(#[weak] window, #[weak] retry_signal_action, #[strong] excluded_updates_vec, move |_| { process::apt_process_update(&excluded_updates_vec.borrow(), window, &retry_signal_action); }), ); @@ -217,7 +207,7 @@ pub fn apt_update_page( let update_percent_server_context = MainContext::default(); // The main loop executes the asynchronous block - update_percent_server_context.spawn_local(clone!(@weak apt_update_dialog_progress_bar, @weak apt_update_dialog, @strong get_upgradable_sender => async move { + update_percent_server_context.spawn_local(clone!(#[weak] apt_update_dialog_progress_bar, async move { while let Ok(state) = update_percent_receiver.recv().await { apt_update_dialog_progress_bar.set_fraction(state.parse::().unwrap()/100.0) } @@ -226,7 +216,7 @@ 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!(@weak apt_update_dialog, @weak apt_update_dialog_child_box => async move { + clone!(#[weak] apt_update_dialog, #[weak] apt_update_dialog_child_box, async move { while let Ok(state) = update_status_receiver.recv().await { match state.as_ref() { "FN_OVERRIDE_SUCCESSFUL" => { @@ -272,7 +262,7 @@ pub fn apt_update_page( } "FN_OVERRIDE_FAILED" => { apt_update_dialog_child_box.set_visible(false); - apt_update_dialog.set_extra_child(Some(>k::Image::builder().pixel_size(128).icon_name("dialog-error-symbolic").halign(Align::Center).build())); + 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); } @@ -285,7 +275,7 @@ pub fn apt_update_page( let get_upgradable_server_context = MainContext::default(); // The main loop executes the asynchronous block get_upgradable_server_context.spawn_local( - clone!(@weak select_button, @weak update_button, @weak packages_boxedlist, @strong excluded_updates_vec => async move { + clone!(#[weak] select_button, #[weak] update_button, #[weak] packages_boxedlist, #[strong] excluded_updates_vec, async move { while let Ok(state) = get_upgradable_receiver.recv().await { let apt_row = AptPackageRow::new(AptPackageSocket { name: state.name, @@ -302,7 +292,7 @@ pub fn apt_update_page( apt_row.connect_closure( "checkbutton-toggled", false, - closure_local!(@strong apt_row, @strong select_button, @strong update_button, @strong packages_boxedlist, @strong excluded_updates_vec => move |apt_row: AptPackageRow| { + closure_local!(#[strong] select_button, #[strong] update_button, #[strong] packages_boxedlist, #[strong] excluded_updates_vec, move |apt_row: AptPackageRow| { if is_widget_select_all_ready(&packages_boxedlist) { select_button.set_label(&t!("select_button_select_all").to_string()); } else { @@ -315,7 +305,7 @@ pub fn apt_update_page( apt_row.connect_closure( "checkbutton-untoggled", false, - closure_local!(@strong apt_row, @strong select_button, @strong update_button, @strong packages_boxedlist, @strong excluded_updates_vec => move |apt_row: AptPackageRow| { + closure_local!(#[strong] select_button, #[strong] update_button, #[strong] packages_boxedlist, #[strong] excluded_updates_vec, move |apt_row: AptPackageRow| { select_button.set_label(&t!("select_button_select_all").to_string()); update_button.set_sensitive(!is_all_children_unmarked(&packages_boxedlist)); excluded_updates_vec.borrow_mut().push(apt_row.package_name()) @@ -329,7 +319,7 @@ pub fn apt_update_page( }), ); - searchbar.connect_search_changed(clone!(@weak searchbar, @weak packages_boxedlist => move |_| { + searchbar.connect_search_changed(clone!(#[weak] searchbar, #[weak] packages_boxedlist, move |_| { let mut counter = packages_boxedlist.first_child(); while let Some(row) = counter { if row.widget_name() == "AptPackageRow" { diff --git a/src/bin/gui/apt_update_page/process.rs b/src/bin/gui/apt_update_page/process.rs index f42febd..465da4e 100644 --- a/src/bin/gui/apt_update_page/process.rs +++ b/src/bin/gui/apt_update_page/process.rs @@ -12,7 +12,7 @@ use serde::Serialize; use serde_json::Value; use std::path::Path; use std::process::Command; -use std::{fs::*, thread}; +use std::{thread}; use std::cell::RefCell; use std::rc::Rc; use tokio::runtime::Runtime; @@ -86,10 +86,10 @@ pub fn apt_process_update( excluded_updates_alert_dialog.set_default_response(Some("excluded_updates_alert_continue")); let excluded_updates_alert_dialog_action = - gio::SimpleAction::new("excluded_updates_alert_dialog_action", None); + SimpleAction::new("excluded_updates_alert_dialog_action", None); excluded_updates_alert_dialog_action.connect_activate( - clone!(@weak window, @weak retry_signal_action, @strong excluded_updates_vec => move |_, _| { + clone!(#[weak] window, #[weak] retry_signal_action, #[strong] excluded_updates_vec, move |_, _| { apt_confirm_window(&excluded_updates_vec, window, &retry_signal_action) }), ); @@ -182,13 +182,13 @@ fn apt_confirm_window( } } - let apt_confirm_dialog_child_box = gtk::Box::builder() + let apt_confirm_dialog_child_box = Box::builder() .orientation(Orientation::Vertical) .build(); - let apt_update_dialog_badges_size_group = gtk::SizeGroup::new(SizeGroupMode::Both); - let apt_update_dialog_badges_size_group0 = gtk::SizeGroup::new(SizeGroupMode::Both); - let apt_update_dialog_badges_size_group1 = gtk::SizeGroup::new(SizeGroupMode::Both); + let apt_update_dialog_badges_size_group = SizeGroup::new(SizeGroupMode::Both); + let apt_update_dialog_badges_size_group0 = SizeGroup::new(SizeGroupMode::Both); + let apt_update_dialog_badges_size_group1 = SizeGroup::new(SizeGroupMode::Both); apt_confirm_dialog_child_box.append(&create_color_badge( &t!("package_count_upgrade_badge_label"), @@ -290,9 +290,9 @@ fn apt_confirm_window( .expect("Failed to write to json file"); } - let apt_confirm_start_signal_action = gio::SimpleAction::new("apt_confirm_start", None); + let apt_confirm_start_signal_action = SimpleAction::new("apt_confirm_start", None); - apt_confirm_start_signal_action.connect_activate(clone!(@weak window, @strong retry_signal_action, @strong apt_confirm_dialog => move |_, _| { + apt_confirm_start_signal_action.connect_activate(clone!(#[weak] window, #[strong] retry_signal_action, #[strong] apt_confirm_dialog, move |_, _| { let retry_signal_action0 = retry_signal_action.clone(); apt_confirm_dialog.clone().choose(None::<&gio::Cancellable>, move |choice| { if choice == "apt_confirm_dialog_confirm" { @@ -305,11 +305,11 @@ fn apt_confirm_window( if to_be_removed_packages_borrow.is_empty() { apt_confirm_start_signal_action.activate(None); } else { - let apt_remove_confirm_text_buffer = gtk::TextBuffer::builder() + let apt_remove_confirm_text_buffer = TextBuffer::builder() .text(to_be_removed_packages_borrow.iter().map(|x| x.to_string() + "\n").collect::() + "\n") .build(); - let description_text_view = gtk::TextView::builder() + let apt_remove_confirm_text_view = TextView::builder() .buffer(&apt_remove_confirm_text_buffer) .hexpand(true) .vexpand(true) @@ -324,7 +324,7 @@ fn apt_confirm_window( .transient_for(&window) .heading(t!("apt_remove_confirm_dialog_heading")) .body(t!("apt_remove_confirm_dialog_body")) - .extra_child(&description_text_view) + .extra_child(&apt_remove_confirm_text_view) .build(); apt_remove_confirm_dialog.add_response( @@ -407,16 +407,16 @@ fn apt_full_upgrade_from_socket( } }); - let apt_upgrade_dialog_child_box = gtk::Box::builder() + let apt_upgrade_dialog_child_box = Box::builder() .orientation(Orientation::Vertical) .build(); - let apt_upgrade_dialog_progress_bar = gtk::ProgressBar::builder() + let apt_upgrade_dialog_progress_bar = ProgressBar::builder() .show_text(true) .hexpand(true) .build(); - let apt_upgrade_dialog_spinner = gtk::Spinner::builder() + let apt_upgrade_dialog_spinner = Spinner::builder() .hexpand(true) .valign(Align::Start) .halign(Align::Center) @@ -440,16 +440,16 @@ fn apt_full_upgrade_from_socket( &t!("apt_upgrade_dialog_ok_label").to_string(), ); - let apt_upgrade_dialog_child_box_done = gtk::Box::builder() + let apt_upgrade_dialog_child_box_done = Box::builder() .orientation(Orientation::Vertical) .build(); - let apt_upgrade_log_image = gtk::Image::builder() + let apt_upgrade_log_image = Image::builder() .pixel_size(128) .halign(Align::Center) .build(); - let apt_upgrade_log_button = gtk::Button::builder() + let apt_upgrade_log_button = Button::builder() .label(t!("apt_upgrade_dialog_open_log_file_label")) .halign(Align::Center) .margin_start(15) @@ -466,7 +466,7 @@ fn apt_full_upgrade_from_socket( let upgrade_percent_server_context = MainContext::default(); // The main loop executes the asynchronous block - upgrade_percent_server_context.spawn_local(clone!(@weak apt_upgrade_dialog_progress_bar, @weak apt_upgrade_dialog => async move { + upgrade_percent_server_context.spawn_local(clone!(#[weak] apt_upgrade_dialog_progress_bar, async move { while let Ok(state) = upgrade_percent_receiver.recv().await { match state.as_ref() { "FN_OVERRIDE_SUCCESSFUL" => {} @@ -480,7 +480,7 @@ fn apt_full_upgrade_from_socket( let upgrade_status_server_context = MainContext::default(); // The main loop executes the asynchronous block upgrade_status_server_context.spawn_local( - clone!(@weak apt_upgrade_dialog, @weak apt_upgrade_dialog_child_box, @strong apt_upgrade_dialog_child_box_done, @strong apt_upgrade_log_image => async move { + clone!(#[weak] apt_upgrade_dialog, #[weak] apt_upgrade_dialog_child_box, #[strong] apt_upgrade_dialog_child_box_done, #[strong] apt_upgrade_log_image, async move { while let Ok(state) = upgrade_status_receiver.recv().await { match state.as_ref() { "FN_OVERRIDE_SUCCESSFUL" => { @@ -507,7 +507,7 @@ fn apt_full_upgrade_from_socket( let retry_signal_action0 = retry_signal_action.clone(); apt_upgrade_log_button.connect_clicked(move |_| { - let _ = std::process::Command::new("xdg-open") + let _ = Command::new("xdg-open") .arg(log_file_path_clone0.to_owned()) .spawn(); }); @@ -526,13 +526,13 @@ fn create_color_badge( label0_text: &str, label1_text: &str, css_style: &str, - group_size: >k::SizeGroup, - group_size0: >k::SizeGroup, - group_size1: >k::SizeGroup, -) -> gtk::ListBox { - let badge_box = gtk::Box::builder().build(); + group_size: &SizeGroup, + group_size0: &SizeGroup, + group_size1: &SizeGroup, +) -> ListBox { + let badge_box = Box::builder().build(); - let label0 = gtk::Label::builder() + let label0 = Label::builder() .label(label0_text) .margin_start(5) .margin_end(5) @@ -545,9 +545,9 @@ fn create_color_badge( .build(); group_size0.add_widget(&label0); - let label_seprator = gtk::Separator::builder().build(); + let label_separator = Separator::builder().build(); - let label1 = gtk::Label::builder() + let label1 = Label::builder() .label(label1_text) .margin_start(3) .margin_end(0) @@ -563,10 +563,10 @@ fn create_color_badge( label1.add_css_class(css_style); badge_box.append(&label0); - badge_box.append(&label_seprator); + badge_box.append(&label_separator); badge_box.append(&label1); - let boxedlist = gtk::ListBox::builder() + let boxedlist = ListBox::builder() .selection_mode(SelectionMode::None) .halign(Align::Center) .margin_start(10) diff --git a/src/bin/gui/build_ui/mod.rs b/src/bin/gui/build_ui/mod.rs index e90b7b8..8ef0e02 100644 --- a/src/bin/gui/build_ui/mod.rs +++ b/src/bin/gui/build_ui/mod.rs @@ -1,29 +1,24 @@ use crate::apt_update_page; -use crate::apt_update_page::apt_update_page; use crate::config::{APP_GITHUB, APP_ICON, APP_ID, VERSION}; -use crate::glib::closure_local; -use adw::glib::ffi::G_VARIANT_TYPE_ANY; use adw::prelude::*; use adw::*; use gtk::glib::{clone, MainContext}; -use gtk::pango::AttrType::Variant; -use gtk::{License, Orientation, SignalAction}; +use gtk::{License}; use std::cell::RefCell; -use std::ops::Deref; use std::process::Command; use std::rc::Rc; use std::thread; -pub fn build_ui(app: &adw::Application) { +pub fn build_ui(app: &Application) { // setup glib - gtk::glib::set_prgname(Some(t!("app_name").to_string())); + glib::set_prgname(Some(t!("app_name").to_string())); glib::set_application_name(&t!("app_name").to_string()); 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(); - std::thread::spawn(move || loop { + thread::spawn(move || loop { match Command::new("ping").arg("google.com").arg("-c 1").output() { Ok(t) if t.status.success() => internet_loop_sender .send_blocking(true) @@ -35,13 +30,13 @@ pub fn build_ui(app: &adw::Application) { thread::sleep(std::time::Duration::from_secs(5)); }); - let window_banner = adw::Banner::builder().revealed(false).build(); + let window_banner = Banner::builder().revealed(false).build(); let internet_connected_status = internet_connected.clone(); let internet_loop_context = MainContext::default(); // The main loop executes the asynchronous block - internet_loop_context.spawn_local(clone!(@weak window_banner => async move { + internet_loop_context.spawn_local(clone!(#[weak] window_banner, async move { while let Ok(state) = internet_loop_receiver.recv().await { let banner_text = t!("banner_text_no_internet").to_string(); if state == true { @@ -59,26 +54,26 @@ pub fn build_ui(app: &adw::Application) { } })); - let window_headerbar = adw::HeaderBar::builder() + let window_headerbar = HeaderBar::builder() .title_widget( - &adw::WindowTitle::builder() + &WindowTitle::builder() .title(t!("application_name")) .build(), ) .build(); - let window_adw_view_stack = adw::ViewStack::builder() + let window_adw_view_stack = ViewStack::builder() .hhomogeneous(true) .vhomogeneous(true) .build(); - let window_toolbar = adw::ToolbarView::builder() + let window_toolbar = ToolbarView::builder() .content(&window_adw_view_stack) .top_bar_style(ToolbarStyle::Flat) .bottom_bar_style(ToolbarStyle::Flat) .build(); - let window_adw_view_switcher_bar = adw::ViewSwitcherBar::builder() + let window_adw_view_switcher_bar = ViewSwitcherBar::builder() .stack(&window_adw_view_stack) .reveal(true) .build(); @@ -89,7 +84,7 @@ pub fn build_ui(app: &adw::Application) { window_toolbar.add_top_bar(&window_banner); // create the main Application window - let window = adw::ApplicationWindow::builder() + let window = ApplicationWindow::builder() // The text on the titlebar .title(t!("app_name")) // link it to the application "app" @@ -115,21 +110,21 @@ pub fn build_ui(app: &adw::Application) { .tooltip_text(t!("refresh_button_tooltip_text")) .build(); - let credits_window = adw::AboutWindow::builder() + let credits_window = AboutWindow::builder() .application_icon(APP_ICON) .application_name(t!("application_name")) .transient_for(&window) .version(VERSION) .hide_on_close(true) .developer_name(t!("developer_name")) - .license_type(License::Gpl20) + .license_type(License::Mpl20) .issue_url(APP_GITHUB.to_owned() + "/issues") .build(); window_headerbar.pack_end(&refresh_button); window_headerbar.pack_end(&credits_button); credits_button - .connect_clicked(clone!(@weak credits_button => move |_| credits_window.present())); + .connect_clicked(move |_| credits_window.present()); // show the window @@ -138,14 +133,14 @@ pub fn build_ui(app: &adw::Application) { // Apt Update Page let apt_retry_signal_action = gio::SimpleAction::new("retry", None); - let apt_update_view_stack_bin = adw::Bin::builder() + let apt_update_view_stack_bin = Bin::builder() .child(&apt_update_page::apt_update_page( window.clone(), &apt_retry_signal_action, )) .build(); - apt_retry_signal_action.connect_activate(clone!(@weak window, @strong apt_retry_signal_action, @strong apt_update_view_stack_bin => move |_, _| { + apt_retry_signal_action.connect_activate(clone!(#[weak] window, #[strong] apt_retry_signal_action, #[strong] apt_update_view_stack_bin, move |_, _| { apt_update_view_stack_bin.set_child(Some(&apt_update_page::apt_update_page(window, &apt_retry_signal_action))); })); @@ -158,7 +153,7 @@ pub fn build_ui(app: &adw::Application) { // refresh_button.connect_clicked( - clone!(@weak apt_retry_signal_action, @weak window_adw_view_stack => move |_| { + clone!(#[weak] apt_retry_signal_action, #[weak] window_adw_view_stack, move |_| { match window_adw_view_stack.visible_child_name().unwrap().as_str() { "apt_update_page" => apt_retry_signal_action.activate(None), _ => {} diff --git a/src/bin/gui/config.rs b/src/bin/gui/config.rs index 13be845..63ce5f3 100644 --- a/src/bin/gui/config.rs +++ b/src/bin/gui/config.rs @@ -1,5 +1,4 @@ -pub const APP_ID: &str = "com.github.pikaos-linux.pikafirstsetup"; -pub const DISTRO_ICON: &str = "pika-logo"; +pub const APP_ID: &str = "com.github.pikaos-linux.pikmanupdatemanager"; pub const VERSION: &str = env!("CARGO_PKG_VERSION"); -pub const APP_ICON: &str = "com.github.pikaos-linux.pikawelcome"; -pub const APP_GITHUB: &str = "https://github.com/PikaOS-Linux/pkg-pika-welcome"; +pub const APP_ICON: &str = "com.github.pikaos-linux.pikmanupdatemanager"; +pub const APP_GITHUB: &str = "https://github.com/PikaOS-Linux/pkg-pikman-update-manager"; diff --git a/src/lib/apt_install_progress_socket/mod.rs b/src/lib/apt_install_progress_socket/mod.rs index be342bd..8b989af 100644 --- a/src/lib/apt_install_progress_socket/mod.rs +++ b/src/lib/apt_install_progress_socket/mod.rs @@ -1,16 +1,11 @@ use crate::pika_unixsocket_tools::*; -use rust_apt::progress::{DynAcquireProgress, DynInstallProgress}; -use rust_apt::raw::{AcqTextStatus, ItemDesc, PkgAcquire}; +use rust_apt::progress::{DynInstallProgress}; use std::process::exit; use tokio::io::AsyncWriteExt; use tokio::net::UnixStream; use tokio::runtime::Runtime; pub struct AptInstallProgressSocket<'a> { - pkgname: String, - steps_done: u64, - total_steps: u64, - action: String, percent_socket_path: &'a str, status_socket_path: &'a str, } @@ -18,11 +13,7 @@ pub struct AptInstallProgressSocket<'a> { impl<'a> AptInstallProgressSocket<'a> { /// Returns a new default progress instance. pub fn new(percent_socket_path: &'a str, status_socket_path: &'a str) -> Self { - let mut progress = Self { - pkgname: String::new(), - steps_done: 0, - total_steps: 0, - action: String::new(), + let progress = Self { percent_socket_path: percent_socket_path, status_socket_path: status_socket_path, }; @@ -33,7 +24,7 @@ impl<'a> AptInstallProgressSocket<'a> { impl<'a> DynInstallProgress for AptInstallProgressSocket<'a> { fn status_changed( &mut self, - pkgname: String, + _pkgname: String, steps_done: u64, total_steps: u64, action: String, @@ -48,7 +39,7 @@ impl<'a> DynInstallProgress for AptInstallProgressSocket<'a> { .block_on(send_progress_status(&action, self.status_socket_path)); } - fn error(&mut self, pkgname: String, steps_done: u64, total_steps: u64, error: String) { + fn error(&mut self, pkgname: String, _steps_done: u64, _total_steps: u64, error: String) { let message = format!("dpkg failure on {}: {}", pkgname, error); eprintln!("{}", &message); Runtime::new() diff --git a/src/lib/apt_update_progress_socket/mod.rs b/src/lib/apt_update_progress_socket/mod.rs index 15f647e..f156350 100644 --- a/src/lib/apt_update_progress_socket/mod.rs +++ b/src/lib/apt_update_progress_socket/mod.rs @@ -8,8 +8,6 @@ use tokio::runtime::Runtime; pub struct AptUpdateProgressSocket<'a> { pulse_interval: usize, - max: usize, - progress: f32, percent_socket_path: &'a str, status_socket_path: &'a str, } @@ -17,10 +15,8 @@ pub struct AptUpdateProgressSocket<'a> { impl<'a> AptUpdateProgressSocket<'a> { /// Returns a new default progress instance. pub fn new(percent_socket_path: &'a str, status_socket_path: &'a str) -> Self { - let mut progress = Self { + let progress = Self { pulse_interval: 0, - max: 0, - progress: 0.0, percent_socket_path: percent_socket_path, status_socket_path: status_socket_path, }; @@ -89,7 +85,7 @@ impl<'a> DynAcquireProgress for AptUpdateProgressSocket<'a> { /// Stop does not pass information into the method. /// /// prints out the bytes downloaded and the overall average line speed. - fn stop(&mut self, status: &AcqTextStatus) {} + fn stop(&mut self, _status: &AcqTextStatus) {} /// Called when an Item fails to download. /// @@ -118,7 +114,7 @@ impl<'a> DynAcquireProgress for AptUpdateProgressSocket<'a> { /// Draws the current progress. /// Each line has an overall percent meter and a per active item status /// meter along with an overall bandwidth and ETA indicator. - fn pulse(&mut self, status: &AcqTextStatus, owner: &PkgAcquire) { + fn pulse(&mut self, status: &AcqTextStatus, _owner: &PkgAcquire) { let progress_percent: f32 = (status.current_bytes() as f32 * 100.0) / status.total_bytes() as f32; Runtime::new().unwrap().block_on(send_progress_percent( diff --git a/src/lib/pika_unixsocket_tools/mod.rs b/src/lib/pika_unixsocket_tools/mod.rs index 63a70fc..a4a9f04 100644 --- a/src/lib/pika_unixsocket_tools/mod.rs +++ b/src/lib/pika_unixsocket_tools/mod.rs @@ -47,7 +47,7 @@ pub async fn handle_client( let mut buffer = [0; 1024]; if !Path::new(&log_file_path).exists() { - match std::fs::File::create(&log_file_path) { + match fs::File::create(&log_file_path) { Ok(_) => {} Err(_) => { eprintln!("Warning: {} file couldn't be created", log_file_path); @@ -166,7 +166,7 @@ pub async fn start_socket_server_no_log( match listener.accept().await { Ok((stream, _)) => { // Handle the connection in a separate task - task::spawn(crate::pika_unixsocket_tools::handle_client_no_log( + task::spawn(handle_client_no_log( stream, buffer_sender.clone(), ));