This commit is contained in:
Ward from fusion-voyager-3 2024-06-29 01:26:15 +03:00
parent eeb1720b27
commit 241b2100e9
2 changed files with 23 additions and 18 deletions

View File

@ -8,6 +8,7 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="df2ca9e1-e07d-43f4-bc68-0a6113fc1fa2" name="Changes" comment=""> <list default="true" id="df2ca9e1-e07d-43f4-bc68-0a6113fc1fa2" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/apt_package_row/imp.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/apt_package_row/imp.rs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/apt_package_row/imp.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/apt_package_row/imp.rs" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -99,7 +100,7 @@
<updated>1719504951223</updated> <updated>1719504951223</updated>
<workItem from="1719504952240" duration="1363000" /> <workItem from="1719504952240" duration="1363000" />
<workItem from="1719510804090" duration="7000" /> <workItem from="1719510804090" duration="7000" />
<workItem from="1719609702948" duration="2696000" /> <workItem from="1719609702948" duration="3379000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@ -61,28 +61,15 @@ impl ObjectImpl for AptPackageRow {
expandable_box.add_css_class("linked"); expandable_box.add_css_class("linked");
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 |obj| {
remove_all_children(&prefix_box); remove_all_children_from_box(&prefix_box);
remove_all_children(&expandable_box); remove_all_children_from_box(&expandable_box);
// //
let package_name = obj.package_name(); let package_name = obj.package_name();
let package_arch = obj.package_arch(); let package_arch = obj.package_arch();
let package_installed_version= obj.package_installed_version(); let package_installed_version= obj.package_installed_version();
let package_candidate_version= obj.package_candidate_version(); let package_candidate_version= obj.package_candidate_version();
// //
let package_label = gtk::Label::builder() create_prefix_content(&prefix_box, &package_arch, &package_installed_version, &package_candidate_version);
.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);
// //
let expandable_page_selection_box = gtk::Box::builder() let expandable_page_selection_box = gtk::Box::builder()
.orientation(Orientation::Horizontal) .orientation(Orientation::Horizontal)
@ -240,12 +227,29 @@ fn create_arch_badge(arch: String) -> gtk::ListBox {
boxedlist boxedlist
} }
fn remove_all_children(parent: &impl IsA<Widget> -> Box) { fn remove_all_children_from_box(parent: &gtk::Box) {
while let Some(child) = parent.last_child() { while let Some(child) = parent.last_child() {
parent.remove(&child); parent.remove(&child);
} }
} }
fn create_prefix_content(prefix_box: &gtk::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) { pub fn get_diff_by_prefix(xs: String, ys: String) -> (String, String, String) {
let mut count = String::new(); let mut count = String::new();
for (x,y) in xs.chars().zip(ys.chars()) { for (x,y) in xs.chars().zip(ys.chars()) {