diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 42f6565..fac69d5 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -9,6 +9,9 @@ + + + - { - "keyToString": { - "Cargo.Run apt_update.executor": "Run", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.rust.reset.selective.auto.import": "true", - "git-widget-placeholder": "master", - "last_opened_file_path": "/home/ward/RustroverProjects/pika-idk-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.first.attach.projects": "true" + +}]]> @@ -112,7 +116,7 @@ - + diff --git a/Cargo.lock b/Cargo.lock index 9ec7e81..84935f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,12 +26,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "anyhow" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" - [[package]] name = "arc-swap" version = "1.7.1" @@ -58,7 +52,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -139,23 +133,22 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cairo-rs" -version = "0.18.5" +version = "0.19.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2" +checksum = "b2ac2a4d0e69036cf0062976f6efcba1aaee3e448594e6514bb2ddf87acce562" dependencies = [ "bitflags 2.5.0", "cairo-sys-rs", "glib", "libc", - "once_cell", "thiserror", ] [[package]] name = "cairo-sys-rs" -version = "0.18.2" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51" +checksum = "fd3bb3119664efbd78b5e6c93957447944f16bdbced84c17a9f41c7829b81e64" dependencies = [ "glib-sys", "libc", @@ -278,7 +271,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.68", + "syn", ] [[package]] @@ -295,7 +288,7 @@ checksum = "4b2c1c1776b986979be68bb2285da855f8d8a35851a769fca8740df7c3d07877" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -429,7 +422,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -464,22 +457,21 @@ dependencies = [ [[package]] name = "gdk-pixbuf" -version = "0.18.5" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec" +checksum = "624eaba126021103c7339b2e179ae4ee8cdab842daab419040710f38ed9f8699" dependencies = [ "gdk-pixbuf-sys", "gio", "glib", "libc", - "once_cell", ] [[package]] name = "gdk-pixbuf-sys" -version = "0.18.0" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7" +checksum = "4efa05a4f83c8cc50eb4d883787b919b85e5f1d8dd10b5a1df53bf5689782379" dependencies = [ "gio-sys", "glib-sys", @@ -490,9 +482,9 @@ dependencies = [ [[package]] name = "gdk4" -version = "0.7.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edb019ad581f8ecf8ea8e4baa6df7c483a95b5a59be3140be6a9c3b0c632af6" +checksum = "db265c9dd42d6a371e09e52deab3a84808427198b86ac792d75fd35c07990a07" dependencies = [ "cairo-rs", "gdk-pixbuf", @@ -505,9 +497,9 @@ dependencies = [ [[package]] name = "gdk4-sys" -version = "0.7.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbab43f332a3cf1df9974da690b5bb0e26720ed09a228178ce52175372dcfef0" +checksum = "c9418fb4e8a67074919fe7604429c45aa74eb9df82e7ca529767c6d4e9dc66dd" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -537,9 +529,9 @@ checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "gio" -version = "0.18.4" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fc8f532f87b79cbc51a79748f16a6828fb784be93145a322fa14d06d354c73" +checksum = "4c49f117d373ffcc98a35d114db5478bc223341cff53e39a5d6feced9e2ddffe" dependencies = [ "futures-channel", "futures-core", @@ -548,7 +540,6 @@ dependencies = [ "gio-sys", "glib", "libc", - "once_cell", "pin-project-lite", "smallvec 1.13.2", "thiserror", @@ -556,22 +547,22 @@ dependencies = [ [[package]] name = "gio-sys" -version = "0.18.1" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2" +checksum = "2cd743ba4714d671ad6b6234e8ab2a13b42304d0e13ab7eba1dcdd78a7d6d4ef" dependencies = [ "glib-sys", "gobject-sys", "libc", "system-deps", - "winapi 0.3.9", + "windows-sys 0.52.0", ] [[package]] name = "glib" -version = "0.18.5" +version = "0.19.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" +checksum = "39650279f135469465018daae0ba53357942a5212137515777d5fdca74984a44" dependencies = [ "bitflags 2.5.0", "futures-channel", @@ -585,30 +576,28 @@ dependencies = [ "gobject-sys", "libc", "memchr", - "once_cell", "smallvec 1.13.2", "thiserror", ] [[package]] name = "glib-macros" -version = "0.18.5" +version = "0.19.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc" +checksum = "4429b0277a14ae9751350ad9b658b1be0abb5b54faa5bcdf6e74a3372582fad7" dependencies = [ - "heck 0.4.1", - "proc-macro-crate 2.0.0", - "proc-macro-error", + "heck", + "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] name = "glib-sys" -version = "0.18.1" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898" +checksum = "5c2dc18d3a82b0006d470b13304fbbb3e0a9bd4884cf985a60a7ed733ac2c4a5" dependencies = [ "libc", "system-deps", @@ -646,9 +635,9 @@ dependencies = [ [[package]] name = "gobject-sys" -version = "0.18.0" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" +checksum = "2e697e252d6e0416fd1d9e169bda51c0f1c926026c39ca21fbe8b1bb5c3b8b9e" dependencies = [ "glib-sys", "libc", @@ -657,9 +646,9 @@ dependencies = [ [[package]] name = "graphene-rs" -version = "0.18.1" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2228cda1505613a7a956cca69076892cfbda84fc2b7a62b94a41a272c0c401" +checksum = "f5fb86031d24d9ec0a2a15978fc7a65d545a2549642cf1eb7c3dda358da42bcf" dependencies = [ "glib", "graphene-sys", @@ -668,9 +657,9 @@ dependencies = [ [[package]] name = "graphene-sys" -version = "0.18.1" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4144cee8fc8788f2a9b73dc5f1d4e1189d1f95305c4cb7bd9c1af1cfa31f59" +checksum = "2f530e0944bccba4b55065e9c69f4975ad691609191ebac16e13ab8e1f27af05" dependencies = [ "glib-sys", "libc", @@ -680,9 +669,9 @@ dependencies = [ [[package]] name = "gsk4" -version = "0.7.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d958e351d2f210309b32d081c832d7de0aca0b077aa10d88336c6379bd01f7e" +checksum = "7563884bf6939f4468e5d94654945bdd9afcaf8c3ba4c5dd17b5342b747221be" dependencies = [ "cairo-rs", "gdk4", @@ -695,9 +684,9 @@ dependencies = [ [[package]] name = "gsk4-sys" -version = "0.7.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bd9e3effea989f020e8f1ff3fa3b8c63ba93d43b899c11a118868853a56d55" +checksum = "23024bf2636c38bbd1f822f58acc9d1c25b28da896ff0f291a1a232d4272b3dc" dependencies = [ "cairo-sys-rs", "gdk4-sys", @@ -711,9 +700,9 @@ dependencies = [ [[package]] name = "gtk4" -version = "0.7.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aeb51aa3e9728575a053e1f43543cd9992ac2477e1b186ad824fd4adfb70842" +checksum = "b04e11319b08af11358ab543105a9e49b0c491faca35e2b8e7e36bfba8b671ab" dependencies = [ "cairo-rs", "field-offset", @@ -732,23 +721,21 @@ dependencies = [ [[package]] name = "gtk4-macros" -version = "0.7.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d57ec49cf9b657f69a05bca8027cff0a8dfd0c49e812be026fc7311f2163832f" +checksum = "ec655a7ef88d8ce9592899deb8b2d0fa50bab1e6dd69182deb764e643c522408" dependencies = [ - "anyhow", - "proc-macro-crate 1.3.1", - "proc-macro-error", + "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] name = "gtk4-sys" -version = "0.7.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54d8c4aa23638ce9faa2caf7e2a27d4a1295af2155c8e8d28c4d4eeca7a65eb8" +checksum = "8c8aa86b7f85ea71d66ea88c1d4bae1cfacf51ca4856274565133838d77e57b5" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -775,12 +762,6 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -871,9 +852,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libadwaita" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fe7e70c06507ed10a16cda707f358fbe60fe0dc237498f78c686ade92fd979c" +checksum = "91b4990248b9e1ec5e72094a2ccaea70ec3809f88f6fd52192f2af306b87c5d9" dependencies = [ "gdk-pixbuf", "gdk4", @@ -887,9 +868,9 @@ dependencies = [ [[package]] name = "libadwaita-sys" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e10aaa38de1d53374f90deeb4535209adc40cc5dba37f9704724169bceec69a" +checksum = "23a748e4e92be1265cd9e93d569c0b5dfc7814107985aa6743d670ab281ea1a8" dependencies = [ "gdk4-sys", "gio-sys", @@ -1083,22 +1064,21 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "pango" -version = "0.18.3" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4" +checksum = "3f0d328648058085cfd6897c9ae4272884098a926f3a833cd50c8c73e6eccecd" dependencies = [ "gio", "glib", "libc", - "once_cell", "pango-sys", ] [[package]] name = "pango-sys" -version = "0.18.0" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5" +checksum = "ff03da4fa086c0b244d4a4587d3e20622a3ecdb21daea9edf66597224c634ba0" dependencies = [ "glib-sys", "gobject-sys", @@ -1215,45 +1195,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.3.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" -dependencies = [ - "toml_edit 0.20.2", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", + "toml_edit 0.21.1", ] [[package]] @@ -1357,7 +1303,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "syn 2.0.68", + "syn", ] [[package]] @@ -1482,7 +1428,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -1566,17 +1512,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.68" @@ -1595,7 +1530,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" dependencies = [ "cfg-expr", - "heck 0.5.0", + "heck", "pkg-config", "toml 0.8.2", "version-compare", @@ -1643,7 +1578,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -1705,7 +1640,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -1814,6 +1749,17 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap 2.2.6", + "toml_datetime", + "winnow", +] + [[package]] name = "triomphe" version = "0.1.13" @@ -1843,12 +1789,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - [[package]] name = "walkdir" version = "2.5.0" diff --git a/Cargo.toml b/Cargo.toml index 161895d..a3e7063 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ name = "apt_update" path = "src/apt_update/main.rs" [dependencies] -adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] } -gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] } +adw = { version = "0.6.0", package = "libadwaita", features = ["v1_4"] } +gtk = { version = "0.8.2", package = "gtk4", features = ["v4_12"] } async-channel = "2.1.1" rust-i18n = "3.0.1" rust-apt = { git = "https://gitlab.com/volian/rust-apt" } diff --git a/src/apt_update_page/mod.rs b/src/apt_update_page/mod.rs index 8695d70..df21a8d 100644 --- a/src/apt_update_page/mod.rs +++ b/src/apt_update_page/mod.rs @@ -203,8 +203,8 @@ pub fn apt_update_page( .build(); update_button.add_css_class("destructive-action"); - update_button.connect_clicked(clone!(@strong excluded_updates_vec => move |_| { - process::apt_process_update(&excluded_updates_vec.borrow()); + update_button.connect_clicked(clone!(@weak window, @strong excluded_updates_vec => move |_| { + process::apt_process_update(&excluded_updates_vec.borrow(), window); })); bottom_bar.append(&select_button); diff --git a/src/apt_update_page/process.rs b/src/apt_update_page/process.rs index a794680..a8ef5fe 100644 --- a/src/apt_update_page/process.rs +++ b/src/apt_update_page/process.rs @@ -1,7 +1,13 @@ use rust_apt::new_cache; use rust_apt::cache::Upgrade; +use adw::prelude::*; +use gtk::glib::*; +use gtk::*; +use pretty_bytes::converter::convert; +use serde_json::{Value}; +use std::{fs::*}; +use std::path::Path; -#[derive(Debug)] struct AptChangesInfo { package_count: u64, total_download_size: u64, @@ -22,8 +28,49 @@ impl AptChangesInfo { } } -pub fn apt_process_update(excluded_updates_vec: &Vec) { +pub fn apt_process_update(excluded_updates_vec: &Vec, window: adw::ApplicationWindow) { + let excluded_updates_alert_dialog = adw::MessageDialog::builder() + .transient_for(&window) + .heading(t!("excluded_updates_alert_dialog_heading")) + .body(t!("excluded_updates_alert_dialog_body")) + .build(); + excluded_updates_alert_dialog.add_response( + "excluded_updates_alert_dialog_cancel", + &t!("excluded_updates_alert_dialog_cancel_label").to_string(), + ); + + excluded_updates_alert_dialog.add_response( + "excluded_updates_alert_continue", + &t!("excluded_updates_alert_continue_label").to_string(), + ); + + excluded_updates_alert_dialog.set_response_appearance( + "excluded_updates_alert_continue", + adw::ResponseAppearance::Destructive, + ); + + 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); + + excluded_updates_alert_dialog_action.connect_activate(clone!(@weak window, @strong excluded_updates_vec => move |_, _| { + apt_confirm_window(&excluded_updates_vec, window) + })); + + if excluded_updates_vec.is_empty() { + excluded_updates_alert_dialog_action.activate(None); + } else { + excluded_updates_alert_dialog + .choose(None::<&gio::Cancellable>, move |choice| { + if choice == "excluded_updates_alert_continue" { + excluded_updates_alert_dialog_action.activate(None); + } + }); + } +} + +fn apt_confirm_window(excluded_updates_vec: &Vec, window: adw::ApplicationWindow) { // Emulate Apt Full Upgrade to get transaction info let mut apt_changes_struct = AptChangesInfo { package_count: 0, @@ -43,5 +90,148 @@ pub fn apt_process_update(excluded_updates_vec: &Vec) { } } - dbg!(apt_changes_struct); + let apt_confirm_dialog_child_box = gtk::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); + + apt_confirm_dialog_child_box.append( + &create_color_badge( + &t!("package_count_badge_label"), + &apt_changes_struct.package_count.to_string(), + "background-accent-bg", + &apt_update_dialog_badges_size_group, + &apt_update_dialog_badges_size_group0, + &apt_update_dialog_badges_size_group1 + ) + ); + + apt_confirm_dialog_child_box.append( + &create_color_badge( + &t!("total_download_size_badge_label"), + &convert(apt_changes_struct.total_download_size as f64), + "background-accent-bg", + &apt_update_dialog_badges_size_group, + &apt_update_dialog_badges_size_group0, + &apt_update_dialog_badges_size_group1 + ) + ); + + + apt_confirm_dialog_child_box.append( + &create_color_badge( + &t!("total_installed_size_badge_label"), + &convert(apt_changes_struct.total_installed_size as f64), + "background-accent-bg", + &apt_update_dialog_badges_size_group, + &apt_update_dialog_badges_size_group0, + &apt_update_dialog_badges_size_group1 + ) + ); + + let apt_confirm_dialog = adw::MessageDialog::builder() + .transient_for(&window) + .heading(t!("apt_confirm_dialog_heading")) + .body(t!("apt_confirm_dialog_body")) + .extra_child(&apt_confirm_dialog_child_box) + .build(); + + apt_confirm_dialog.add_response( + "apt_confirm_dialog_cancel", + &t!("apt_confirm_dialog_cancel_label").to_string(), + ); + + apt_confirm_dialog.add_response( + "apt_confirm_dialog_confirm", + &t!("apt_confirm_dialog_confirm_label").to_string(), + ); + + apt_confirm_dialog.set_response_appearance( + "apt_confirm_dialog_confirm", + adw::ResponseAppearance::Destructive, + ); + + apt_confirm_dialog.set_default_response(Some("apt_confirm_dialog_confirm")); + + + if !excluded_updates_vec.is_empty() { + let excluded_updates_values: Vec = excluded_updates_vec.into_iter() + .map(|i| serde_json::from_str(format!("{{\"package\":\"{}\"}}", i).as_str())) + .collect::,_>>() + .unwrap(); + + let excluded_updates_values_json = Value::Array(excluded_updates_values); + + let json_file_path = "/tmp/pika-apt-exclusions.json"; + + if Path::new(json_file_path).exists() { + std::fs::remove_file(json_file_path).expect("Failed to remove old json file"); + } + + std::fs::write(json_file_path, serde_json::to_string_pretty(&excluded_updates_values_json).unwrap()).expect("Failed to write to json file"); + } + + apt_confirm_dialog.present(); } + +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(); + + let label0 = gtk::Label::builder() + .label(label0_text) + .margin_start(5) + .margin_end(5) + .margin_bottom(1) + .margin_top(1) + .valign(Align::Center) + .halign(Align::Center) + .hexpand(true) + .vexpand(true) + .build(); + group_size0.add_widget(&label0); + + let label_seprator = gtk::Separator::builder().build(); + + let label1 = gtk::Label::builder() + .label(label1_text) + .margin_start(3) + .margin_end(0) + .margin_bottom(1) + .margin_top(1) + .valign(Align::Center) + .halign(Align::Center) + .hexpand(true) + .vexpand(true) + .build(); + group_size1.add_widget(&label1); + + label1.add_css_class(css_style); + + badge_box.append(&label0); + badge_box.append(&label_seprator); + badge_box.append(&label1); + + let boxedlist = gtk::ListBox::builder() + .selection_mode(SelectionMode::None) + .halign(Align::Center) + .margin_start(10) + .margin_end(10) + .margin_bottom(10) + .margin_top(10) + .build(); + + boxedlist.add_css_class("boxed-list"); + boxedlist.append(&badge_box); + group_size.add_widget(&boxedlist); + boxedlist +} \ No newline at end of file