[][src]Struct rustofi::AppPage

pub struct AppPage<'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 window: Window<'a>,
}

AppPage displays a single column rofi window and is meant to be used as a main menu 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)

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)

window: Window<'a>

rofi window instance

Methods

impl<'a, T: Display + Clone> AppPage<'a, T>[src]

pub fn new(items: Vec<T>, item_callback: Box<dyn RustofiCallback<T>>) -> Self[src]

create the initial bare minumum AppPage, without showing the window yet

pub fn message(self, message: &'static str) -> Self[src]

A message usually displayed right beneath the prompt in a rofi window. You can use this to display instructions

Trait Implementations

impl<'a, T: Display + Clone> RustofiComponent<'a> for AppPage<'a, T>[src]

fn create_window() -> Window<'a>[src]

create a centred single column rofi window with Pango markup enabled

fn action(self, acb: Box<dyn FnMut(&String) -> RustofiResult>) -> Self[src]

set the callback to be run when an action is selected

fn blank(self, bcb: Box<dyn FnMut() -> RustofiResult>) -> Self[src]

set the callback to be run when the blank entry is selected

fn actions(self, actions: Vec<String>) -> Self[src]

set the actions in the AppPage. This should only be called once as it overwrites the previous settings

fn window(self, window: Window<'a>) -> Self[src]

set a completely custom window

fn display(&mut self, prompt: String) -> RustofiResult[src]

run the rofi and match the selection to a RustofiResult

Auto Trait Implementations

impl<'a, T> !Send for AppPage<'a, T>

impl<'a, T> !Sync for AppPage<'a, T>

impl<'a, T> Unpin for AppPage<'a, T> where
    T: Unpin

impl<'a, T> !UnwindSafe for AppPage<'a, T>

impl<'a, T> !RefUnwindSafe for AppPage<'a, T>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]