make searchbar work
This commit is contained in:
parent
9a7e998f31
commit
a84bf4efdc
@ -9,7 +9,6 @@
|
||||
<component name="ChangeListManager">
|
||||
<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/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/apt_package_row/mod.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/apt_update_page/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/apt_update_page/mod.rs" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -108,7 +107,7 @@
|
||||
<workItem from="1719847278228" duration="8841000" />
|
||||
<workItem from="1719872581190" duration="4000" />
|
||||
<workItem from="1720090281244" duration="5582000" />
|
||||
<workItem from="1720289925469" duration="4403000" />
|
||||
<workItem from="1720289925469" duration="5474000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
@ -65,8 +65,8 @@ pub fn apt_update_page(window: adw::ApplicationWindow) -> gtk::Box {
|
||||
|
||||
let searchbar = gtk::SearchEntry::builder()
|
||||
.search_delay(500)
|
||||
.margin_top(15)
|
||||
.margin_bottom(15)
|
||||
.margin_start(15)
|
||||
.margin_end(30)
|
||||
.margin_start(30)
|
||||
.build();
|
||||
@ -217,6 +217,25 @@ pub fn apt_update_page(window: adw::ApplicationWindow) -> gtk::Box {
|
||||
}),
|
||||
);
|
||||
|
||||
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" {
|
||||
if !searchbar.text().is_empty() {
|
||||
if row.property::<String>("package-name").to_lowercase().contains(&searchbar.text().to_string().to_lowercase()) {
|
||||
row.set_property("visible", true);
|
||||
searchbar.grab_focus();
|
||||
} else {
|
||||
row.set_property("visible", false);
|
||||
}
|
||||
} else {
|
||||
row.set_property("visible", true);
|
||||
}
|
||||
}
|
||||
counter = row.next_sibling();
|
||||
}
|
||||
}));
|
||||
|
||||
main_box.append(&searchbar);
|
||||
main_box.append(&packages_viewport);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user