pub struct SearchPage<'a, T> {
pub items: Vec<T>,
pub item_callback: Box<dyn RustofiCallback<T>>,
pub blank_callback: Box<dyn FnMut() -> RustofiResult>,
pub actions: Vec<String>,
pub action_callback: Box<dyn FnMut(&String) -> RustofiResult>,
pub search_callback: Box<dyn FnMut(&String) -> RustofiResult>,
pub window: Window<'a>,
}
Expand description
SearchPage
displays a multi column rofi window and is meant to be used as a search page
of sorts for your application. items
should be associated with a data model, while actions
should be either operations you can perform on those items, or actions you can take within the
app (switch pages for example). The search_callback
allows you to refresh the data models
displayed or perform an operation on custom entry
Fields§
§items: Vec<T>
standard list items, will be displayed in the rofi window using to_string()
item_callback: Box<dyn RustofiCallback<T>>
callback called whenever an item in the items
vector is selected
blank_callback: Box<dyn FnMut() -> RustofiResult>
callback called whenever a blank entry is selected
actions: Vec<String>
additional action entries, meant to be operations on standard items
action_callback: Box<dyn FnMut(&String) -> RustofiResult>
callback called whenever a custom action is selected (NOT on Exit or Cancel)
search_callback: Box<dyn FnMut(&String) -> RustofiResult>
callback to be run when no other entry matches
window: Window<'a>
rofi window instance
Implementations§
Source§impl<'a, T: Display + Clone> SearchPage<'a, T>
impl<'a, T: Display + Clone> SearchPage<'a, T>
Sourcepub fn new(
items: Vec<T>,
item_callback: Box<dyn RustofiCallback<T>>,
search_callback: Box<dyn FnMut(&String) -> RustofiResult>,
) -> Self
pub fn new( items: Vec<T>, item_callback: Box<dyn RustofiCallback<T>>, search_callback: Box<dyn FnMut(&String) -> RustofiResult>, ) -> Self
create the initial bare minumum AppPage, without showing the window yet
Trait Implementations§
Source§impl<'a, T: Display + Clone> RustofiComponent<'a> for SearchPage<'a, T>
impl<'a, T: Display + Clone> RustofiComponent<'a> for SearchPage<'a, T>
Source§fn create_window() -> Window<'a>
fn create_window() -> Window<'a>
create a rofi window with 4 columns
Source§fn action(self, acb: Box<dyn FnMut(&String) -> RustofiResult>) -> Self
fn action(self, acb: Box<dyn FnMut(&String) -> RustofiResult>) -> Self
set the callback to be run when an action is selected
Source§fn blank(self, bcb: Box<dyn FnMut() -> RustofiResult>) -> Self
fn blank(self, bcb: Box<dyn FnMut() -> RustofiResult>) -> Self
set the callback to be run when the blank entry is selected
Source§fn actions(self, actions: Vec<String>) -> Self
fn actions(self, actions: Vec<String>) -> Self
set the actions in the AppPage. This should only be called once as it overwrites the previous settings
Source§fn display(&mut self, prompt: String) -> RustofiResult
fn display(&mut self, prompt: String) -> RustofiResult
display the search window and match the entry against the actions, standard items and finally if nothing matches, run the search callback