From 241b2100e9eae0f1d3a026c94ea0eec505c5de9a Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 29 Jun 2024 01:26:15 +0300 Subject: [PATCH] what? --- .idea/workspace.xml | 3 ++- src/apt_package_row/imp.rs | 38 +++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d99a9a2..44e8096 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -8,6 +8,7 @@ + diff --git a/src/apt_package_row/imp.rs b/src/apt_package_row/imp.rs index 9aa4b1f..5a86c7c 100644 --- a/src/apt_package_row/imp.rs +++ b/src/apt_package_row/imp.rs @@ -61,28 +61,15 @@ impl ObjectImpl for AptPackageRow { expandable_box.add_css_class("linked"); obj.connect_package_name_notify(clone!(@weak prefix_box, @weak expandable_box, @strong obj => move |obj| { - remove_all_children(&prefix_box); - remove_all_children(&expandable_box); + remove_all_children_from_box(&prefix_box); + remove_all_children_from_box(&expandable_box); // let package_name = obj.package_name(); let package_arch = obj.package_arch(); let package_installed_version= obj.package_installed_version(); let package_candidate_version= obj.package_candidate_version(); // - let package_label = gtk::Label::builder() - .halign(Align::Start) - .margin_start(5) - .margin_end(5) - .margin_bottom(5) - .margin_top(5) - .label(package_name) - .build(); - package_label.add_css_class("size-20-bold-text"); - let version_box = gtk::Box::new(Orientation::Horizontal, 0); - version_box.append(&create_version_badge(package_installed_version, package_candidate_version)); - version_box.append(&create_arch_badge(package_arch)); - prefix_box.append(&package_label); - prefix_box.append(&version_box); + create_prefix_content(&prefix_box, &package_arch, &package_installed_version, &package_candidate_version); // let expandable_page_selection_box = gtk::Box::builder() .orientation(Orientation::Horizontal) @@ -240,12 +227,29 @@ fn create_arch_badge(arch: String) -> gtk::ListBox { boxedlist } -fn remove_all_children(parent: &impl IsA -> Box) { +fn remove_all_children_from_box(parent: >k::Box) { while let Some(child) = parent.last_child() { parent.remove(&child); } } +fn create_prefix_content(prefix_box: >k::Box, package_name: &str ,package_arch: &str, package_installed_version: &str, package_candidate_version: &str) { + let package_label = gtk::Label::builder() + .halign(Align::Start) + .margin_start(5) + .margin_end(5) + .margin_bottom(5) + .margin_top(5) + .label(package_name) + .build(); + package_label.add_css_class("size-20-bold-text"); + let version_box = gtk::Box::new(Orientation::Horizontal, 0); + version_box.append(&create_version_badge(package_installed_version, package_candidate_version)); + version_box.append(&create_arch_badge(package_arch)); + prefix_box.append(&package_label); + prefix_box.append(&version_box); +} + pub fn get_diff_by_prefix(xs: String, ys: String) -> (String, String, String) { let mut count = String::new(); for (x,y) in xs.chars().zip(ys.chars()) {