rename search result object and row
This commit is contained in:
parent
f95fa068f3
commit
f0542071d4
7 changed files with 35 additions and 35 deletions
45
examples/launcher/search_result_row/mod.rs
Normal file
45
examples/launcher/search_result_row/mod.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
use crate::icon_source;
|
||||
use crate::BoxedSearchResult;
|
||||
use gtk4 as gtk;
|
||||
mod imp;
|
||||
|
||||
use crate::SearchResultObject;
|
||||
use gtk::glib;
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct SearchResultRow(ObjectSubclass<imp::SearchResultRow>)
|
||||
@extends gtk::Widget, gtk::Box;
|
||||
}
|
||||
|
||||
impl Default for SearchResultRow {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl SearchResultRow {
|
||||
pub fn new() -> Self {
|
||||
glib::Object::new(&[]).expect("Failed to create SearchResultRow")
|
||||
}
|
||||
|
||||
pub fn set_search_result(&self, search_obj: SearchResultObject) {
|
||||
let self_ = imp::SearchResultRow::from_instance(self);
|
||||
if let Ok(search_result) = search_obj.property("data") {
|
||||
if let Ok(search_result) = search_result.get::<BoxedSearchResult>() {
|
||||
if let Some(search_result) = search_result.0 {
|
||||
self_.name.set_text(&search_result.name);
|
||||
self_.description.set_text(&search_result.description);
|
||||
icon_source(&self_.image, &search_result.icon);
|
||||
icon_source(&self_.categoryimage, &search_result.category_icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_shortcut(&self, indx: u32) {
|
||||
let self_ = imp::SearchResultRow::from_instance(self);
|
||||
self_.shortcut.set_text(&format!("Ctrl + {}", indx));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue