mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-30 13:04:13 +00:00
remove extra helper
This commit is contained in:
parent
44d34c46bb
commit
10078b7226
@ -96,14 +96,14 @@ impl List {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find list item by `Value`
|
/// Find list item by `value` (stores ID)
|
||||||
/// * return `position` found
|
/// * return `position` found
|
||||||
pub fn find(&self, value: i64) -> Option<u32> {
|
pub fn find(&self, value: i64) -> Option<u32> {
|
||||||
self.list_store
|
self.list_store
|
||||||
.find_with_equal_func(|this| value == this.clone().downcast::<Item>().unwrap().value())
|
.find_with_equal_func(|this| value == this.clone().downcast::<Item>().unwrap().value())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove list item by `Value`
|
/// Remove list item by `value` (stores ID)
|
||||||
/// * return `position` of removed list item
|
/// * return `position` of removed list item
|
||||||
pub fn remove(&self, value: i64) -> Option<u32> {
|
pub fn remove(&self, value: i64) -> Option<u32> {
|
||||||
match self.find(value) {
|
match self.find(value) {
|
||||||
@ -120,22 +120,23 @@ impl List {
|
|||||||
/// Run callback function on `connect_selected_notify` event
|
/// Run callback function on `connect_selected_notify` event
|
||||||
/// * return `Value` enum match selected item
|
/// * return `Value` enum match selected item
|
||||||
pub fn on_select(&self, callback: impl Fn(Value) + 'static) {
|
pub fn on_select(&self, callback: impl Fn(Value) + 'static) {
|
||||||
self.dropdown
|
self.dropdown.connect_selected_notify(move |this| {
|
||||||
.connect_selected_notify(move |this| callback(selected_item(this).value_enum()));
|
callback(
|
||||||
|
this.selected_item()
|
||||||
|
.and_downcast::<Item>()
|
||||||
|
.unwrap()
|
||||||
|
.value_enum(),
|
||||||
|
)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|
||||||
/// Get selected `Item` GObject
|
/// Get selected `Item` GObject
|
||||||
pub fn selected_item(&self) -> Item {
|
pub fn selected_item(&self) -> Item {
|
||||||
selected_item(&self.dropdown)
|
self.dropdown
|
||||||
|
.selected_item()
|
||||||
|
.and_downcast::<Item>()
|
||||||
|
.unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tools
|
|
||||||
|
|
||||||
/// Cast and return selected `Item` GObject for any internal
|
|
||||||
/// [DropDown](https://docs.gtk.org/gtk4/class.DropDown.html) widget
|
|
||||||
fn selected_item(dropdown: &DropDown) -> Item {
|
|
||||||
dropdown.selected_item().and_downcast::<Item>().unwrap()
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user